fix for the issue #92464
This commit is contained in:
parent
38c22af015
commit
fd5be23a96
@ -1310,7 +1310,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
},
|
||||
};
|
||||
let mut abi = Abi::Aggregate { sized: true };
|
||||
if tag.value.size(dl) == size {
|
||||
|
||||
// Without latter check aligned enums with custom discriminant values
|
||||
// Would result in ICE see the issue #92464 for more info
|
||||
if tag.value.size(dl) == size || variants.iter().all(|layout| layout.is_empty()) {
|
||||
abi = Abi::Scalar(tag);
|
||||
} else {
|
||||
// Try to use a ScalarPair for all tagged enums.
|
||||
|
15
src/test/ui/aligned_enum_cast.rs
Normal file
15
src/test/ui/aligned_enum_cast.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// run-pass
|
||||
// allows aligned custom discriminant enums to cast into other types
|
||||
// See the issue #92464 for more info
|
||||
#[allow(dead_code)]
|
||||
#[repr(align(8))]
|
||||
enum Aligned {
|
||||
Zero = 0,
|
||||
One = 1,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let aligned = Aligned::Zero;
|
||||
let fo = aligned as u8;
|
||||
println!("foo {}",fo);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user