Do not disable field reordering on enums with big discriminant#70748
Merged
bors merged 1 commit intorust-lang:masterfrom Apr 5, 2020
Merged
Do not disable field reordering on enums with big discriminant#70748bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
The field are always re-ordered to minimize padding, regardless of the alignment of the discriminant
Contributor
|
(rust_highfive has picked a reviewer for you, use r? to override) |
Contributor
|
r? @eddyb |
eddyb
reviewed
Apr 4, 2020
| assert_eq!(size_of::<e3>(), 4 as usize); | ||
| assert_eq!(size_of::<ReorderedStruct>(), 4); | ||
| assert_eq!(size_of::<ReorderedEnum>(), 6); | ||
| assert_eq!(size_of::<ReorderedEnum2>(), 8); |
Member
There was a problem hiding this comment.
For the record, before this PR it was 12.
Member
|
FWIW, this has some more details #70477 (comment). My reasoning is that the discriminant "commutes" with the group of fields right next to it, which have lower alignment, without changes in padding. I believe this doesn't hold for descending sorting (by alignment), but only ascending sorting, of variant fields (it's the latter we do for I haven't fully looked into what other implications partially-sorted field orders have. @bors r+ |
Collaborator
|
📌 Commit 6b6cb7b has been approved by |
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this pull request
Apr 4, 2020
Do not disable field reordering on enums with big discriminant The field are always re-ordered to minimize padding, regardless of the alignment of the discriminant (spinoff from rust-lang#70477)
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 5, 2020
Rollup of 6 pull requests Successful merges: - rust-lang#70635 (rustc_target: Some cleanup to `no_default_libraries`) - rust-lang#70748 (Do not disable field reordering on enums with big discriminant) - rust-lang#70752 (Add slice::fill) - rust-lang#70766 (use ManuallyDrop instead of forget inside collections) - rust-lang#70768 (macro_rules: `NtLifetime` cannot start with an identifier) - rust-lang#70783 (comment refers to removed type) Failed merges: r? @ghost
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The field are always re-ordered to minimize padding, regardless of the
alignment of the discriminant
(spinoff from #70477)