Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up#[repr(X)] should inhibit enum layout optimization #40029
Comments
bluss
added
the
regression-from-stable-to-nightly
label
Feb 22, 2017
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
First nightly with change is |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
brson
added
the
P-high
label
Mar 1, 2017
This comment has been minimized.
This comment has been minimized.
|
I agree this is a regression that should be fixed. |
brson
added
T-compiler
I-nominated
labels
Mar 1, 2017
This comment has been minimized.
This comment has been minimized.
|
on it. |
nikomatsakis
self-assigned this
Mar 1, 2017
nikomatsakis
added a commit
to nikomatsakis/rust
that referenced
this issue
Mar 1, 2017
nikomatsakis
referenced this issue
Mar 1, 2017
Merged
inhibit enum layout optimizations under `#[repr(C)]` or `#[repr(u8)]` #40188
This comment has been minimized.
This comment has been minimized.
|
See #40188 |
bluss commentedFeb 22, 2017
•
edited
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
&TorVec<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!