-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Incorrect no_mangle attribute warning #78989
Copy link
Copy link
Closed
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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_mangleattribute. So is theno_mangleattribute actually not needed? Anyway, the warning aboutnot a function or staticis 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