diff --git a/tests/ui/attributes/malformed-reprs.rs b/tests/ui/attributes/malformed-reprs.rs new file mode 100644 index 0000000000000..4f99239d21b50 --- /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 0000000000000..c39c98dde3198 --- /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(...) | | 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`.