Add additional test case for repr(packed) allowing union abi opt to kick in.

This commit is contained in:
Luqman Aden 2022-11-30 23:16:57 -08:00
parent d5ab3a06d2
commit f2d81defa1
2 changed files with 33 additions and 2 deletions

View File

@ -56,6 +56,10 @@ union P3 { x: F32x4 } //~ ERROR: layout_of
#[repr(packed(1))]
union P4 { x: E } //~ ERROR: layout_of
#[rustc_layout(debug)]
#[repr(packed(1))]
union P5 { zst: [u16; 0], byte: u8 } //~ ERROR: layout_of
#[rustc_layout(debug)]
type X = std::mem::MaybeUninit<u8>; //~ ERROR: layout_of

View File

@ -461,6 +461,33 @@ error: layout_of(P4) = Layout {
LL | union P4 { x: E }
| ^^^^^^^^
error: layout_of(P5) = Layout {
size: Size(1 bytes),
align: AbiAndPrefAlign {
abi: Align(1 bytes),
pref: $PREF_ALIGN,
},
abi: Scalar(
Union {
value: Int(
I8,
false,
),
},
),
fields: Union(
2,
),
largest_niche: None,
variants: Single {
index: 0,
},
}
--> $DIR/debug.rs:61:1
|
LL | union P5 { zst: [u16; 0], byte: u8 }
| ^^^^^^^^
error: layout_of(std::mem::MaybeUninit<u8>) = Layout {
size: Size(1 bytes),
align: AbiAndPrefAlign {
@ -483,10 +510,10 @@ error: layout_of(std::mem::MaybeUninit<u8>) = Layout {
index: 0,
},
}
--> $DIR/debug.rs:60:1
--> $DIR/debug.rs:64:1
|
LL | type X = std::mem::MaybeUninit<u8>;
| ^^^^^^
error: aborting due to 13 previous errors
error: aborting due to 14 previous errors