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`
This commit is contained in:
Stuart Cook 2025-05-04 13:21:09 +10:00 committed by GitHub
commit 54821b9ed0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 46 additions and 8 deletions

View file

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