about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-07 19:55:33 +0200
committerGitHub <noreply@github.com>2025-07-07 19:55:33 +0200
commit6c8482ee2cfed910fa5b2af7e73fa9a14a23293a (patch)
treebe2c7a19b43c83c6aa0de6c2a7ef6392a5f228f6
parent1b922d3901863fb68ba786bde0b8780e5eed9d56 (diff)
parentf7046bd32ab28aa95c652fdb3c5a8d197abf1f93 (diff)
downloadrust-6c8482ee2cfed910fa5b2af7e73fa9a14a23293a.tar.gz
rust-6c8482ee2cfed910fa5b2af7e73fa9a14a23293a.zip
Rollup merge of #143539 - JonathanBrouwer:ice-regression-tests, r=oli-obk
Regression tests for repr ICEs

Closes https://github.com/rust-lang/rust/issues/143522
Closes https://github.com/rust-lang/rust/issues/143479

Both issues were already (accidentally) fixed in this PR, but having the tests is nice https://github.com/rust-lang/rust/pull/143252

r? `@jdonszelmann`
-rw-r--r--tests/ui/attributes/malformed-reprs.rs14
-rw-r--r--tests/ui/attributes/malformed-reprs.stderr43
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/ui/attributes/malformed-reprs.rs b/tests/ui/attributes/malformed-reprs.rs
new file mode 100644
index 00000000000..4f99239d21b
--- /dev/null
+++ b/tests/ui/attributes/malformed-reprs.rs
@@ -0,0 +1,14 @@
+// Tests a few different invalid repr attributes
+
+// This is a regression test for https://github.com/rust-lang/rust/issues/143522
+#![repr]
+//~^ ERROR malformed `repr` attribute input [E0539]
+//~| ERROR `repr` attribute cannot be used at crate level
+
+// This is a regression test for https://github.com/rust-lang/rust/issues/143479
+#[repr(align(0))]
+//~^ ERROR invalid `repr(align)` attribute: not a power of two
+//~| ERROR unsupported representation for zero-variant enum [E0084]
+enum Foo {}
+
+fn main() {}
diff --git a/tests/ui/attributes/malformed-reprs.stderr b/tests/ui/attributes/malformed-reprs.stderr
new file mode 100644
index 00000000000..c39c98dde31
--- /dev/null
+++ b/tests/ui/attributes/malformed-reprs.stderr
@@ -0,0 +1,43 @@
+error[E0539]: malformed `repr` attribute input
+  --> $DIR/malformed-reprs.rs:4:1
+   |
+LL | #![repr]
+   | ^^^^^^^^
+   | |
+   | expected this to be a list
+   | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]`
+
+error[E0589]: invalid `repr(align)` attribute: not a power of two
+  --> $DIR/malformed-reprs.rs:9:14
+   |
+LL | #[repr(align(0))]
+   |              ^
+
+error: `repr` attribute cannot be used at crate level
+  --> $DIR/malformed-reprs.rs:4:1
+   |
+LL | #![repr]
+   | ^^^^^^^^
+...
+LL | enum Foo {}
+   |      --- the inner attribute doesn't annotate this enum
+   |
+help: perhaps you meant to use an outer attribute
+   |
+LL - #![repr]
+LL + #[repr]
+   |
+
+error[E0084]: unsupported representation for zero-variant enum
+  --> $DIR/malformed-reprs.rs:9:1
+   |
+LL | #[repr(align(0))]
+   | ^^^^^^^^^^^^^^^^^
+...
+LL | enum Foo {}
+   | -------- zero-variant enum
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0084, E0539, E0589.
+For more information about an error, try `rustc --explain E0084`.