Regression tests for repr ICEs

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
This commit is contained in:
Jonathan Brouwer 2025-07-06 22:06:46 +02:00
parent de031bbcb1
commit f7046bd32a
No known key found for this signature in database
GPG Key ID: 13619B051B673C52
2 changed files with 57 additions and 0 deletions

View File

@ -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() {}

View File

@ -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`.