Skip to content

Commit f2d81de

Browse files
committed
Add additional test case for repr(packed) allowing union abi opt to kick in.
1 parent d5ab3a0 commit f2d81de

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

tests/ui/layout/debug.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ union P3 { x: F32x4 } //~ ERROR: layout_of
5656
#[repr(packed(1))]
5757
union P4 { x: E } //~ ERROR: layout_of
5858

59+
#[rustc_layout(debug)]
60+
#[repr(packed(1))]
61+
union P5 { zst: [u16; 0], byte: u8 } //~ ERROR: layout_of
62+
5963
#[rustc_layout(debug)]
6064
type X = std::mem::MaybeUninit<u8>; //~ ERROR: layout_of
6165

tests/ui/layout/debug.stderr

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,33 @@ error: layout_of(P4) = Layout {
461461
LL | union P4 { x: E }
462462
| ^^^^^^^^
463463

464+
error: layout_of(P5) = Layout {
465+
size: Size(1 bytes),
466+
align: AbiAndPrefAlign {
467+
abi: Align(1 bytes),
468+
pref: $PREF_ALIGN,
469+
},
470+
abi: Scalar(
471+
Union {
472+
value: Int(
473+
I8,
474+
false,
475+
),
476+
},
477+
),
478+
fields: Union(
479+
2,
480+
),
481+
largest_niche: None,
482+
variants: Single {
483+
index: 0,
484+
},
485+
}
486+
--> $DIR/debug.rs:61:1
487+
|
488+
LL | union P5 { zst: [u16; 0], byte: u8 }
489+
| ^^^^^^^^
490+
464491
error: layout_of(std::mem::MaybeUninit<u8>) = Layout {
465492
size: Size(1 bytes),
466493
align: AbiAndPrefAlign {
@@ -483,10 +510,10 @@ error: layout_of(std::mem::MaybeUninit<u8>) = Layout {
483510
index: 0,
484511
},
485512
}
486-
--> $DIR/debug.rs:60:1
513+
--> $DIR/debug.rs:64:1
487514
|
488515
LL | type X = std::mem::MaybeUninit<u8>;
489516
| ^^^^^^
490517

491-
error: aborting due to 13 previous errors
518+
error: aborting due to 14 previous errors
492519

0 commit comments

Comments
 (0)