Skip to content

Commit

Permalink
Do not uppercase-lint no_mangle statics
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Apr 10, 2018
1 parent 4b9b70c commit 6e0089e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustc_lint/bad_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node {
hir::ItemStatic(..) => {
if attr::find_by_name(&it.attrs, "no_mangle").is_some() {
return;
}
NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span);
}
hir::ItemConst(..) => {
Expand Down
3 changes: 3 additions & 0 deletions src/test/compile-fail/lint-non-uppercase-statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case
static mut bar: isize = 1;
//~^ ERROR static variable `bar` should have an upper case name such as `BAR`

#[no_mangle]
pub static extern_foo: isize = 1; // OK, because #[no_mangle] supersedes the warning

fn main() { }

0 comments on commit 6e0089e

Please sign in to comment.