Incorrect no_mangle attribute warning #78989
Labels
A-attributes
Area: Attributes (`#[…]`, `#![…]`)
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
I tried this code:
I expected to see this happen: no warning.
Instead, this happened:
The attribute is actually applied correctly, otherwise we would get undefined symbol error.Also, the extern variable is clearly declared as static, so the warning does not really make sense.Edit: it seems that the code also works without the
no_mangle
attribute. So is theno_mangle
attribute actually not needed? Anyway, the warning aboutnot a function or static
is confusing.This problem occurred in our embedded project artiq-zynq, where the static global variables are used to provide references to linker symbols.
Version it worked on
It most recently worked on: Rust 1.47 stable. Haven't tried newer nightly.
Version with regression
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
The text was updated successfully, but these errors were encountered: