Make the naming lints only warn on names with upper/lowercase equivalents
Closes #21735.
This commit is contained in:
parent
c5961ad06d
commit
39a8c23c0b
6 changed files with 90 additions and 52 deletions
|
|
@ -11,7 +11,7 @@
|
|||
#[deny(warnings)]
|
||||
|
||||
const foo: isize = 3;
|
||||
//~^ ERROR: should have an uppercase name such as
|
||||
//~^ ERROR: should have an upper case name such as
|
||||
//~^^ ERROR: constant item is never used
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ mod test {
|
|||
mod bad {
|
||||
fn CamelCase() {} //~ ERROR function `CamelCase` should have a snake case name
|
||||
|
||||
static bad: isize = 1; //~ ERROR static constant `bad` should have an uppercase name
|
||||
static bad: isize = 1; //~ ERROR static constant `bad` should have an upper case name
|
||||
}
|
||||
|
||||
mod warn {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@
|
|||
#![forbid(non_upper_case_globals)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
static foo: isize = 1; //~ ERROR static constant `foo` should have an uppercase name such as `FOO`
|
||||
static foo: isize = 1; //~ ERROR static constant `foo` should have an upper case name such as `FOO`
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub const a : isize = 97;
|
|||
fn f() {
|
||||
let r = match (0,0) {
|
||||
(0, a) => 0,
|
||||
//~^ ERROR static constant in pattern `a` should have an uppercase name such as `A`
|
||||
//~^ ERROR constant in pattern `a` should have an upper case name such as `A`
|
||||
(x, y) => 1 + x + y,
|
||||
};
|
||||
assert!(r == 1);
|
||||
|
|
@ -34,7 +34,7 @@ fn g() {
|
|||
use self::m::aha;
|
||||
let r = match (0,0) {
|
||||
(0, aha) => 0,
|
||||
//~^ ERROR static constant in pattern `aha` should have an uppercase name such as `AHA`
|
||||
//~^ ERROR constant in pattern `aha` should have an upper case name such as `AHA`
|
||||
(x, y) => 1 + x + y,
|
||||
};
|
||||
assert!(r == 1);
|
||||
|
|
@ -48,7 +48,7 @@ fn h() {
|
|||
use self::n::OKAY as not_okay;
|
||||
let r = match (0,0) {
|
||||
(0, not_okay) => 0,
|
||||
//~^ ERROR static constant in pattern `not_okay` should have an uppercase name such as `NOT_OKAY`
|
||||
//~^ ERROR constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY`
|
||||
(x, y) => 1 + x + y,
|
||||
};
|
||||
assert!(r == 1);
|
||||
|
|
|
|||
17
src/test/run-pass/snake-case-no-lowercase-equivalent.rs
Normal file
17
src/test/run-pass/snake-case-no-lowercase-equivalent.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2014 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.
|
||||
|
||||
#![feature(non_ascii_idents)]
|
||||
#![deny(non_snake_case)]
|
||||
|
||||
// This name is neither upper nor lower case
|
||||
fn 你好() {}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue