diff --git a/tests/ui/attributes/unsafe/unsafe-nonexistent-attribute.rs b/tests/ui/attributes/unsafe/unsafe-nonexistent-attribute.rs new file mode 100644 index 000000000000..c7d7b712925d --- /dev/null +++ b/tests/ui/attributes/unsafe/unsafe-nonexistent-attribute.rs @@ -0,0 +1,10 @@ +// This is a regression test for https://github.com/rust-lang/rust/issues/148453 +// We want the `cannot find attribute` error to appear before `is not an unsafe attribute` +//@ edition: 2024 + +#[unsafe(does_not_exist)] +//~^ ERROR cannot find attribute +//~| ERROR is not an unsafe attribute +fn aa() {} + +fn main() {} diff --git a/tests/ui/attributes/unsafe/unsafe-nonexistent-attribute.stderr b/tests/ui/attributes/unsafe/unsafe-nonexistent-attribute.stderr new file mode 100644 index 000000000000..42d9425ed31f --- /dev/null +++ b/tests/ui/attributes/unsafe/unsafe-nonexistent-attribute.stderr @@ -0,0 +1,16 @@ +error: cannot find attribute `does_not_exist` in this scope + --> $DIR/unsafe-nonexistent-attribute.rs:5:10 + | +LL | #[unsafe(does_not_exist)] + | ^^^^^^^^^^^^^^ + +error: `does_not_exist` is not an unsafe attribute + --> $DIR/unsafe-nonexistent-attribute.rs:5:3 + | +LL | #[unsafe(does_not_exist)] + | ^^^^^^ this is not an unsafe attribute + | + = note: extraneous unsafe is not allowed in attributes + +error: aborting due to 2 previous errors +