From f4e1ec111c016f1dbbedb2628a30e9ce20d8e5f1 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sat, 3 May 2025 15:19:08 +0200 Subject: Report the `unsafe_attr_outside_unsafe` lint at the closest node --- .../unsafe-attributes/unsafe-attributes-allow.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-allow.rs (limited to 'tests/ui') diff --git a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-allow.rs b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-allow.rs new file mode 100644 index 00000000000..76fdce7e5cf --- /dev/null +++ b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-allow.rs @@ -0,0 +1,16 @@ +//@ check-pass +//@ edition: 2021 +// +// Anti-regression test for https://github.com/rust-lang/rust/issues/140602 +// where the generated warning couldn't be allowed due too being attached to +// the wrong AST node. + +#![deny(unsafe_attr_outside_unsafe)] + +#[allow(unsafe_attr_outside_unsafe)] +mod generated { + #[no_mangle] + fn _generated_foo() {} +} + +fn main() {} -- cgit 1.4.1-3-g733a5