-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
rustc: do not raise the alignment of optimized enums to the niche's alignment. #46809
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
e612243
to
090a192
Compare
@bors r+ |
📌 Commit 090a192 has been approved by |
@bors r_ |
@bors r- |
(don't mind me, just Travis-cycling the PR) |
090a192
to
50b069c
Compare
rustc: ensure optimized enums have a properly aligned size. Fixes #46769 by padding the optimized enums wrapping packed data as necessary. Note that this is not the only way to solve this - on nightly, #46436 makes it easier to fix without adding new padding because of the replacement of `packed` flags with a non-redundant scheme. But because it can't be backported, the optimal fix will be in a separate nightly-only PR (#46809).
#46808 has been merged. |
50b069c
to
8fc4afe
Compare
@bors r=arielb1 |
📌 Commit 8fc4afe has been approved by |
Could you please add a test that the size of a packed enum is what it's supposed to be? @bors r- |
Something like this: // This struct has a single niche - the dealigned pointer within. Check that
// it is null-pointer-optimized correctly
struct Interesting {
packed: Packed<&'static ()>,
other: u8
}
assert_eq!(mem::size_of::<Interesting>(), mem::size_of::<Option<Interesting>>()); |
8fc4afe
to
5c3dcfa
Compare
@bors r=arielb1 |
📌 Commit 5c3dcfa has been approved by |
rustc: do not raise the alignment of optimized enums to the niche's alignment. This is the improved fix for rust-lang#46769 that does not increase the size of any types (see also rust-lang#46808).
This is the improved fix for #46769 that does not increase the size of any types (see also #46808).