rustc: do not raise the alignment of optimized enums to the niche's alignment. by eddyb · Pull Request #46809 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation14 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@eddyb

This is the improved fix for #46769 that does not increase the size of any types (see also #46808).

@rust-highfive

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@eddyb

@eddyb eddyb mentioned this pull request

Dec 18, 2017

@kennytm kennytm added the S-blocked

Status: Blocked on something else such as an RFC or other implementation work.

label

Dec 18, 2017

@arielb1

@bors

📌 Commit 090a192 has been approved by arielb1

@arielb1

@arielb1

@eddyb

(don't mind me, just Travis-cycling the PR)

bors added a commit that referenced this pull request

Dec 18, 2017

@bors

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).

@kennytm kennytm added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-blocked

Status: Blocked on something else such as an RFC or other implementation work.

labels

Dec 19, 2017

@kennytm

@eddyb

@bors

📌 Commit 8fc4afe has been approved by arielb1

@kennytm kennytm added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Dec 19, 2017

@arielb1

Could you please add a test that the size of a packed enum is what it's supposed to be?

@bors r-

@arielb1

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::(), mem::size_of::<Option>());

@eddyb

@eddyb

@bors

📌 Commit 5c3dcfa has been approved by arielb1

kennytm added a commit to kennytm/rust that referenced this pull request

Dec 21, 2017

@kennytm

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).

bors added a commit that referenced this pull request

Dec 21, 2017

@bors

Rollup of 14 pull requests

@eddyb eddyb deleted the issue-46769-optimal branch

December 22, 2017 06:25

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.