I tried this code:
thread_local! {
#[unsafe(no_mangle)]
static FOO: () = const { () };
}
I expected to see this happen:
error: const items should never be `#[no_mangle]`
(The macro expands to a const item that has the #[unsafe(no_mangle)] applied to it.)
Instead, this happened:
It compiled successfully. The attribute is ignored
Meta
rustc --version --verbose:
rustc 1.91.0-nightly (02c7b1a7a 2025-09-13)
binary: rustc
commit-hash: 02c7b1a7ac1d739663878030510508372e46f254
commit-date: 2025-09-13
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.1
@rustbot label A-attributes A-macros T-compiler
Edit: see #146557 (comment) for root cause
I tried this code:
I expected to see this happen:
(The macro expands to a
constitem that has the#[unsafe(no_mangle)]applied to it.)Instead, this happened:
It compiled successfully. The attribute is ignored
Meta
rustc --version --verbose:@rustbot label A-attributes A-macros T-compiler
Edit: see #146557 (comment) for root cause