about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLuqman Aden <me@luqman.ca>2022-11-30 23:16:57 -0800
committerLuqman Aden <me@luqman.ca>2023-05-05 16:05:04 -0700
commitf2d81defa1e78921db326835fc9a7e21475868d1 (patch)
treea95bc5582659a698cabe69974647b691c964e2c8
parentd5ab3a06d2a7a16f8774ea0b3c2455465b0962a9 (diff)
downloadrust-f2d81defa1e78921db326835fc9a7e21475868d1.tar.gz
rust-f2d81defa1e78921db326835fc9a7e21475868d1.zip
Add additional test case for repr(packed) allowing union abi opt to kick in.
-rw-r--r--tests/ui/layout/debug.rs4
-rw-r--r--tests/ui/layout/debug.stderr31
2 files changed, 33 insertions, 2 deletions
diff --git a/tests/ui/layout/debug.rs b/tests/ui/layout/debug.rs
index 78dbb1a299e..46171880a6f 100644
--- a/tests/ui/layout/debug.rs
+++ b/tests/ui/layout/debug.rs
@@ -57,6 +57,10 @@ union P3 { x: F32x4 } //~ ERROR: layout_of
 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
 
 fn f() -> T {
diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr
index c296c2ba797..b9fa1b299e9 100644
--- a/tests/ui/layout/debug.stderr
+++ b/tests/ui/layout/debug.stderr
@@ -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