Skip to content

Commit 0629309

Browse files
committed
Rollup merge of rust-lang#49856 - varkor:no_mangle-statics-unlinted, r=michaelwoerister
Do not uppercase-lint #[no_mangle] statics The reasoning being that `#[no_mangle]` expresses enough intention that there's likely a good reason for the name. Fixes rust-lang#36258.
2 parents 4dbca4c + 6e0089e commit 0629309

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/librustc_lint/bad_style.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
368368
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
369369
match it.node {
370370
hir::ItemStatic(..) => {
371+
if attr::find_by_name(&it.attrs, "no_mangle").is_some() {
372+
return;
373+
}
371374
NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span);
372375
}
373376
hir::ItemConst(..) => {

src/test/compile-fail/lint-non-uppercase-statics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case
1616
static mut bar: isize = 1;
1717
//~^ ERROR static variable `bar` should have an upper case name such as `BAR`
1818

19+
#[no_mangle]
20+
pub static extern_foo: isize = 1; // OK, because #[no_mangle] supersedes the warning
21+
1922
fn main() { }

0 commit comments

Comments
 (0)