there seems to be no reason to treat ZST specially in these cases
This commit is contained in:
parent
0da9409e08
commit
bf91321e0f
@ -359,13 +359,8 @@ struct TmpLayout {
|
||||
// It'll fit, but we need to make some adjustments.
|
||||
match layout.fields {
|
||||
FieldsShape::Arbitrary { ref mut offsets, .. } => {
|
||||
for (j, offset) in offsets.iter_enumerated_mut() {
|
||||
// keep ZST at offset 0 to simplify Scalar/ScalarPair layout
|
||||
if !variants[i][j].0.is_zst() {
|
||||
for offset in offsets.iter_mut() {
|
||||
*offset += this_offset;
|
||||
} else {
|
||||
debug_assert_eq!(offset.bytes(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
@ -962,11 +957,6 @@ fn univariant(
|
||||
};
|
||||
|
||||
(
|
||||
// Place ZSTs first to avoid "interesting offsets", especially with only
|
||||
// one or two non-ZST fields. This helps Scalar/ScalarPair layouts. Note
|
||||
// that these can ignore even some aligned ZST as long as the alignment
|
||||
// is less than that of the scalar, hence we treat *all* ZST like that.
|
||||
!f.0.is_zst(),
|
||||
// Then place largest alignments first.
|
||||
cmp::Reverse(alignment_group_key(f)),
|
||||
// Then prioritize niche placement within alignment group according to
|
||||
|
@ -117,13 +117,13 @@ error: layout_of(S) = Layout {
|
||||
fields: Arbitrary {
|
||||
offsets: [
|
||||
Size(0 bytes),
|
||||
Size(0 bytes),
|
||||
Size(8 bytes),
|
||||
Size(4 bytes),
|
||||
],
|
||||
memory_index: [
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
],
|
||||
},
|
||||
largest_niche: None,
|
||||
|
@ -1,16 +1,16 @@
|
||||
print-type-size type: `S5<(), Empty>`: 16 bytes, alignment: 4 bytes
|
||||
print-type-size field `.w`: 4 bytes
|
||||
print-type-size field `.x`: 4 bytes
|
||||
print-type-size field `.y`: 4 bytes
|
||||
print-type-size field `.z`: 4 bytes
|
||||
print-type-size field `.tagw`: 0 bytes
|
||||
print-type-size field `.unit`: 0 bytes
|
||||
print-type-size field `.void`: 0 bytes
|
||||
print-type-size field `.empty`: 0 bytes
|
||||
print-type-size field `.tagz`: 0 bytes
|
||||
print-type-size field `.w`: 4 bytes
|
||||
print-type-size field `.x`: 4 bytes
|
||||
print-type-size field `.y`: 4 bytes
|
||||
print-type-size field `.z`: 4 bytes
|
||||
print-type-size type: `S1`: 8 bytes, alignment: 4 bytes
|
||||
print-type-size field `.tag`: 0 bytes
|
||||
print-type-size field `.x`: 4 bytes
|
||||
print-type-size field `.y`: 4 bytes
|
||||
print-type-size field `.tag`: 0 bytes
|
||||
print-type-size type: `Empty`: 0 bytes, alignment: 1 bytes
|
||||
print-type-size type: `Void`: 0 bytes, alignment: 1 bytes
|
||||
|
Loading…
Reference in New Issue
Block a user