Lint against lowercase static mut

This commit is contained in:
Aleksey Kladov 2016-10-14 13:12:42 +03:00
parent 098d228459
commit 350b0d8946
3 changed files with 6 additions and 20 deletions

View File

@ -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);
}

View File

@ -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() { }

View File

@ -1,19 +0,0 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// pretty-expanded FIXME #23616
#![forbid(non_camel_case_types)]
#![forbid(non_upper_case_globals)]
static mut bar: isize = 2;
pub fn main() {}