From 350b0d89467d53a6febd9439beeed03d4a2e8c04 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 14 Oct 2016 13:12:42 +0300 Subject: [PATCH] Lint against lowercase static mut --- src/librustc_lint/bad_style.rs | 4 +++- .../lint-non-uppercase-statics.rs | 3 +++ ...uppercase-statics-lowercase-mut-statics.rs | 19 ------------------- 3 files changed, 6 insertions(+), 20 deletions(-) delete mode 100644 src/test/run-pass/lint-non-uppercase-statics-lowercase-mut-statics.rs diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index acb92bec7c7..d68d4c23b84 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -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); } diff --git a/src/test/compile-fail/lint-non-uppercase-statics.rs b/src/test/compile-fail/lint-non-uppercase-statics.rs index e1fbc73bbed..a9161a8b11b 100644 --- a/src/test/compile-fail/lint-non-uppercase-statics.rs +++ b/src/test/compile-fail/lint-non-uppercase-statics.rs @@ -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() { } diff --git a/src/test/run-pass/lint-non-uppercase-statics-lowercase-mut-statics.rs b/src/test/run-pass/lint-non-uppercase-statics-lowercase-mut-statics.rs deleted file mode 100644 index aa5b3834c01..00000000000 --- a/src/test/run-pass/lint-non-uppercase-statics-lowercase-mut-statics.rs +++ /dev/null @@ -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 or the MIT license -// , 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() {}