Add a regression test for unsafe nonexistent attributes

This commit is contained in:
Jonathan Brouwer 2025-12-01 22:24:33 +01:00
parent 6e3a015400
commit 892bd18ad8
No known key found for this signature in database
GPG key ID: 13619B051B673C52
2 changed files with 26 additions and 0 deletions

View file

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

View file

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