summaryrefslogtreecommitdiffstats
path: root/src/test/ui/repr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/repr
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/repr')
-rw-r--r--src/test/ui/repr/attr-usage-repr.rs33
-rw-r--r--src/test/ui/repr/attr-usage-repr.stderr35
-rw-r--r--src/test/ui/repr/auxiliary/repr-transparent-non-exhaustive.rs18
-rw-r--r--src/test/ui/repr/issue-83505-repr-simd.rs10
-rw-r--r--src/test/ui/repr/issue-83505-repr-simd.stderr30
-rw-r--r--src/test/ui/repr/issue-83921-ice.rs34
-rw-r--r--src/test/ui/repr/issue-83921-ice.stderr46
-rw-r--r--src/test/ui/repr/repr-align-assign.fixed13
-rw-r--r--src/test/ui/repr/repr-align-assign.rs13
-rw-r--r--src/test/ui/repr/repr-align-assign.stderr27
-rw-r--r--src/test/ui/repr/repr-align.rs33
-rw-r--r--src/test/ui/repr/repr-align.stderr75
-rw-r--r--src/test/ui/repr/repr-disallow-on-variant.rs9
-rw-r--r--src/test/ui/repr/repr-disallow-on-variant.stderr12
-rw-r--r--src/test/ui/repr/repr-packed-contains-align.rs53
-rw-r--r--src/test/ui/repr/repr-packed-contains-align.stderr139
-rw-r--r--src/test/ui/repr/repr-transparent-issue-87496.rs12
-rw-r--r--src/test/ui/repr/repr-transparent-issue-87496.stderr16
-rw-r--r--src/test/ui/repr/repr-transparent-non-exhaustive.rs96
-rw-r--r--src/test/ui/repr/repr-transparent-non-exhaustive.stderr127
-rw-r--r--src/test/ui/repr/repr-transparent-other-items.rs9
-rw-r--r--src/test/ui/repr/repr-transparent-other-items.stderr19
-rw-r--r--src/test/ui/repr/repr-transparent-other-reprs.rs18
-rw-r--r--src/test/ui/repr/repr-transparent-other-reprs.stderr29
-rw-r--r--src/test/ui/repr/repr-transparent.rs90
-rw-r--r--src/test/ui/repr/repr-transparent.stderr90
-rw-r--r--src/test/ui/repr/repr.rs13
-rw-r--r--src/test/ui/repr/repr.stderr20
28 files changed, 1119 insertions, 0 deletions
diff --git a/src/test/ui/repr/attr-usage-repr.rs b/src/test/ui/repr/attr-usage-repr.rs
new file mode 100644
index 000000000..8965decc3
--- /dev/null
+++ b/src/test/ui/repr/attr-usage-repr.rs
@@ -0,0 +1,33 @@
+#![feature(repr_simd)]
+
+#[repr(C)] //~ ERROR: attribute should be applied to a struct, enum, or union
+fn f() {}
+
+#[repr(C)]
+struct SExtern(f64, f64);
+
+#[repr(packed)]
+struct SPacked(f64, f64);
+
+#[repr(simd)]
+struct SSimd(f64, f64);
+
+#[repr(i8)] //~ ERROR: attribute should be applied to an enum
+struct SInt(f64, f64);
+
+#[repr(C)]
+enum EExtern { A, B }
+
+#[repr(align(8))]
+enum EAlign { A, B }
+
+#[repr(packed)] //~ ERROR: attribute should be applied to a struct
+enum EPacked { A, B }
+
+#[repr(simd)] //~ ERROR: attribute should be applied to a struct
+enum ESimd { A, B }
+
+#[repr(i8)]
+enum EInt { A, B }
+
+fn main() {}
diff --git a/src/test/ui/repr/attr-usage-repr.stderr b/src/test/ui/repr/attr-usage-repr.stderr
new file mode 100644
index 000000000..42f65625a
--- /dev/null
+++ b/src/test/ui/repr/attr-usage-repr.stderr
@@ -0,0 +1,35 @@
+error[E0517]: attribute should be applied to a struct, enum, or union
+ --> $DIR/attr-usage-repr.rs:3:8
+ |
+LL | #[repr(C)]
+ | ^
+LL | fn f() {}
+ | --------- not a struct, enum, or union
+
+error[E0517]: attribute should be applied to an enum
+ --> $DIR/attr-usage-repr.rs:15:8
+ |
+LL | #[repr(i8)]
+ | ^^
+LL | struct SInt(f64, f64);
+ | ---------------------- not an enum
+
+error[E0517]: attribute should be applied to a struct or union
+ --> $DIR/attr-usage-repr.rs:24:8
+ |
+LL | #[repr(packed)]
+ | ^^^^^^
+LL | enum EPacked { A, B }
+ | --------------------- not a struct or union
+
+error[E0517]: attribute should be applied to a struct
+ --> $DIR/attr-usage-repr.rs:27:8
+ |
+LL | #[repr(simd)]
+ | ^^^^
+LL | enum ESimd { A, B }
+ | ------------------- not a struct
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0517`.
diff --git a/src/test/ui/repr/auxiliary/repr-transparent-non-exhaustive.rs b/src/test/ui/repr/auxiliary/repr-transparent-non-exhaustive.rs
new file mode 100644
index 000000000..4bf6b54fe
--- /dev/null
+++ b/src/test/ui/repr/auxiliary/repr-transparent-non-exhaustive.rs
@@ -0,0 +1,18 @@
+#![crate_type = "lib"]
+
+pub struct Private { _priv: () }
+
+#[non_exhaustive]
+pub struct NonExhaustive {}
+
+#[non_exhaustive]
+pub enum NonExhaustiveEnum {}
+
+pub enum NonExhaustiveVariant {
+ #[non_exhaustive]
+ A,
+}
+
+pub struct ExternalIndirection<T> {
+ pub x: T,
+}
diff --git a/src/test/ui/repr/issue-83505-repr-simd.rs b/src/test/ui/repr/issue-83505-repr-simd.rs
new file mode 100644
index 000000000..280b771d0
--- /dev/null
+++ b/src/test/ui/repr/issue-83505-repr-simd.rs
@@ -0,0 +1,10 @@
+// Regression test for the ICE described in #83505.
+
+#![crate_type="lib"]
+
+#[repr(simd)]
+//~^ ERROR: attribute should be applied to a struct [E0517]
+//~| ERROR: unsupported representation for zero-variant enum [E0084]
+enum Es {}
+static CLs: Es;
+//~^ ERROR: free static item without body
diff --git a/src/test/ui/repr/issue-83505-repr-simd.stderr b/src/test/ui/repr/issue-83505-repr-simd.stderr
new file mode 100644
index 000000000..df99baaf5
--- /dev/null
+++ b/src/test/ui/repr/issue-83505-repr-simd.stderr
@@ -0,0 +1,30 @@
+error: free static item without body
+ --> $DIR/issue-83505-repr-simd.rs:9:1
+ |
+LL | static CLs: Es;
+ | ^^^^^^^^^^^^^^-
+ | |
+ | help: provide a definition for the static: `= <expr>;`
+
+error[E0517]: attribute should be applied to a struct
+ --> $DIR/issue-83505-repr-simd.rs:5:8
+ |
+LL | #[repr(simd)]
+ | ^^^^
+...
+LL | enum Es {}
+ | ---------- not a struct
+
+error[E0084]: unsupported representation for zero-variant enum
+ --> $DIR/issue-83505-repr-simd.rs:5:1
+ |
+LL | #[repr(simd)]
+ | ^^^^^^^^^^^^^
+...
+LL | enum Es {}
+ | ------- zero-variant enum
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0084, E0517.
+For more information about an error, try `rustc --explain E0084`.
diff --git a/src/test/ui/repr/issue-83921-ice.rs b/src/test/ui/repr/issue-83921-ice.rs
new file mode 100644
index 000000000..70583eb9b
--- /dev/null
+++ b/src/test/ui/repr/issue-83921-ice.rs
@@ -0,0 +1,34 @@
+// Regression test for various ICEs inspired by
+// https://github.com/rust-lang/rust/issues/83921#issuecomment-814640734
+
+// compile-flags: -Zdeduplicate-diagnostics=yes
+
+#[repr(packed())]
+//~^ ERROR: incorrect `repr(packed)` attribute format
+struct S1;
+
+#[repr(align)]
+//~^ ERROR: invalid `repr(align)` attribute
+struct S2;
+
+#[repr(align(2, 4))]
+//~^ ERROR: incorrect `repr(align)` attribute format
+struct S3;
+
+#[repr(align())]
+//~^ ERROR: incorrect `repr(align)` attribute format
+struct S4;
+
+#[repr(i8())]
+//~^ ERROR: invalid representation hint
+enum E1 { A, B }
+
+#[repr(u32(42))]
+//~^ ERROR: invalid representation hint
+enum E2 { A, B }
+
+#[repr(i64 = 2)]
+//~^ ERROR: invalid representation hint
+enum E3 { A, B }
+
+fn main() {}
diff --git a/src/test/ui/repr/issue-83921-ice.stderr b/src/test/ui/repr/issue-83921-ice.stderr
new file mode 100644
index 000000000..32c450410
--- /dev/null
+++ b/src/test/ui/repr/issue-83921-ice.stderr
@@ -0,0 +1,46 @@
+error[E0552]: incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all
+ --> $DIR/issue-83921-ice.rs:6:8
+ |
+LL | #[repr(packed())]
+ | ^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: `align` needs an argument
+ --> $DIR/issue-83921-ice.rs:10:8
+ |
+LL | #[repr(align)]
+ | ^^^^^ help: supply an argument here: `align(...)`
+
+error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
+ --> $DIR/issue-83921-ice.rs:14:8
+ |
+LL | #[repr(align(2, 4))]
+ | ^^^^^^^^^^^
+
+error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses
+ --> $DIR/issue-83921-ice.rs:18:8
+ |
+LL | #[repr(align())]
+ | ^^^^^^^
+
+error[E0552]: invalid representation hint: `i8` does not take a parenthesized argument list
+ --> $DIR/issue-83921-ice.rs:22:8
+ |
+LL | #[repr(i8())]
+ | ^^^^
+
+error[E0552]: invalid representation hint: `u32` does not take a parenthesized argument list
+ --> $DIR/issue-83921-ice.rs:26:8
+ |
+LL | #[repr(u32(42))]
+ | ^^^^^^^
+
+error[E0552]: invalid representation hint: `i64` does not take a value
+ --> $DIR/issue-83921-ice.rs:30:8
+ |
+LL | #[repr(i64 = 2)]
+ | ^^^^^^^
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0552, E0589, E0693.
+For more information about an error, try `rustc --explain E0552`.
diff --git a/src/test/ui/repr/repr-align-assign.fixed b/src/test/ui/repr/repr-align-assign.fixed
new file mode 100644
index 000000000..59ca22e97
--- /dev/null
+++ b/src/test/ui/repr/repr-align-assign.fixed
@@ -0,0 +1,13 @@
+// run-rustfix
+
+#![allow(dead_code)]
+
+#[repr(align(8))] //~ ERROR incorrect `repr(align)` attribute format
+ //~| ERROR incorrect `repr(align)` attribute format
+struct A(u64);
+
+#[repr(align(8))] //~ ERROR incorrect `repr(align)` attribute format
+ //~| ERROR incorrect `repr(align)` attribute format
+struct B(u64);
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-align-assign.rs b/src/test/ui/repr/repr-align-assign.rs
new file mode 100644
index 000000000..6b7799297
--- /dev/null
+++ b/src/test/ui/repr/repr-align-assign.rs
@@ -0,0 +1,13 @@
+// run-rustfix
+
+#![allow(dead_code)]
+
+#[repr(align=8)] //~ ERROR incorrect `repr(align)` attribute format
+ //~| ERROR incorrect `repr(align)` attribute format
+struct A(u64);
+
+#[repr(align="8")] //~ ERROR incorrect `repr(align)` attribute format
+ //~| ERROR incorrect `repr(align)` attribute format
+struct B(u64);
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-align-assign.stderr b/src/test/ui/repr/repr-align-assign.stderr
new file mode 100644
index 000000000..b878ae0d1
--- /dev/null
+++ b/src/test/ui/repr/repr-align-assign.stderr
@@ -0,0 +1,27 @@
+error[E0693]: incorrect `repr(align)` attribute format
+ --> $DIR/repr-align-assign.rs:5:8
+ |
+LL | #[repr(align=8)]
+ | ^^^^^^^ help: use parentheses instead: `align(8)`
+
+error[E0693]: incorrect `repr(align)` attribute format
+ --> $DIR/repr-align-assign.rs:9:8
+ |
+LL | #[repr(align="8")]
+ | ^^^^^^^^^ help: use parentheses instead: `align(8)`
+
+error[E0693]: incorrect `repr(align)` attribute format
+ --> $DIR/repr-align-assign.rs:5:8
+ |
+LL | #[repr(align=8)]
+ | ^^^^^^^ help: use parentheses instead: `align(8)`
+
+error[E0693]: incorrect `repr(align)` attribute format
+ --> $DIR/repr-align-assign.rs:9:8
+ |
+LL | #[repr(align="8")]
+ | ^^^^^^^^^ help: use parentheses instead: `align(8)`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0693`.
diff --git a/src/test/ui/repr/repr-align.rs b/src/test/ui/repr/repr-align.rs
new file mode 100644
index 000000000..58ecf9a51
--- /dev/null
+++ b/src/test/ui/repr/repr-align.rs
@@ -0,0 +1,33 @@
+#![allow(dead_code)]
+
+#[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
+ //~| ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
+struct S0(i32);
+
+#[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two
+ //~| ERROR: invalid `repr(align)` attribute: not a power of two
+struct S1(i32);
+
+#[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29
+ //~| ERROR: invalid `repr(align)` attribute: larger than 2^29
+struct S2(i32);
+
+#[repr(align(536870912))] // ok: this is the largest accepted alignment
+struct S3(i32);
+
+#[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
+ //~| ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
+enum E0 { A, B }
+
+#[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two
+ //~| ERROR: invalid `repr(align)` attribute: not a power of two
+enum E1 { A, B }
+
+#[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29
+ //~| ERROR: invalid `repr(align)` attribute: larger than 2^29
+enum E2 { A, B }
+
+#[repr(align(536870912))] // ok: this is the largest accepted alignment
+enum E3 { A, B }
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-align.stderr b/src/test/ui/repr/repr-align.stderr
new file mode 100644
index 000000000..900a811bb
--- /dev/null
+++ b/src/test/ui/repr/repr-align.stderr
@@ -0,0 +1,75 @@
+error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
+ --> $DIR/repr-align.rs:3:8
+ |
+LL | #[repr(align(16.0))]
+ | ^^^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: not a power of two
+ --> $DIR/repr-align.rs:7:8
+ |
+LL | #[repr(align(15))]
+ | ^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: larger than 2^29
+ --> $DIR/repr-align.rs:11:8
+ |
+LL | #[repr(align(4294967296))]
+ | ^^^^^^^^^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
+ --> $DIR/repr-align.rs:18:8
+ |
+LL | #[repr(align(16.0))]
+ | ^^^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: not a power of two
+ --> $DIR/repr-align.rs:22:8
+ |
+LL | #[repr(align(15))]
+ | ^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: larger than 2^29
+ --> $DIR/repr-align.rs:26:8
+ |
+LL | #[repr(align(4294967296))]
+ | ^^^^^^^^^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
+ --> $DIR/repr-align.rs:3:8
+ |
+LL | #[repr(align(16.0))]
+ | ^^^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: not a power of two
+ --> $DIR/repr-align.rs:7:8
+ |
+LL | #[repr(align(15))]
+ | ^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: larger than 2^29
+ --> $DIR/repr-align.rs:11:8
+ |
+LL | #[repr(align(4294967296))]
+ | ^^^^^^^^^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer
+ --> $DIR/repr-align.rs:18:8
+ |
+LL | #[repr(align(16.0))]
+ | ^^^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: not a power of two
+ --> $DIR/repr-align.rs:22:8
+ |
+LL | #[repr(align(15))]
+ | ^^^^^^^^^
+
+error[E0589]: invalid `repr(align)` attribute: larger than 2^29
+ --> $DIR/repr-align.rs:26:8
+ |
+LL | #[repr(align(4294967296))]
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 12 previous errors
+
+For more information about this error, try `rustc --explain E0589`.
diff --git a/src/test/ui/repr/repr-disallow-on-variant.rs b/src/test/ui/repr/repr-disallow-on-variant.rs
new file mode 100644
index 000000000..d9bd0b0e3
--- /dev/null
+++ b/src/test/ui/repr/repr-disallow-on-variant.rs
@@ -0,0 +1,9 @@
+struct Test;
+
+enum Foo {
+ #[repr(u8)]
+ //~^ ERROR attribute should be applied to an enum
+ Variant,
+}
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-disallow-on-variant.stderr b/src/test/ui/repr/repr-disallow-on-variant.stderr
new file mode 100644
index 000000000..f7e4dcc9d
--- /dev/null
+++ b/src/test/ui/repr/repr-disallow-on-variant.stderr
@@ -0,0 +1,12 @@
+error[E0517]: attribute should be applied to an enum
+ --> $DIR/repr-disallow-on-variant.rs:4:12
+ |
+LL | #[repr(u8)]
+ | ^^
+LL |
+LL | Variant,
+ | ------- not an enum
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0517`.
diff --git a/src/test/ui/repr/repr-packed-contains-align.rs b/src/test/ui/repr/repr-packed-contains-align.rs
new file mode 100644
index 000000000..bef5c7d8c
--- /dev/null
+++ b/src/test/ui/repr/repr-packed-contains-align.rs
@@ -0,0 +1,53 @@
+#![allow(dead_code)]
+
+#[repr(align(16))]
+#[derive(Clone, Copy)]
+struct SA(i32);
+
+#[derive(Clone, Copy)]
+struct SB(SA);
+
+#[repr(align(16))]
+#[derive(Clone, Copy)]
+union UA {
+ i: i32
+}
+
+#[derive(Clone, Copy)]
+union UB {
+ a: UA
+}
+
+#[repr(packed)]
+struct SC(SA); //~ ERROR: packed type cannot transitively contain a `#[repr(align)]` type
+
+#[repr(packed)]
+struct SD(SB); //~ ERROR: packed type cannot transitively contain a `#[repr(align)]` type
+
+#[repr(packed)]
+struct SE(UA); //~ ERROR: packed type cannot transitively contain a `#[repr(align)]` type
+
+#[repr(packed)]
+struct SF(UB); //~ ERROR: packed type cannot transitively contain a `#[repr(align)]` type
+
+#[repr(packed)]
+union UC { //~ ERROR: packed type cannot transitively contain a `#[repr(align)]` type
+ a: UA
+}
+
+#[repr(packed)]
+union UD { //~ ERROR: packed type cannot transitively contain a `#[repr(align)]` type
+ n: UB
+}
+
+#[repr(packed)]
+union UE { //~ ERROR: packed type cannot transitively contain a `#[repr(align)]` type
+ a: SA
+}
+
+#[repr(packed)]
+union UF { //~ ERROR: packed type cannot transitively contain a `#[repr(align)]` type
+ n: SB
+}
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-packed-contains-align.stderr b/src/test/ui/repr/repr-packed-contains-align.stderr
new file mode 100644
index 000000000..4c3a960ca
--- /dev/null
+++ b/src/test/ui/repr/repr-packed-contains-align.stderr
@@ -0,0 +1,139 @@
+error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
+ --> $DIR/repr-packed-contains-align.rs:22:1
+ |
+LL | struct SC(SA);
+ | ^^^^^^^^^
+ |
+note: `SA` has a `#[repr(align)]` attribute
+ --> $DIR/repr-packed-contains-align.rs:5:1
+ |
+LL | struct SA(i32);
+ | ^^^^^^^^^
+
+error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
+ --> $DIR/repr-packed-contains-align.rs:25:1
+ |
+LL | struct SD(SB);
+ | ^^^^^^^^^
+ |
+note: `SA` has a `#[repr(align)]` attribute
+ --> $DIR/repr-packed-contains-align.rs:5:1
+ |
+LL | struct SA(i32);
+ | ^^^^^^^^^
+note: `SD` contains a field of type `SB`
+ --> $DIR/repr-packed-contains-align.rs:25:11
+ |
+LL | struct SD(SB);
+ | ^^
+note: ...which contains a field of type `SA`
+ --> $DIR/repr-packed-contains-align.rs:8:11
+ |
+LL | struct SB(SA);
+ | ^^
+
+error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
+ --> $DIR/repr-packed-contains-align.rs:28:1
+ |
+LL | struct SE(UA);
+ | ^^^^^^^^^
+ |
+note: `UA` has a `#[repr(align)]` attribute
+ --> $DIR/repr-packed-contains-align.rs:12:1
+ |
+LL | union UA {
+ | ^^^^^^^^
+
+error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
+ --> $DIR/repr-packed-contains-align.rs:31:1
+ |
+LL | struct SF(UB);
+ | ^^^^^^^^^
+ |
+note: `UA` has a `#[repr(align)]` attribute
+ --> $DIR/repr-packed-contains-align.rs:12:1
+ |
+LL | union UA {
+ | ^^^^^^^^
+note: `SF` contains a field of type `UB`
+ --> $DIR/repr-packed-contains-align.rs:31:11
+ |
+LL | struct SF(UB);
+ | ^^
+note: ...which contains a field of type `UA`
+ --> $DIR/repr-packed-contains-align.rs:18:5
+ |
+LL | a: UA
+ | ^
+
+error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
+ --> $DIR/repr-packed-contains-align.rs:34:1
+ |
+LL | union UC {
+ | ^^^^^^^^
+ |
+note: `UA` has a `#[repr(align)]` attribute
+ --> $DIR/repr-packed-contains-align.rs:12:1
+ |
+LL | union UA {
+ | ^^^^^^^^
+
+error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
+ --> $DIR/repr-packed-contains-align.rs:39:1
+ |
+LL | union UD {
+ | ^^^^^^^^
+ |
+note: `UA` has a `#[repr(align)]` attribute
+ --> $DIR/repr-packed-contains-align.rs:12:1
+ |
+LL | union UA {
+ | ^^^^^^^^
+note: `UD` contains a field of type `UB`
+ --> $DIR/repr-packed-contains-align.rs:40:5
+ |
+LL | n: UB
+ | ^
+note: ...which contains a field of type `UA`
+ --> $DIR/repr-packed-contains-align.rs:18:5
+ |
+LL | a: UA
+ | ^
+
+error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
+ --> $DIR/repr-packed-contains-align.rs:44:1
+ |
+LL | union UE {
+ | ^^^^^^^^
+ |
+note: `SA` has a `#[repr(align)]` attribute
+ --> $DIR/repr-packed-contains-align.rs:5:1
+ |
+LL | struct SA(i32);
+ | ^^^^^^^^^
+
+error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
+ --> $DIR/repr-packed-contains-align.rs:49:1
+ |
+LL | union UF {
+ | ^^^^^^^^
+ |
+note: `SA` has a `#[repr(align)]` attribute
+ --> $DIR/repr-packed-contains-align.rs:5:1
+ |
+LL | struct SA(i32);
+ | ^^^^^^^^^
+note: `UF` contains a field of type `SB`
+ --> $DIR/repr-packed-contains-align.rs:50:5
+ |
+LL | n: SB
+ | ^
+note: ...which contains a field of type `SA`
+ --> $DIR/repr-packed-contains-align.rs:8:11
+ |
+LL | struct SB(SA);
+ | ^^
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0588`.
diff --git a/src/test/ui/repr/repr-transparent-issue-87496.rs b/src/test/ui/repr/repr-transparent-issue-87496.rs
new file mode 100644
index 000000000..a4dd45c63
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-issue-87496.rs
@@ -0,0 +1,12 @@
+// Regression test for the ICE described in #87496.
+
+// check-pass
+
+#[repr(transparent)]
+struct TransparentCustomZst(());
+extern "C" {
+ fn good17(p: TransparentCustomZst);
+ //~^ WARNING: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
+}
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-transparent-issue-87496.stderr b/src/test/ui/repr/repr-transparent-issue-87496.stderr
new file mode 100644
index 000000000..3dc13b1c1
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-issue-87496.stderr
@@ -0,0 +1,16 @@
+warning: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
+ --> $DIR/repr-transparent-issue-87496.rs:8:18
+ |
+LL | fn good17(p: TransparentCustomZst);
+ | ^^^^^^^^^^^^^^^^^^^^ not FFI-safe
+ |
+ = note: `#[warn(improper_ctypes)]` on by default
+ = note: this struct contains only zero-sized fields
+note: the type is defined here
+ --> $DIR/repr-transparent-issue-87496.rs:6:1
+ |
+LL | struct TransparentCustomZst(());
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/repr/repr-transparent-non-exhaustive.rs b/src/test/ui/repr/repr-transparent-non-exhaustive.rs
new file mode 100644
index 000000000..9ccd8610d
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-non-exhaustive.rs
@@ -0,0 +1,96 @@
+#![deny(repr_transparent_external_private_fields)]
+
+// aux-build: repr-transparent-non-exhaustive.rs
+extern crate repr_transparent_non_exhaustive;
+
+use repr_transparent_non_exhaustive::{
+ Private,
+ NonExhaustive,
+ NonExhaustiveEnum,
+ NonExhaustiveVariant,
+ ExternalIndirection,
+};
+
+pub struct InternalPrivate {
+ _priv: (),
+}
+
+#[non_exhaustive]
+pub struct InternalNonExhaustive;
+
+pub struct InternalIndirection<T> {
+ x: T,
+}
+
+pub type Sized = i32;
+
+#[repr(transparent)]
+pub struct T1(Sized, InternalPrivate);
+#[repr(transparent)]
+pub struct T2(Sized, InternalNonExhaustive);
+#[repr(transparent)]
+pub struct T3(Sized, InternalIndirection<(InternalPrivate, InternalNonExhaustive)>);
+#[repr(transparent)]
+pub struct T4(Sized, ExternalIndirection<(InternalPrivate, InternalNonExhaustive)>);
+
+#[repr(transparent)]
+pub struct T5(Sized, Private);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T6(Sized, NonExhaustive);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T7(Sized, NonExhaustiveEnum);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T8(Sized, NonExhaustiveVariant);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T9(Sized, InternalIndirection<Private>);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T10(Sized, InternalIndirection<NonExhaustive>);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T11(Sized, InternalIndirection<NonExhaustiveEnum>);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T12(Sized, InternalIndirection<NonExhaustiveVariant>);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T13(Sized, ExternalIndirection<Private>);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T14(Sized, ExternalIndirection<NonExhaustive>);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T15(Sized, ExternalIndirection<NonExhaustiveEnum>);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+#[repr(transparent)]
+pub struct T16(Sized, ExternalIndirection<NonExhaustiveVariant>);
+//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+//~| WARN this was previously accepted by the compiler
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-transparent-non-exhaustive.stderr b/src/test/ui/repr/repr-transparent-non-exhaustive.stderr
new file mode 100644
index 000000000..3b1e334a0
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-non-exhaustive.stderr
@@ -0,0 +1,127 @@
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:37:22
+ |
+LL | pub struct T5(Sized, Private);
+ | ^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/repr-transparent-non-exhaustive.rs:1:9
+ |
+LL | #![deny(repr_transparent_external_private_fields)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this struct contains `Private`, which contains private fields, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:42:22
+ |
+LL | pub struct T6(Sized, NonExhaustive);
+ | ^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this struct contains `NonExhaustive`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:47:22
+ |
+LL | pub struct T7(Sized, NonExhaustiveEnum);
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this enum contains `NonExhaustiveEnum`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:52:22
+ |
+LL | pub struct T8(Sized, NonExhaustiveVariant);
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this enum contains `NonExhaustiveVariant`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:57:22
+ |
+LL | pub struct T9(Sized, InternalIndirection<Private>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this struct contains `Private`, which contains private fields, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:62:23
+ |
+LL | pub struct T10(Sized, InternalIndirection<NonExhaustive>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this struct contains `NonExhaustive`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:67:23
+ |
+LL | pub struct T11(Sized, InternalIndirection<NonExhaustiveEnum>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this enum contains `NonExhaustiveEnum`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:72:23
+ |
+LL | pub struct T12(Sized, InternalIndirection<NonExhaustiveVariant>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this enum contains `NonExhaustiveVariant`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:77:23
+ |
+LL | pub struct T13(Sized, ExternalIndirection<Private>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this struct contains `Private`, which contains private fields, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:82:23
+ |
+LL | pub struct T14(Sized, ExternalIndirection<NonExhaustive>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this struct contains `NonExhaustive`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:87:23
+ |
+LL | pub struct T15(Sized, ExternalIndirection<NonExhaustiveEnum>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this enum contains `NonExhaustiveEnum`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
+ --> $DIR/repr-transparent-non-exhaustive.rs:92:23
+ |
+LL | pub struct T16(Sized, ExternalIndirection<NonExhaustiveVariant>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
+ = note: this enum contains `NonExhaustiveVariant`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
+
+error: aborting due to 12 previous errors
+
diff --git a/src/test/ui/repr/repr-transparent-other-items.rs b/src/test/ui/repr/repr-transparent-other-items.rs
new file mode 100644
index 000000000..e537e3e1a
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-other-items.rs
@@ -0,0 +1,9 @@
+// See also repr-transparent.rs
+
+#[repr(transparent)] //~ ERROR should be applied to a struct
+fn cant_repr_this() {}
+
+#[repr(transparent)] //~ ERROR should be applied to a struct
+static CANT_REPR_THIS: u32 = 0;
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-transparent-other-items.stderr b/src/test/ui/repr/repr-transparent-other-items.stderr
new file mode 100644
index 000000000..14e6f13e1
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-other-items.stderr
@@ -0,0 +1,19 @@
+error[E0517]: attribute should be applied to a struct, enum, or union
+ --> $DIR/repr-transparent-other-items.rs:3:8
+ |
+LL | #[repr(transparent)]
+ | ^^^^^^^^^^^
+LL | fn cant_repr_this() {}
+ | ---------------------- not a struct, enum, or union
+
+error[E0517]: attribute should be applied to a struct, enum, or union
+ --> $DIR/repr-transparent-other-items.rs:6:8
+ |
+LL | #[repr(transparent)]
+ | ^^^^^^^^^^^
+LL | static CANT_REPR_THIS: u32 = 0;
+ | ------------------------------- not a struct, enum, or union
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0517`.
diff --git a/src/test/ui/repr/repr-transparent-other-reprs.rs b/src/test/ui/repr/repr-transparent-other-reprs.rs
new file mode 100644
index 000000000..0cd0edf32
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-other-reprs.rs
@@ -0,0 +1,18 @@
+// See also repr-transparent.rs
+
+#[repr(transparent, C)] //~ ERROR cannot have other repr
+struct TransparentPlusC {
+ ptr: *const u8
+}
+
+#[repr(transparent, packed)] //~ ERROR cannot have other repr
+struct TransparentPlusPacked(*const u8);
+
+#[repr(transparent, align(2))] //~ ERROR cannot have other repr
+struct TransparentPlusAlign(u8);
+
+#[repr(transparent)] //~ ERROR cannot have other repr
+#[repr(C)]
+struct SeparateAttributes(*mut u8);
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-transparent-other-reprs.stderr b/src/test/ui/repr/repr-transparent-other-reprs.stderr
new file mode 100644
index 000000000..d92c35811
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent-other-reprs.stderr
@@ -0,0 +1,29 @@
+error[E0692]: transparent struct cannot have other repr hints
+ --> $DIR/repr-transparent-other-reprs.rs:3:8
+ |
+LL | #[repr(transparent, C)]
+ | ^^^^^^^^^^^ ^
+
+error[E0692]: transparent struct cannot have other repr hints
+ --> $DIR/repr-transparent-other-reprs.rs:8:8
+ |
+LL | #[repr(transparent, packed)]
+ | ^^^^^^^^^^^ ^^^^^^
+
+error[E0692]: transparent struct cannot have other repr hints
+ --> $DIR/repr-transparent-other-reprs.rs:11:8
+ |
+LL | #[repr(transparent, align(2))]
+ | ^^^^^^^^^^^ ^^^^^^^^
+
+error[E0692]: transparent struct cannot have other repr hints
+ --> $DIR/repr-transparent-other-reprs.rs:14:8
+ |
+LL | #[repr(transparent)]
+ | ^^^^^^^^^^^
+LL | #[repr(C)]
+ | ^
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0692`.
diff --git a/src/test/ui/repr/repr-transparent.rs b/src/test/ui/repr/repr-transparent.rs
new file mode 100644
index 000000000..8c9d1639c
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent.rs
@@ -0,0 +1,90 @@
+// This file tests repr(transparent)-related errors reported during typeck. Other errors
+// that are reported earlier and therefore preempt these are tested in:
+// - repr-transparent-other-reprs.rs
+// - repr-transparent-other-items.rs
+
+#![feature(transparent_unions)]
+
+use std::marker::PhantomData;
+
+#[repr(transparent)]
+struct NoFields;
+
+#[repr(transparent)]
+struct ContainsOnlyZst(());
+
+#[repr(transparent)]
+struct ContainsOnlyZstArray([bool; 0]);
+
+#[repr(transparent)]
+struct ContainsMultipleZst(PhantomData<*const i32>, NoFields);
+
+#[repr(transparent)]
+struct ContainsZstAndNonZst((), [i32; 2]);
+
+#[repr(transparent)]
+struct MultipleNonZst(u8, u8); //~ ERROR needs at most one non-zero-sized field
+
+trait Mirror { type It: ?Sized; }
+impl<T: ?Sized> Mirror for T { type It = Self; }
+
+#[repr(transparent)]
+pub struct StructWithProjection(f32, <f32 as Mirror>::It);
+//~^ ERROR needs at most one non-zero-sized field
+
+#[repr(transparent)]
+struct NontrivialAlignZst(u32, [u16; 0]); //~ ERROR alignment larger than 1
+
+#[repr(align(32))]
+struct ZstAlign32<T>(PhantomData<T>);
+
+#[repr(transparent)]
+struct GenericAlign<T>(ZstAlign32<T>, u32); //~ ERROR alignment larger than 1
+
+#[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum
+enum Void {} //~ ERROR transparent enum needs exactly one variant, but has 0
+
+#[repr(transparent)]
+enum FieldlessEnum {
+ Foo,
+}
+
+#[repr(transparent)]
+enum UnitFieldEnum {
+ Foo(()),
+}
+
+#[repr(transparent)]
+enum TooManyFieldsEnum {
+ Foo(u32, String),
+}
+//~^^^ ERROR transparent enum needs at most one non-zero-sized field, but has 2
+
+#[repr(transparent)]
+enum MultipleVariants { //~ ERROR transparent enum needs exactly one variant, but has 2
+ Foo(String),
+ Bar,
+}
+
+#[repr(transparent)]
+enum NontrivialAlignZstEnum {
+ Foo(u32, [u16; 0]), //~ ERROR alignment larger than 1
+}
+
+#[repr(transparent)]
+enum GenericAlignEnum<T> {
+ Foo { bar: ZstAlign32<T>, baz: u32 } //~ ERROR alignment larger than 1
+}
+
+#[repr(transparent)]
+union UnitUnion {
+ u: (),
+}
+
+#[repr(transparent)]
+union TooManyFields { //~ ERROR transparent union needs at most one non-zero-sized field, but has 2
+ u: u32,
+ s: i32
+}
+
+fn main() {}
diff --git a/src/test/ui/repr/repr-transparent.stderr b/src/test/ui/repr/repr-transparent.stderr
new file mode 100644
index 000000000..f1c570b95
--- /dev/null
+++ b/src/test/ui/repr/repr-transparent.stderr
@@ -0,0 +1,90 @@
+error[E0690]: transparent struct needs at most one non-zero-sized field, but has 2
+ --> $DIR/repr-transparent.rs:26:1
+ |
+LL | struct MultipleNonZst(u8, u8);
+ | ^^^^^^^^^^^^^^^^^^^^^ -- -- this field is non-zero-sized
+ | | |
+ | | this field is non-zero-sized
+ | needs at most one non-zero-sized field, but has 2
+
+error[E0690]: transparent struct needs at most one non-zero-sized field, but has 2
+ --> $DIR/repr-transparent.rs:32:1
+ |
+LL | pub struct StructWithProjection(f32, <f32 as Mirror>::It);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- ------------------- this field is non-zero-sized
+ | | |
+ | | this field is non-zero-sized
+ | needs at most one non-zero-sized field, but has 2
+
+error[E0691]: zero-sized field in transparent struct has alignment larger than 1
+ --> $DIR/repr-transparent.rs:36:32
+ |
+LL | struct NontrivialAlignZst(u32, [u16; 0]);
+ | ^^^^^^^^ has alignment larger than 1
+
+error[E0691]: zero-sized field in transparent struct has alignment larger than 1
+ --> $DIR/repr-transparent.rs:42:24
+ |
+LL | struct GenericAlign<T>(ZstAlign32<T>, u32);
+ | ^^^^^^^^^^^^^ has alignment larger than 1
+
+error[E0084]: unsupported representation for zero-variant enum
+ --> $DIR/repr-transparent.rs:44:1
+ |
+LL | #[repr(transparent)]
+ | ^^^^^^^^^^^^^^^^^^^^
+LL | enum Void {}
+ | --------- zero-variant enum
+
+error[E0731]: transparent enum needs exactly one variant, but has 0
+ --> $DIR/repr-transparent.rs:45:1
+ |
+LL | enum Void {}
+ | ^^^^^^^^^ needs exactly one variant, but has 0
+
+error[E0690]: the variant of a transparent enum needs at most one non-zero-sized field, but has 2
+ --> $DIR/repr-transparent.rs:58:1
+ |
+LL | enum TooManyFieldsEnum {
+ | ^^^^^^^^^^^^^^^^^^^^^^ needs at most one non-zero-sized field, but has 2
+LL | Foo(u32, String),
+ | --- ------ this field is non-zero-sized
+ | |
+ | this field is non-zero-sized
+
+error[E0731]: transparent enum needs exactly one variant, but has 2
+ --> $DIR/repr-transparent.rs:64:1
+ |
+LL | enum MultipleVariants {
+ | ^^^^^^^^^^^^^^^^^^^^^ needs exactly one variant, but has 2
+LL | Foo(String),
+ | ---
+LL | Bar,
+ | --- too many variants in `MultipleVariants`
+
+error[E0691]: zero-sized field in transparent enum has alignment larger than 1
+ --> $DIR/repr-transparent.rs:71:14
+ |
+LL | Foo(u32, [u16; 0]),
+ | ^^^^^^^^ has alignment larger than 1
+
+error[E0691]: zero-sized field in transparent enum has alignment larger than 1
+ --> $DIR/repr-transparent.rs:76:11
+ |
+LL | Foo { bar: ZstAlign32<T>, baz: u32 }
+ | ^^^^^^^^^^^^^^^^^^ has alignment larger than 1
+
+error[E0690]: transparent union needs at most one non-zero-sized field, but has 2
+ --> $DIR/repr-transparent.rs:85:1
+ |
+LL | union TooManyFields {
+ | ^^^^^^^^^^^^^^^^^^^ needs at most one non-zero-sized field, but has 2
+LL | u: u32,
+ | ------ this field is non-zero-sized
+LL | s: i32
+ | ------ this field is non-zero-sized
+
+error: aborting due to 11 previous errors
+
+Some errors have detailed explanations: E0084, E0690, E0691, E0731.
+For more information about an error, try `rustc --explain E0084`.
diff --git a/src/test/ui/repr/repr.rs b/src/test/ui/repr/repr.rs
new file mode 100644
index 000000000..564d67326
--- /dev/null
+++ b/src/test/ui/repr/repr.rs
@@ -0,0 +1,13 @@
+#[repr] //~ ERROR malformed `repr` attribute
+struct _A {}
+
+#[repr = "B"] //~ ERROR malformed `repr` attribute
+struct _B {}
+
+#[repr = "C"] //~ ERROR malformed `repr` attribute
+struct _C {}
+
+#[repr(C)]
+struct _D {}
+
+fn main() {}
diff --git a/src/test/ui/repr/repr.stderr b/src/test/ui/repr/repr.stderr
new file mode 100644
index 000000000..e0bec6663
--- /dev/null
+++ b/src/test/ui/repr/repr.stderr
@@ -0,0 +1,20 @@
+error: malformed `repr` attribute input
+ --> $DIR/repr.rs:1:1
+ |
+LL | #[repr]
+ | ^^^^^^^ help: must be of the form: `#[repr(C)]`
+
+error: malformed `repr` attribute input
+ --> $DIR/repr.rs:4:1
+ |
+LL | #[repr = "B"]
+ | ^^^^^^^^^^^^^ help: must be of the form: `#[repr(C)]`
+
+error: malformed `repr` attribute input
+ --> $DIR/repr.rs:7:1
+ |
+LL | #[repr = "C"]
+ | ^^^^^^^^^^^^^ help: must be of the form: `#[repr(C)]`
+
+error: aborting due to 3 previous errors
+