Open
Description
See here for an elaboration of the redundancy. Below follows the original issue that lead to us looking into this.
I just discovered something rather strange in our enum layouts: std::sync::atomic::Ordering
has
abi: Scalar(
Initialized {
value: Int(
I8,
false,
),
valid_range: 0..=4,
},
),
but its variants look like
Layout {
size: Size(1 bytes),
align: AbiAndPrefAlign {
abi: Align(1 bytes),
pref: Align(8 bytes),
},
abi: Aggregate {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
variants: Single {
index: 0,
},
max_repr_align: None,
unadjusted_abi_align: Align(1 bytes),
},
Note the abi: Aggregate
!
I am surprised that this has not already lead to ICEs in CTFE/Miri -- via downcasting, one can end up with Immediate::Scalar
that have Aggregate
ABI, which can quickly panic.
This is a bug, right? If the enum has Scalar
layout, then all its variants should also have that layout? For ScalarPair enums, this seems to already be the case.
Cc @oli-obk @eddyb