diff options
| author | varkor <github@varkor.com> | 2018-04-10 22:30:23 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-04-10 22:30:23 +0100 |
| commit | 6e0089ea7776eea84fb26690b590074710247146 (patch) | |
| tree | 57292589496696e1b92d8079a7c595e01585e3ee | |
| parent | 4b9b70c394e7f341b4016fce4cbf763d404b26f9 (diff) | |
| download | rust-6e0089ea7776eea84fb26690b590074710247146.tar.gz rust-6e0089ea7776eea84fb26690b590074710247146.zip | |
Do not uppercase-lint no_mangle statics
| -rw-r--r-- | src/librustc_lint/bad_style.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/lint-non-uppercase-statics.rs | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index ad3760eed80..463ec4796e8 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -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(..) => { diff --git a/src/test/compile-fail/lint-non-uppercase-statics.rs b/src/test/compile-fail/lint-non-uppercase-statics.rs index 463a93612ca..84cc24a0010 100644 --- a/src/test/compile-fail/lint-non-uppercase-statics.rs +++ b/src/test/compile-fail/lint-non-uppercase-statics.rs @@ -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() { } |
