Skip to content

Commit 2122bdb

Browse files
committed
Auto merge of #4087 - phansch:move_tests, r=matthiaskrgr
UI test cleanup: Extract many_single_char_names tests changelog: none cc #2038, #4086
2 parents e9b7a71 + 915ada0 commit 2122bdb

4 files changed

+126
-121
lines changed

tests/ui/many_single_char_names.rs

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#[warn(clippy::many_single_char_names)]
2+
3+
fn bla() {
4+
let a: i32;
5+
let (b, c, d): (i32, i64, i16);
6+
{
7+
{
8+
let cdefg: i32;
9+
let blar: i32;
10+
}
11+
{
12+
let e: i32;
13+
}
14+
{
15+
let e: i32;
16+
let f: i32;
17+
}
18+
match 5 {
19+
1 => println!(),
20+
e => panic!(),
21+
}
22+
match 5 {
23+
1 => println!(),
24+
_ => panic!(),
25+
}
26+
}
27+
}
28+
29+
fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {}
30+
31+
fn bindings2() {
32+
let (a, b, c, d, e, f, g, h) = unimplemented!();
33+
}
34+
35+
fn shadowing() {
36+
let a = 0i32;
37+
let a = 0i32;
38+
let a = 0i32;
39+
let a = 0i32;
40+
let a = 0i32;
41+
let a = 0i32;
42+
{
43+
let a = 0i32;
44+
}
45+
}
46+
47+
fn patterns() {
48+
enum Z {
49+
A(i32),
50+
B(i32),
51+
C(i32),
52+
D(i32),
53+
E(i32),
54+
F(i32),
55+
}
56+
57+
// These should not trigger a warning, since the pattern bindings are a new scope.
58+
match Z::A(0) {
59+
Z::A(a) => {},
60+
Z::B(b) => {},
61+
Z::C(c) => {},
62+
Z::D(d) => {},
63+
Z::E(e) => {},
64+
Z::F(f) => {},
65+
}
66+
}
67+
68+
fn main() {}
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
error: 5 bindings with single-character names in scope
2+
--> $DIR/many_single_char_names.rs:4:9
3+
|
4+
LL | let a: i32;
5+
| ^
6+
LL | let (b, c, d): (i32, i64, i16);
7+
| ^ ^ ^
8+
...
9+
LL | let e: i32;
10+
| ^
11+
|
12+
= note: `-D clippy::many-single-char-names` implied by `-D warnings`
13+
14+
error: 6 bindings with single-character names in scope
15+
--> $DIR/many_single_char_names.rs:4:9
16+
|
17+
LL | let a: i32;
18+
| ^
19+
LL | let (b, c, d): (i32, i64, i16);
20+
| ^ ^ ^
21+
...
22+
LL | let e: i32;
23+
| ^
24+
LL | let f: i32;
25+
| ^
26+
27+
error: 5 bindings with single-character names in scope
28+
--> $DIR/many_single_char_names.rs:4:9
29+
|
30+
LL | let a: i32;
31+
| ^
32+
LL | let (b, c, d): (i32, i64, i16);
33+
| ^ ^ ^
34+
...
35+
LL | e => panic!(),
36+
| ^
37+
38+
error: 8 bindings with single-character names in scope
39+
--> $DIR/many_single_char_names.rs:29:13
40+
|
41+
LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {}
42+
| ^ ^ ^ ^ ^ ^ ^ ^
43+
44+
error: 8 bindings with single-character names in scope
45+
--> $DIR/many_single_char_names.rs:32:10
46+
|
47+
LL | let (a, b, c, d, e, f, g, h) = unimplemented!();
48+
| ^ ^ ^ ^ ^ ^ ^ ^
49+
50+
error: aborting due to 5 previous errors
51+

tests/ui/non_expressive_names.rs

-65
Original file line numberDiff line numberDiff line change
@@ -23,71 +23,6 @@ impl MaybeInst {
2323
}
2424
}
2525

26-
fn bla() {
27-
let a: i32;
28-
let (b, c, d): (i32, i64, i16);
29-
{
30-
{
31-
let cdefg: i32;
32-
let blar: i32;
33-
}
34-
{
35-
let e: i32;
36-
}
37-
{
38-
let e: i32;
39-
let f: i32;
40-
}
41-
match 5 {
42-
1 => println!(""),
43-
e => panic!(),
44-
}
45-
match 5 {
46-
1 => println!(""),
47-
_ => panic!(),
48-
}
49-
}
50-
}
51-
52-
fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {}
53-
54-
fn bindings2() {
55-
let (a, b, c, d, e, f, g, h) = unimplemented!();
56-
}
57-
58-
fn shadowing() {
59-
let a = 0i32;
60-
let a = 0i32;
61-
let a = 0i32;
62-
let a = 0i32;
63-
let a = 0i32;
64-
let a = 0i32;
65-
{
66-
let a = 0i32;
67-
}
68-
}
69-
70-
fn patterns() {
71-
enum Z {
72-
A(i32),
73-
B(i32),
74-
C(i32),
75-
D(i32),
76-
E(i32),
77-
F(i32),
78-
}
79-
80-
// These should not trigger a warning, since the pattern bindings are a new scope.
81-
match Z::A(0) {
82-
Z::A(a) => {},
83-
Z::B(b) => {},
84-
Z::C(c) => {},
85-
Z::D(d) => {},
86-
Z::E(e) => {},
87-
Z::F(f) => {},
88-
}
89-
}
90-
9126
fn underscores_and_numbers() {
9227
let _1 = 1; //~ERROR Consider a more descriptive name
9328
let ____1 = 1; //~ERROR Consider a more descriptive name

tests/ui/non_expressive_names.stderr

+7-56
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,40 @@
1-
error: 5 bindings with single-character names in scope
2-
--> $DIR/non_expressive_names.rs:27:9
3-
|
4-
LL | let a: i32;
5-
| ^
6-
LL | let (b, c, d): (i32, i64, i16);
7-
| ^ ^ ^
8-
...
9-
LL | let e: i32;
10-
| ^
11-
|
12-
= note: `-D clippy::many-single-char-names` implied by `-D warnings`
13-
14-
error: 6 bindings with single-character names in scope
15-
--> $DIR/non_expressive_names.rs:27:9
16-
|
17-
LL | let a: i32;
18-
| ^
19-
LL | let (b, c, d): (i32, i64, i16);
20-
| ^ ^ ^
21-
...
22-
LL | let e: i32;
23-
| ^
24-
LL | let f: i32;
25-
| ^
26-
27-
error: 5 bindings with single-character names in scope
28-
--> $DIR/non_expressive_names.rs:27:9
29-
|
30-
LL | let a: i32;
31-
| ^
32-
LL | let (b, c, d): (i32, i64, i16);
33-
| ^ ^ ^
34-
...
35-
LL | e => panic!(),
36-
| ^
37-
38-
error: 8 bindings with single-character names in scope
39-
--> $DIR/non_expressive_names.rs:52:13
40-
|
41-
LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {}
42-
| ^ ^ ^ ^ ^ ^ ^ ^
43-
44-
error: 8 bindings with single-character names in scope
45-
--> $DIR/non_expressive_names.rs:55:10
46-
|
47-
LL | let (a, b, c, d, e, f, g, h) = unimplemented!();
48-
| ^ ^ ^ ^ ^ ^ ^ ^
49-
501
error: consider choosing a more descriptive name
51-
--> $DIR/non_expressive_names.rs:92:9
2+
--> $DIR/non_expressive_names.rs:27:9
523
|
534
LL | let _1 = 1; //~ERROR Consider a more descriptive name
545
| ^^
556
|
567
= note: `-D clippy::just-underscores-and-digits` implied by `-D warnings`
578

589
error: consider choosing a more descriptive name
59-
--> $DIR/non_expressive_names.rs:93:9
10+
--> $DIR/non_expressive_names.rs:28:9
6011
|
6112
LL | let ____1 = 1; //~ERROR Consider a more descriptive name
6213
| ^^^^^
6314

6415
error: consider choosing a more descriptive name
65-
--> $DIR/non_expressive_names.rs:94:9
16+
--> $DIR/non_expressive_names.rs:29:9
6617
|
6718
LL | let __1___2 = 12; //~ERROR Consider a more descriptive name
6819
| ^^^^^^^
6920

7021
error: consider choosing a more descriptive name
71-
--> $DIR/non_expressive_names.rs:114:13
22+
--> $DIR/non_expressive_names.rs:49:13
7223
|
7324
LL | let _1 = 1;
7425
| ^^
7526

7627
error: consider choosing a more descriptive name
77-
--> $DIR/non_expressive_names.rs:115:13
28+
--> $DIR/non_expressive_names.rs:50:13
7829
|
7930
LL | let ____1 = 1;
8031
| ^^^^^
8132

8233
error: consider choosing a more descriptive name
83-
--> $DIR/non_expressive_names.rs:116:13
34+
--> $DIR/non_expressive_names.rs:51:13
8435
|
8536
LL | let __1___2 = 12;
8637
| ^^^^^^^
8738

88-
error: aborting due to 11 previous errors
39+
error: aborting due to 6 previous errors
8940

0 commit comments

Comments
 (0)