Skip to content
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

rustc: do not raise the alignment of optimized enums to the niche's alignment. #46809

Merged
merged 1 commit into from
Dec 22, 2017

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Dec 18, 2017

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

@rust-highfive
Copy link
Collaborator

r? @estebank

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

@eddyb
Copy link
Member Author

eddyb commented Dec 18, 2017

r? @arielb1 or @nagisa

@rust-highfive rust-highfive assigned arielb1 and unassigned estebank 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
@eddyb eddyb force-pushed the issue-46769-optimal branch from e612243 to 090a192 Compare December 18, 2017 16:34
@arielb1
Copy link
Contributor

arielb1 commented Dec 18, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Dec 18, 2017

📌 Commit 090a192 has been approved by arielb1

@arielb1
Copy link
Contributor

arielb1 commented Dec 18, 2017

@bors r_

@arielb1
Copy link
Contributor

arielb1 commented Dec 18, 2017

@bors r-

@eddyb
Copy link
Member Author

eddyb commented Dec 18, 2017

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

@eddyb eddyb closed this Dec 18, 2017
@eddyb eddyb reopened this Dec 18, 2017
@eddyb eddyb force-pushed the issue-46769-optimal branch from 090a192 to 50b069c Compare December 18, 2017 19:58
bors added a commit that referenced this pull request Dec 18, 2017
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
Copy link
Member

kennytm commented Dec 19, 2017

#46808 has been merged.

@eddyb eddyb force-pushed the issue-46769-optimal branch from 50b069c to 8fc4afe Compare December 19, 2017 18:58
@eddyb
Copy link
Member Author

eddyb commented Dec 19, 2017

@bors r=arielb1

@bors
Copy link
Contributor

bors commented Dec 19, 2017

📌 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
Copy link
Contributor

arielb1 commented Dec 19, 2017

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

@bors r-

@arielb1
Copy link
Contributor

arielb1 commented Dec 19, 2017

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>>());

@eddyb eddyb force-pushed the issue-46769-optimal branch from 8fc4afe to 5c3dcfa Compare December 20, 2017 01:45
@eddyb
Copy link
Member Author

eddyb commented Dec 20, 2017

@bors r=arielb1

@bors
Copy link
Contributor

bors commented Dec 20, 2017

📌 Commit 5c3dcfa has been approved by arielb1

kennytm added a commit to kennytm/rust that referenced this pull request Dec 21, 2017
 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
Rollup of 14 pull requests

- Successful merges: #46636, #46780, #46784, #46809, #46814, #46820, #46839, #46847, #46858, #46878, #46884, #46890, #46898, #46918
- Failed merges:
@bors bors merged commit 5c3dcfa into rust-lang:master Dec 22, 2017
@eddyb eddyb deleted the issue-46769-optimal branch December 22, 2017 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants