Skip to content

Commit

Permalink
Auto merge of #4087 - phansch:move_tests, r=matthiaskrgr
Browse files Browse the repository at this point in the history
UI test cleanup: Extract many_single_char_names tests

changelog: none

cc #2038, #4086
  • Loading branch information
bors committed May 12, 2019
2 parents feb18c3 + e430b15 commit 84ee791
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 121 deletions.
69 changes: 69 additions & 0 deletions tests/ui/many_single_char_names.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#[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 changes: 51 additions & 0 deletions tests/ui/many_single_char_names.stderr
Original file line number Diff line number Diff line change
@@ -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:30: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:33:10
|
LL | let (a, b, c, d, e, f, g, h) = unimplemented!();
| ^ ^ ^ ^ ^ ^ ^ ^

error: aborting due to 5 previous errors

65 changes: 0 additions & 65 deletions tests/ui/non_expressive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 7 additions & 56 deletions tests/ui/non_expressive_names.stderr
Original file line number Diff line number Diff line change
@@ -1,89 +1,40 @@
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
| ^^
|
= 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

0 comments on commit 84ee791

Please sign in to comment.