diff --git a/tests/ui/many_single_char_names.rs b/tests/ui/many_single_char_names.rs new file mode 100644 index 000000000..d8ec63a6e --- /dev/null +++ b/tests/ui/many_single_char_names.rs @@ -0,0 +1,68 @@ +#[warn(clippy::many_single_char_names)] + +fn bla() { + let a: i32; + let (b, c, d): (i32, i64, i16); + { + { + let cdefg: i32; + let blar: i32; + } + { + let e: i32; + } + { + let e: i32; + let f: i32; + } + match 5 { + 1 => println!(), + e => panic!(), + } + match 5 { + 1 => println!(), + _ => panic!(), + } + } +} + +fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} + +fn bindings2() { + let (a, b, c, d, e, f, g, h) = unimplemented!(); +} + +fn shadowing() { + let a = 0i32; + let a = 0i32; + let a = 0i32; + let a = 0i32; + let a = 0i32; + let a = 0i32; + { + let a = 0i32; + } +} + +fn patterns() { + enum Z { + A(i32), + B(i32), + C(i32), + D(i32), + E(i32), + F(i32), + } + + // These should not trigger a warning, since the pattern bindings are a new scope. + match Z::A(0) { + Z::A(a) => {}, + Z::B(b) => {}, + Z::C(c) => {}, + Z::D(d) => {}, + Z::E(e) => {}, + Z::F(f) => {}, + } +} + +fn main() {} diff --git a/tests/ui/many_single_char_names.stderr b/tests/ui/many_single_char_names.stderr new file mode 100644 index 000000000..a746667ba --- /dev/null +++ b/tests/ui/many_single_char_names.stderr @@ -0,0 +1,51 @@ +error: 5 bindings with single-character names in scope + --> $DIR/many_single_char_names.rs:4:9 + | +LL | let a: i32; + | ^ +LL | let (b, c, d): (i32, i64, i16); + | ^ ^ ^ +... +LL | let e: i32; + | ^ + | + = note: `-D clippy::many-single-char-names` implied by `-D warnings` + +error: 6 bindings with single-character names in scope + --> $DIR/many_single_char_names.rs:4:9 + | +LL | let a: i32; + | ^ +LL | let (b, c, d): (i32, i64, i16); + | ^ ^ ^ +... +LL | let e: i32; + | ^ +LL | let f: i32; + | ^ + +error: 5 bindings with single-character names in scope + --> $DIR/many_single_char_names.rs:4:9 + | +LL | let a: i32; + | ^ +LL | let (b, c, d): (i32, i64, i16); + | ^ ^ ^ +... +LL | e => panic!(), + | ^ + +error: 8 bindings with single-character names in scope + --> $DIR/many_single_char_names.rs:29:13 + | +LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} + | ^ ^ ^ ^ ^ ^ ^ ^ + +error: 8 bindings with single-character names in scope + --> $DIR/many_single_char_names.rs:32:10 + | +LL | let (a, b, c, d, e, f, g, h) = unimplemented!(); + | ^ ^ ^ ^ ^ ^ ^ ^ + +error: aborting due to 5 previous errors + diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 301ff2761..58415b4ae 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -23,71 +23,6 @@ impl MaybeInst { } } -fn bla() { - let a: i32; - let (b, c, d): (i32, i64, i16); - { - { - let cdefg: i32; - let blar: i32; - } - { - let e: i32; - } - { - let e: i32; - let f: i32; - } - match 5 { - 1 => println!(""), - e => panic!(), - } - match 5 { - 1 => println!(""), - _ => panic!(), - } - } -} - -fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} - -fn bindings2() { - let (a, b, c, d, e, f, g, h) = unimplemented!(); -} - -fn shadowing() { - let a = 0i32; - let a = 0i32; - let a = 0i32; - let a = 0i32; - let a = 0i32; - let a = 0i32; - { - let a = 0i32; - } -} - -fn patterns() { - enum Z { - A(i32), - B(i32), - C(i32), - D(i32), - E(i32), - F(i32), - } - - // These should not trigger a warning, since the pattern bindings are a new scope. - match Z::A(0) { - Z::A(a) => {}, - Z::B(b) => {}, - Z::C(c) => {}, - Z::D(d) => {}, - Z::E(e) => {}, - Z::F(f) => {}, - } -} - fn underscores_and_numbers() { let _1 = 1; //~ERROR Consider a more descriptive name let ____1 = 1; //~ERROR Consider a more descriptive name diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index b848c0766..a0ca46f0e 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,54 +1,5 @@ -error: 5 bindings with single-character names in scope - --> $DIR/non_expressive_names.rs:27:9 - | -LL | let a: i32; - | ^ -LL | let (b, c, d): (i32, i64, i16); - | ^ ^ ^ -... -LL | let e: i32; - | ^ - | - = note: `-D clippy::many-single-char-names` implied by `-D warnings` - -error: 6 bindings with single-character names in scope - --> $DIR/non_expressive_names.rs:27:9 - | -LL | let a: i32; - | ^ -LL | let (b, c, d): (i32, i64, i16); - | ^ ^ ^ -... -LL | let e: i32; - | ^ -LL | let f: i32; - | ^ - -error: 5 bindings with single-character names in scope - --> $DIR/non_expressive_names.rs:27:9 - | -LL | let a: i32; - | ^ -LL | let (b, c, d): (i32, i64, i16); - | ^ ^ ^ -... -LL | e => panic!(), - | ^ - -error: 8 bindings with single-character names in scope - --> $DIR/non_expressive_names.rs:52:13 - | -LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} - | ^ ^ ^ ^ ^ ^ ^ ^ - -error: 8 bindings with single-character names in scope - --> $DIR/non_expressive_names.rs:55:10 - | -LL | let (a, b, c, d, e, f, g, h) = unimplemented!(); - | ^ ^ ^ ^ ^ ^ ^ ^ - error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:92:9 + --> $DIR/non_expressive_names.rs:27:9 | LL | let _1 = 1; //~ERROR Consider a more descriptive name | ^^ @@ -56,34 +7,34 @@ LL | let _1 = 1; //~ERROR Consider a more descriptive name = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:93:9 + --> $DIR/non_expressive_names.rs:28:9 | LL | let ____1 = 1; //~ERROR Consider a more descriptive name | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:94:9 + --> $DIR/non_expressive_names.rs:29:9 | LL | let __1___2 = 12; //~ERROR Consider a more descriptive name | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:114:13 + --> $DIR/non_expressive_names.rs:49:13 | LL | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:115:13 + --> $DIR/non_expressive_names.rs:50:13 | LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:116:13 + --> $DIR/non_expressive_names.rs:51:13 | LL | let __1___2 = 12; | ^^^^^^^ -error: aborting due to 11 previous errors +error: aborting due to 6 previous errors