Closed
Description
I tried this code to compile in Edition 2021:
#[no_mangle] // fine
static TEST_OUTSIDE: usize = 0;
thread_local! {
#[no_mangle] // unsafe attribute used without unsafe wrap error
static TEST: usize = 0;
}
However, compilation fails because the attribute must be wrapped in unsafe(...)
.
This breaks existing libraries like litequad, even though it wasn't upgraded to edition 2024.
Meta
[package]
name = "no_mangle_test"
version = "0.1.0"
edition = "2021"
error: unsafe attribute used without unsafe
--> src/main.rs:6:7
|
6 | #[no_mangle]
| ^^^^^^^^^ usage of unsafe attribute
|
help: wrap the attribute in `unsafe(...)`
|
6 | #[unsafe(no_mangle)]
| +++++++ +
error: could not compile `no_mangle_test` (bin "no_mangle_test") due to 1 previous error
Metadata
Metadata
Assignees
Labels
Area: Attributes (`#[…]`, `#![…]`)Area: The 2024 editionArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Category: This is a bug.High priorityRelevant to the edition team.Relevant to the library team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.