Lint against lowercase static mut
This commit is contained in:
parent
098d228459
commit
350b0d8946
@ -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);
|
||||
}
|
||||
|
@ -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() { }
|
||||
|
@ -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() {}
|
Loading…
Reference in New Issue
Block a user