Skip to content

Commit

Permalink
Lint against lowercase static mut
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Oct 14, 2016
1 parent 098d228 commit 350b0d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/librustc_lint/bad_style.rs
Expand Up @@ -355,10 +355,12 @@ impl LintPass for NonUpperCaseGlobals {
impl LateLintPass for NonUpperCaseGlobals {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node {
// only check static constants
hir::ItemStatic(_, hir::MutImmutable, _) => {
NonUpperCaseGlobals::check_upper_case(cx, "static constant", it.name, it.span);
}
hir::ItemStatic(_, hir::MutMutable, _) => {
NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span);
}
hir::ItemConst(..) => {
NonUpperCaseGlobals::check_upper_case(cx, "constant", it.name, it.span);
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/compile-fail/lint-non-uppercase-statics.rs
Expand Up @@ -13,4 +13,7 @@

static foo: isize = 1; //~ ERROR static constant `foo` should have an upper case name such as `FOO`

static mut bar: isize = 1;
//~^ ERROR static variable `bar` should have an upper case name such as `BAR`

fn main() { }

This file was deleted.

0 comments on commit 350b0d8

Please sign in to comment.