Skip to content

Commit

Permalink
Rollup merge of rust-lang#49856 - varkor:no_mangle-statics-unlinted, …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
kennytm committed Apr 11, 2018
2 parents 4dbca4c + 6e0089e commit 0629309
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 0629309

Please sign in to comment.