diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-05-04 13:21:09 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-04 13:21:09 +1000 |
| commit | 54821b9ed09bcda8656d880b5f06a16ec69be52f (patch) | |
| tree | 21f0edc869424d8abc492bfa7003d032a10df927 /tests/ui | |
| parent | de30d1b17cce6bd1a18f8021b24404c567aea053 (diff) | |
| parent | f4e1ec111c016f1dbbedb2628a30e9ce20d8e5f1 (diff) | |
| download | rust-54821b9ed09bcda8656d880b5f06a16ec69be52f.tar.gz rust-54821b9ed09bcda8656d880b5f06a16ec69be52f.zip | |
Rollup merge of #140617 - Urgau:unsafe_attr-lint-allow, r=jieyouxu
Report the `unsafe_attr_outside_unsafe` lint at the closest node This PR have `AstValidation` track a linting node id and then uses it when reporting the `unsafe_attr_outside_unsafe` lint, so that instead of being bound at the crate-root, `#[allow]` of the lint works at any node. Fixes rust-lang/rust#140602 r? `@jieyouxu`
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-allow.rs | 16 |
1 files changed, 16 insertions, 0 deletions
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() {} |
