summary refs log tree commit diff
path: root/tests/ui/attributes
diff options
context:
space:
mode:
authorJonathan Brouwer <jonathantbrouwer@gmail.com>2025-07-06 22:06:46 +0200
committerJonathan Brouwer <jonathantbrouwer@gmail.com>2025-07-06 22:07:09 +0200
commitf7046bd32ab28aa95c652fdb3c5a8d197abf1f93 (patch)
tree2f28ac7d691342782dfb700b7123a53e43759c2f /tests/ui/attributes
parentde031bbcb161b0b7fc0eb16f77b02ce9fbdf4c9e (diff)
downloadrust-f7046bd32ab28aa95c652fdb3c5a8d197abf1f93.tar.gz
rust-f7046bd32ab28aa95c652fdb3c5a8d197abf1f93.zip
Regression tests for repr ICEs
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Diffstat (limited to 'tests/ui/attributes')
-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`.