Skip to content

Commit bd23cb8

Browse files
committed
Auto merge of #3754 - phansch:uicleanup, r=oli-obk
UI test cleanup: Extract similar_names tests cc #2038
2 parents 2755d12 + 9dbabff commit bd23cb8

File tree

4 files changed

+223
-217
lines changed

4 files changed

+223
-217
lines changed

tests/ui/non_expressive_names.rs

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,6 @@
1-
#![warn(clippy::all, clippy::similar_names)]
1+
#![warn(clippy::all)]
22
#![allow(unused, clippy::println_empty_string)]
33

4-
struct Foo {
5-
apple: i32,
6-
bpple: i32,
7-
}
8-
9-
fn main() {
10-
let specter: i32;
11-
let spectre: i32;
12-
13-
let apple: i32;
14-
15-
let bpple: i32;
16-
17-
let cpple: i32;
18-
19-
let a_bar: i32;
20-
let b_bar: i32;
21-
let c_bar: i32;
22-
23-
let items = [5];
24-
for item in &items {
25-
loop {}
26-
}
27-
28-
let foo_x: i32;
29-
let foo_y: i32;
30-
31-
let rhs: i32;
32-
let lhs: i32;
33-
34-
let bla_rhs: i32;
35-
let bla_lhs: i32;
36-
37-
let blubrhs: i32;
38-
let blublhs: i32;
39-
40-
let blubx: i32;
41-
let bluby: i32;
42-
43-
let cake: i32;
44-
let cakes: i32;
45-
let coke: i32;
46-
47-
match 5 {
48-
cheese @ 1 => {},
49-
rabbit => panic!(),
50-
}
51-
let cheese: i32;
52-
match (42, 43) {
53-
(cheese1, 1) => {},
54-
(cheese2, 2) => panic!(),
55-
_ => println!(""),
56-
}
57-
let ipv4: i32;
58-
let ipv6: i32;
59-
let abcd1: i32;
60-
let abdc2: i32;
61-
let xyz1abc: i32;
62-
let xyz2abc: i32;
63-
let xyzeabc: i32;
64-
65-
let parser: i32;
66-
let parsed: i32;
67-
let parsee: i32;
68-
69-
let setter: i32;
70-
let getter: i32;
71-
let tx1: i32;
72-
let rx1: i32;
73-
let tx_cake: i32;
74-
let rx_cake: i32;
75-
}
76-
77-
fn foo() {
78-
let Foo { apple, bpple } = unimplemented!();
79-
let Foo {
80-
apple: spring,
81-
bpple: sprang,
82-
} = unimplemented!();
83-
}
84-
854
#[derive(Clone, Debug)]
865
enum MaybeInst {
876
Split,
@@ -160,22 +79,4 @@ impl Bar {
16079
}
16180
}
16281

163-
// false positive similar_names (#3057, #2651)
164-
// clippy claimed total_reg_src_size and total_size and
165-
// numb_reg_src_checkouts and total_bin_size were similar
166-
#[derive(Debug, Clone)]
167-
pub(crate) struct DirSizes {
168-
pub(crate) total_size: u64,
169-
pub(crate) numb_bins: u64,
170-
pub(crate) total_bin_size: u64,
171-
pub(crate) total_reg_size: u64,
172-
pub(crate) total_git_db_size: u64,
173-
pub(crate) total_git_repos_bare_size: u64,
174-
pub(crate) numb_git_repos_bare_repos: u64,
175-
pub(crate) numb_git_checkouts: u64,
176-
pub(crate) total_git_chk_size: u64,
177-
pub(crate) total_reg_cache_size: u64,
178-
pub(crate) total_reg_src_size: u64,
179-
pub(crate) numb_reg_cache_entries: u64,
180-
pub(crate) numb_reg_src_checkouts: u64,
181-
}
82+
fn main() {}

tests/ui/non_expressive_names.stderr

Lines changed: 11 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,66 @@
1-
error: binding's name is too similar to existing binding
2-
--> $DIR/non_expressive_names.rs:15:9
3-
|
4-
LL | let bpple: i32;
5-
| ^^^^^
6-
|
7-
= note: `-D clippy::similar-names` implied by `-D warnings`
8-
note: existing binding defined here
9-
--> $DIR/non_expressive_names.rs:13:9
10-
|
11-
LL | let apple: i32;
12-
| ^^^^^
13-
help: separate the discriminating character by an underscore like: `b_pple`
14-
--> $DIR/non_expressive_names.rs:15:9
15-
|
16-
LL | let bpple: i32;
17-
| ^^^^^
18-
19-
error: binding's name is too similar to existing binding
20-
--> $DIR/non_expressive_names.rs:17:9
21-
|
22-
LL | let cpple: i32;
23-
| ^^^^^
24-
|
25-
note: existing binding defined here
26-
--> $DIR/non_expressive_names.rs:13:9
27-
|
28-
LL | let apple: i32;
29-
| ^^^^^
30-
help: separate the discriminating character by an underscore like: `c_pple`
31-
--> $DIR/non_expressive_names.rs:17:9
32-
|
33-
LL | let cpple: i32;
34-
| ^^^^^
35-
36-
error: binding's name is too similar to existing binding
37-
--> $DIR/non_expressive_names.rs:41:9
38-
|
39-
LL | let bluby: i32;
40-
| ^^^^^
41-
|
42-
note: existing binding defined here
43-
--> $DIR/non_expressive_names.rs:40:9
44-
|
45-
LL | let blubx: i32;
46-
| ^^^^^
47-
help: separate the discriminating character by an underscore like: `blub_y`
48-
--> $DIR/non_expressive_names.rs:41:9
49-
|
50-
LL | let bluby: i32;
51-
| ^^^^^
52-
53-
error: binding's name is too similar to existing binding
54-
--> $DIR/non_expressive_names.rs:45:9
55-
|
56-
LL | let coke: i32;
57-
| ^^^^
58-
|
59-
note: existing binding defined here
60-
--> $DIR/non_expressive_names.rs:43:9
61-
|
62-
LL | let cake: i32;
63-
| ^^^^
64-
65-
error: binding's name is too similar to existing binding
66-
--> $DIR/non_expressive_names.rs:63:9
67-
|
68-
LL | let xyzeabc: i32;
69-
| ^^^^^^^
70-
|
71-
note: existing binding defined here
72-
--> $DIR/non_expressive_names.rs:61:9
73-
|
74-
LL | let xyz1abc: i32;
75-
| ^^^^^^^
76-
77-
error: binding's name is too similar to existing binding
78-
--> $DIR/non_expressive_names.rs:67:9
79-
|
80-
LL | let parsee: i32;
81-
| ^^^^^^
82-
|
83-
note: existing binding defined here
84-
--> $DIR/non_expressive_names.rs:65:9
85-
|
86-
LL | let parser: i32;
87-
| ^^^^^^
88-
help: separate the discriminating character by an underscore like: `parse_e`
89-
--> $DIR/non_expressive_names.rs:67:9
90-
|
91-
LL | let parsee: i32;
92-
| ^^^^^^
93-
94-
error: binding's name is too similar to existing binding
95-
--> $DIR/non_expressive_names.rs:81:16
96-
|
97-
LL | bpple: sprang,
98-
| ^^^^^^
99-
|
100-
note: existing binding defined here
101-
--> $DIR/non_expressive_names.rs:80:16
102-
|
103-
LL | apple: spring,
104-
| ^^^^^^
105-
1061
error: 5th binding whose name is just one char
107-
--> $DIR/non_expressive_names.rs:116:17
2+
--> $DIR/non_expressive_names.rs:35:17
1083
|
1094
LL | let e: i32;
1105
| ^
1116
|
1127
= note: `-D clippy::many-single-char-names` implied by `-D warnings`
1138

1149
error: 5th binding whose name is just one char
115-
--> $DIR/non_expressive_names.rs:119:17
10+
--> $DIR/non_expressive_names.rs:38:17
11611
|
11712
LL | let e: i32;
11813
| ^
11914

12015
error: 6th binding whose name is just one char
121-
--> $DIR/non_expressive_names.rs:120:17
16+
--> $DIR/non_expressive_names.rs:39:17
12217
|
12318
LL | let f: i32;
12419
| ^
12520

12621
error: 5th binding whose name is just one char
127-
--> $DIR/non_expressive_names.rs:124:13
22+
--> $DIR/non_expressive_names.rs:43:13
12823
|
12924
LL | e => panic!(),
13025
| ^
13126

13227
error: consider choosing a more descriptive name
133-
--> $DIR/non_expressive_names.rs:134:9
28+
--> $DIR/non_expressive_names.rs:53:9
13429
|
13530
LL | let _1 = 1; //~ERROR Consider a more descriptive name
13631
| ^^
13732
|
13833
= note: `-D clippy::just-underscores-and-digits` implied by `-D warnings`
13934

14035
error: consider choosing a more descriptive name
141-
--> $DIR/non_expressive_names.rs:135:9
36+
--> $DIR/non_expressive_names.rs:54:9
14237
|
14338
LL | let ____1 = 1; //~ERROR Consider a more descriptive name
14439
| ^^^^^
14540

14641
error: consider choosing a more descriptive name
147-
--> $DIR/non_expressive_names.rs:136:9
42+
--> $DIR/non_expressive_names.rs:55:9
14843
|
14944
LL | let __1___2 = 12; //~ERROR Consider a more descriptive name
15045
| ^^^^^^^
15146

15247
error: consider choosing a more descriptive name
153-
--> $DIR/non_expressive_names.rs:156:13
48+
--> $DIR/non_expressive_names.rs:75:13
15449
|
15550
LL | let _1 = 1;
15651
| ^^
15752

15853
error: consider choosing a more descriptive name
159-
--> $DIR/non_expressive_names.rs:157:13
54+
--> $DIR/non_expressive_names.rs:76:13
16055
|
16156
LL | let ____1 = 1;
16257
| ^^^^^
16358

16459
error: consider choosing a more descriptive name
165-
--> $DIR/non_expressive_names.rs:158:13
60+
--> $DIR/non_expressive_names.rs:77:13
16661
|
16762
LL | let __1___2 = 12;
16863
| ^^^^^^^
16964

170-
error: aborting due to 17 previous errors
65+
error: aborting due to 10 previous errors
17166

tests/ui/similar_names.rs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#![warn(clippy::similar_names)]
2+
#![allow(unused, clippy::println_empty_string)]
3+
4+
struct Foo {
5+
apple: i32,
6+
bpple: i32,
7+
}
8+
9+
fn main() {
10+
let specter: i32;
11+
let spectre: i32;
12+
13+
let apple: i32;
14+
15+
let bpple: i32;
16+
17+
let cpple: i32;
18+
19+
let a_bar: i32;
20+
let b_bar: i32;
21+
let c_bar: i32;
22+
23+
let items = [5];
24+
for item in &items {
25+
loop {}
26+
}
27+
28+
let foo_x: i32;
29+
let foo_y: i32;
30+
31+
let rhs: i32;
32+
let lhs: i32;
33+
34+
let bla_rhs: i32;
35+
let bla_lhs: i32;
36+
37+
let blubrhs: i32;
38+
let blublhs: i32;
39+
40+
let blubx: i32;
41+
let bluby: i32;
42+
43+
let cake: i32;
44+
let cakes: i32;
45+
let coke: i32;
46+
47+
match 5 {
48+
cheese @ 1 => {},
49+
rabbit => panic!(),
50+
}
51+
let cheese: i32;
52+
match (42, 43) {
53+
(cheese1, 1) => {},
54+
(cheese2, 2) => panic!(),
55+
_ => println!(""),
56+
}
57+
let ipv4: i32;
58+
let ipv6: i32;
59+
let abcd1: i32;
60+
let abdc2: i32;
61+
let xyz1abc: i32;
62+
let xyz2abc: i32;
63+
let xyzeabc: i32;
64+
65+
let parser: i32;
66+
let parsed: i32;
67+
let parsee: i32;
68+
69+
let setter: i32;
70+
let getter: i32;
71+
let tx1: i32;
72+
let rx1: i32;
73+
let tx_cake: i32;
74+
let rx_cake: i32;
75+
}
76+
77+
fn foo() {
78+
let Foo { apple, bpple } = unimplemented!();
79+
let Foo {
80+
apple: spring,
81+
bpple: sprang,
82+
} = unimplemented!();
83+
}
84+
85+
// false positive similar_names (#3057, #2651)
86+
// clippy claimed total_reg_src_size and total_size and
87+
// numb_reg_src_checkouts and total_bin_size were similar
88+
#[derive(Debug, Clone)]
89+
pub(crate) struct DirSizes {
90+
pub(crate) total_size: u64,
91+
pub(crate) numb_bins: u64,
92+
pub(crate) total_bin_size: u64,
93+
pub(crate) total_reg_size: u64,
94+
pub(crate) total_git_db_size: u64,
95+
pub(crate) total_git_repos_bare_size: u64,
96+
pub(crate) numb_git_repos_bare_repos: u64,
97+
pub(crate) numb_git_checkouts: u64,
98+
pub(crate) total_git_chk_size: u64,
99+
pub(crate) total_reg_cache_size: u64,
100+
pub(crate) total_reg_src_size: u64,
101+
pub(crate) numb_reg_cache_entries: u64,
102+
pub(crate) numb_reg_src_checkouts: u64,
103+
}

0 commit comments

Comments
 (0)