Closed
Description
I tried this code in Rust 2021 (playground):
#![deny(unsafe_attr_outside_unsafe)]
#[allow(unsafe_attr_outside_unsafe)]
mod generated {
#[no_mangle]
fn _generated_foo() {}
}
I expected to see this happen: compiles successfully
Instead, this happened:
error: unsafe attribute used without unsafe
--> src/lib.rs:5:7
|
5 | #[no_mangle]
| ^^^^^^^^^ usage of unsafe attribute
|
= warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-attributes.html>
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![deny(unsafe_attr_outside_unsafe)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: wrap the attribute in `unsafe(...)`
|
5 | #[unsafe(no_mangle)]
| +++++++ +
Meta
rustc --version --verbose
:
rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.85.0
LLVM version: 19.1.7
Reproduces in 1.88.0-nightly (2025-05-01 3350c1eb3fd8fe1bee1e)
on the Playground.
Metadata
Metadata
Assignees
Labels
Area: Lints (warnings about flaws in source code) such as unused_mut.Category: This is a bug.Diagnostics: An error or lint that should account for edition differences.Lint: unsafe_attr_outside_unsafeStatus: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.