Skip to content

Commit 6e0089e

Browse files
committed
Do not uppercase-lint no_mangle statics
1 parent 4b9b70c commit 6e0089e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/librustc_lint/bad_style.rs

+3
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

+3
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)