From 87b2796ee6670e4feacfb0a89f23eaa7b3dabb19 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 7 Nov 2025 13:59:44 +0100 Subject: [PATCH] Add test for unnecessary unsafe on proc macro attr Signed-off-by: Jonathan Brouwer --- tests/ui/attributes/proc-macro-unsafe.rs | 9 +++++++++ tests/ui/attributes/proc-macro-unsafe.stderr | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/ui/attributes/proc-macro-unsafe.rs create mode 100644 tests/ui/attributes/proc-macro-unsafe.stderr diff --git a/tests/ui/attributes/proc-macro-unsafe.rs b/tests/ui/attributes/proc-macro-unsafe.rs new file mode 100644 index 000000000000..7849df825609 --- /dev/null +++ b/tests/ui/attributes/proc-macro-unsafe.rs @@ -0,0 +1,9 @@ +//@ proc-macro: external-macro-use.rs + +extern crate external_macro_use; + +#[unsafe(external_macro_use::a)] +//~^ ERROR unnecessary `unsafe` on safe attribute +fn f() {} + +fn main() {} diff --git a/tests/ui/attributes/proc-macro-unsafe.stderr b/tests/ui/attributes/proc-macro-unsafe.stderr new file mode 100644 index 000000000000..ccc19bb01d2f --- /dev/null +++ b/tests/ui/attributes/proc-macro-unsafe.stderr @@ -0,0 +1,8 @@ +error: unnecessary `unsafe` on safe attribute + --> $DIR/proc-macro-unsafe.rs:5:3 + | +LL | #[unsafe(external_macro_use::a)] + | ^^^^^^ + +error: aborting due to 1 previous error +