-
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
Tracking issue for #[repr(align(x))]
on enums
#57996
Comments
#[repr(align(x))]
on enums
Allow #[repr(align(x))] on enums (#57996) Tracking issue: #57996 Implements an extension of [RFC 1358](https://github.com/rust-lang/rfcs/blob/master/text/1358-repr-align.md) behind a feature flag (`repr_align_enum`). Originally introduced here for structs: #39999. It seems like only HIR-level changes are required, since enums are already aware of their alignment (due to alignment of their limbs). cc @bitshifter
Allow #[repr(align(x))] on enums (#57996) Tracking issue: #57996 Implements an extension of [RFC 1358](https://github.com/rust-lang/rfcs/blob/master/text/1358-repr-align.md) behind a feature flag (`repr_align_enum`). Originally introduced here for structs: #39999. It seems like only HIR-level changes are required, since enums are already aware of their alignment (due to alignment of their limbs). cc @bitshifter
This compiles today: #![feature(repr_align_enum)]
#[repr(align(1))]
enum X { X(u64) }
fn main() {
match &X::X(5) {
X::X(x) => println!("{:?}", x),
}
} I would expect this to be an error-- references to |
|
Got it-- it's surprising to me that we wouldn't at least warn on a |
The effect of the attribute is platform dependent. I don't see how we could make this lint free of false positives. We could add something like it to clippy, but as a rustc lint that is always on, false positives are essentially never accepted. Suggesting |
We clearly shouldn't lint for things like |
If that can be done as you describe, adding it to |
Okay-- I'm excited about the idea of an |
Stabilization PR and proposal up in #61229. |
RFC 1358 introduced
#[repr(align(x))]
on structs (and unions). It mentions:It would be a nice convenience to allow this for enums, especially when they are part of a public API.
would be equivalent to using
AlignX<Foo>
everywhere:The text was updated successfully, but these errors were encountered: