about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2016-10-14 13:12:42 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2016-10-14 14:47:16 +0300
commit350b0d89467d53a6febd9439beeed03d4a2e8c04 (patch)
treeac7217b3603bc29023d3c5f9f0e8a1fc0169f67d /src
parent098d22845933814a92497cbfaa8eb4a9a36b117f (diff)
downloadrust-350b0d89467d53a6febd9439beeed03d4a2e8c04.tar.gz
rust-350b0d89467d53a6febd9439beeed03d4a2e8c04.zip
Lint against lowercase static mut
Diffstat (limited to 'src')
-rw-r--r--src/librustc_lint/bad_style.rs4
-rw-r--r--src/test/compile-fail/lint-non-uppercase-statics.rs3
-rw-r--r--src/test/run-pass/lint-non-uppercase-statics-lowercase-mut-statics.rs19
3 files changed, 6 insertions, 20 deletions
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 <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() {}