mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 07:04:18 +00:00
UI test cleanup: Extract many_single_char_names tests
This commit is contained in:
parent
3710ec5996
commit
915ada04f5
4 changed files with 126 additions and 121 deletions
68
tests/ui/many_single_char_names.rs
Normal file
68
tests/ui/many_single_char_names.rs
Normal file
|
@ -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() {}
|
51
tests/ui/many_single_char_names.stderr
Normal file
51
tests/ui/many_single_char_names.stderr
Normal file
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue