-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#[repr()]
is allowed where it shouldn't
#129606
Comments
If someone wants to fix this they should check if there's an RFC for |
I'll fold this into #129422 (or probably just do it as a follow-up) |
Otherwise |
…<try> disallow `repr()` on invalid items fixes rust-lang#129606 Disallows `repr()` (so a repr with no arguments) on items where that won't ever make sense. Also this generates an error when `repr` is used on a trait method and the `fn_align` feature is not enabled. Looks like that was missed here: https://github.com/rust-lang/rust/pull/110313/files Which first accepts the align attribute on trait methods. r? `@compiler-errors`
…<try> disallow `repr()` on invalid items fixes rust-lang#129606 fixes rust-lang#132391 Disallows `repr()` (so a repr with no arguments) on items where that won't ever make sense. Also this generates an error when `repr` is used on a trait method and the `fn_align` feature is not enabled. Looks like that was missed here: https://github.com/rust-lang/rust/pull/110313/files Which first accepts the align attribute on trait methods. r? `@compiler-errors` cc `@jdonszelmann` who claimed rust-lang#132391 and generally has been working on attributes
…r=compiler-errors disallow `repr()` on invalid items fixes rust-lang#129606 fixes rust-lang#132391 Disallows `repr()` (so a repr with no arguments) on items where that won't ever make sense. Also this generates an error when `repr` is used on a trait method and the `fn_align` feature is not enabled. Looks like that was missed here: https://github.com/rust-lang/rust/pull/110313/files Which first accepts the align attribute on trait methods. r? `@compiler-errors` cc `@jdonszelmann` who claimed rust-lang#132391 and generally has been working on attributes
Rollup merge of rust-lang#133925 - folkertdev:improve-repr-warnings, r=compiler-errors disallow `repr()` on invalid items fixes rust-lang#129606 fixes rust-lang#132391 Disallows `repr()` (so a repr with no arguments) on items where that won't ever make sense. Also this generates an error when `repr` is used on a trait method and the `fn_align` feature is not enabled. Looks like that was missed here: https://github.com/rust-lang/rust/pull/110313/files Which first accepts the align attribute on trait methods. r? `@compiler-errors` cc `@jdonszelmann` who claimed rust-lang#132391 and generally has been working on attributes
I tried this code:
I expected to see this happen: #[repr] doesn't make sense on other than struct/enum/union, so it shouldn't be permitted. Every case except the
struct
should be an error. Not sure if that one ought to be legal either, but I guess the current warning is enough there.Instead, this happened: Plenty of unused attribute warnings, but it compiles.
Meta
Tested on playground, both
1.80.1
and1.82.0-nightly (2024-08-24 f167efad2f51088d8618)
.The text was updated successfully, but these errors were encountered: