-
Notifications
You must be signed in to change notification settings - Fork 13k
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(X)] should inhibit enum layout optimization #40029
Comments
As usual filing an issue for every regression; it doesn't mean that the change in behaviour must be fixed. In this case it probably should, though. |
First nightly with change is |
All crates affected by the nodrop breakage are fixed by just released nodrop 0.1.9. It changed from this: #[repr(u8)]
enum Flag<T> {
Alive(T),
Dropped,
} to this: #[repr(u8)]
enum Flag<T> {
Alive(T),
Dropped(u8),
} I didn't find a reason to not use this workaround. |
I believe we should restore the old behavior. I feel like if you request a representation with a I could see other choices, but given that this is what we've done till now (right?) I'd say we ought to stick with it. If you want the option for us to apply further optimizations (use "u8" if you need a discriminant, but otherwise who cares...) we should have people opt in to that. |
I agree this is a regression that should be fixed. |
on it. |
See #40188 |
inhibit enum layout optimizations under `#[repr(C)]` or `#[repr(u8)]` Fixes #40029
This is a regression stable to nightly (breaking nodrop and arrayvec at the moment; not their compilation but their tests, which indicate their implementation is not sound for element types like
&T
orVec<T>
).Found by cargobomb report
Note that the regression applies to enums with
#[repr(u8)]
(and similar) but not#[repr(C)]
.PR #25651 was never merged, but it would document this aspect of
#[repr(u8)]
Evaluating #39595 for its impact. Thanks @eddyb for the pointers!
The text was updated successfully, but these errors were encountered: