Skip to content

Commit 2dd917e

Browse files
committed
Attributes cleanup in tests [19/20]
1 parent fdd9f4e commit 2dd917e

94 files changed

Lines changed: 740 additions & 869 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/ui/unnecessary_first_then_check.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![warn(clippy::unnecessary_first_then_check)]
2-
#![allow(clippy::useless_vec, clippy::const_is_empty)]
2+
#![allow(clippy::const_is_empty)]
3+
#![expect(clippy::useless_vec)]
34

45
fn main() {
56
let s = [1, 2, 3];

tests/ui/unnecessary_first_then_check.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![warn(clippy::unnecessary_first_then_check)]
2-
#![allow(clippy::useless_vec, clippy::const_is_empty)]
2+
#![allow(clippy::const_is_empty)]
3+
#![expect(clippy::useless_vec)]
34

45
fn main() {
56
let s = [1, 2, 3];

tests/ui/unnecessary_first_then_check.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unnecessary use of `first().is_some()` to check if slice is not empty
2-
--> tests/ui/unnecessary_first_then_check.rs:6:19
2+
--> tests/ui/unnecessary_first_then_check.rs:7:19
33
|
44
LL | let _: bool = s.first().is_some();
55
| ^^^^^^^^^^^^^^^^^^^ help: replace this with: `!s.is_empty()`
@@ -8,37 +8,37 @@ LL | let _: bool = s.first().is_some();
88
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_first_then_check)]`
99

1010
error: unnecessary use of `first().is_none()` to check if slice is empty
11-
--> tests/ui/unnecessary_first_then_check.rs:8:21
11+
--> tests/ui/unnecessary_first_then_check.rs:9:21
1212
|
1313
LL | let _: bool = s.first().is_none();
1414
| ^^^^^^^^^^^^^^^^^ help: replace this with: `is_empty()`
1515

1616
error: unnecessary use of `first().is_some()` to check if slice is not empty
17-
--> tests/ui/unnecessary_first_then_check.rs:12:19
17+
--> tests/ui/unnecessary_first_then_check.rs:13:19
1818
|
1919
LL | let _: bool = v.first().is_some();
2020
| ^^^^^^^^^^^^^^^^^^^ help: replace this with: `!v.is_empty()`
2121

2222
error: unnecessary use of `first().is_some()` to check if slice is not empty
23-
--> tests/ui/unnecessary_first_then_check.rs:16:19
23+
--> tests/ui/unnecessary_first_then_check.rs:17:19
2424
|
2525
LL | let _: bool = n[0].first().is_some();
2626
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!n[0].is_empty()`
2727

2828
error: unnecessary use of `first().is_none()` to check if slice is empty
29-
--> tests/ui/unnecessary_first_then_check.rs:18:24
29+
--> tests/ui/unnecessary_first_then_check.rs:19:24
3030
|
3131
LL | let _: bool = n[0].first().is_none();
3232
| ^^^^^^^^^^^^^^^^^ help: replace this with: `is_empty()`
3333

3434
error: unnecessary use of `first().is_some()` to check if slice is not empty
35-
--> tests/ui/unnecessary_first_then_check.rs:25:19
35+
--> tests/ui/unnecessary_first_then_check.rs:26:19
3636
|
3737
LL | let _: bool = f[0].bar.first().is_some();
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this with: `!f[0].bar.is_empty()`
3939

4040
error: unnecessary use of `first().is_none()` to check if slice is empty
41-
--> tests/ui/unnecessary_first_then_check.rs:27:28
41+
--> tests/ui/unnecessary_first_then_check.rs:28:28
4242
|
4343
LL | let _: bool = f[0].bar.first().is_none();
4444
| ^^^^^^^^^^^^^^^^^ help: replace this with: `is_empty()`

tests/ui/unnecessary_fold.fixed

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![allow(dead_code)]
2-
1+
#![warn(clippy::unnecessary_fold)]
32
fn is_any(acc: bool, x: usize) -> bool {
43
acc || x > 2
54
}

tests/ui/unnecessary_fold.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![allow(dead_code)]
2-
1+
#![warn(clippy::unnecessary_fold)]
32
fn is_any(acc: bool, x: usize) -> bool {
43
acc || x > 2
54
}

tests/ui/unnecessary_fold.stderr

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this `.fold` can be written more succinctly using another method
2-
--> tests/ui/unnecessary_fold.rs:12:20
2+
--> tests/ui/unnecessary_fold.rs:11:20
33
|
44
LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)`
@@ -9,7 +9,7 @@ LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2);
99
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_fold)]`
1010

1111
error: redundant closure
12-
--> tests/ui/unnecessary_fold.rs:16:32
12+
--> tests/ui/unnecessary_fold.rs:15:32
1313
|
1414
LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x));
1515
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `is_any`
@@ -18,245 +18,245 @@ LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x));
1818
= help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]`
1919

2020
error: this `.fold` can be written more succinctly using another method
21-
--> tests/ui/unnecessary_fold.rs:20:20
21+
--> tests/ui/unnecessary_fold.rs:19:20
2222
|
2323
LL | let _ = (0..3).fold(true, |acc, x| acc && x > 2);
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `all(|x| x > 2)`
2525
|
2626
= note: the `all` method is short circuiting and may change the program semantics if the iterator has side effects
2727

2828
error: this `.fold` can be written more succinctly using another method
29-
--> tests/ui/unnecessary_fold.rs:24:25
29+
--> tests/ui/unnecessary_fold.rs:23:25
3030
|
3131
LL | let _: i32 = (0..3).fold(0, |acc, x| acc + x);
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()`
3333

3434
error: this `.fold` can be written more succinctly using another method
35-
--> tests/ui/unnecessary_fold.rs:26:25
35+
--> tests/ui/unnecessary_fold.rs:25:25
3636
|
3737
LL | let _: i32 = (0..3).fold(0, Add::add);
3838
| ^^^^^^^^^^^^^^^^^ help: try: `sum()`
3939

4040
error: this `.fold` can be written more succinctly using another method
41-
--> tests/ui/unnecessary_fold.rs:28:25
41+
--> tests/ui/unnecessary_fold.rs:27:25
4242
|
4343
LL | let _: i32 = (0..3).fold(0, i32::add);
4444
| ^^^^^^^^^^^^^^^^^ help: try: `sum()`
4545

4646
error: this `.fold` can be written more succinctly using another method
47-
--> tests/ui/unnecessary_fold.rs:32:25
47+
--> tests/ui/unnecessary_fold.rs:31:25
4848
|
4949
LL | let _: i32 = (0..3).fold(1, |acc, x| acc * x);
5050
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()`
5151

5252
error: this `.fold` can be written more succinctly using another method
53-
--> tests/ui/unnecessary_fold.rs:34:25
53+
--> tests/ui/unnecessary_fold.rs:33:25
5454
|
5555
LL | let _: i32 = (0..3).fold(1, Mul::mul);
5656
| ^^^^^^^^^^^^^^^^^ help: try: `product()`
5757

5858
error: this `.fold` can be written more succinctly using another method
59-
--> tests/ui/unnecessary_fold.rs:36:25
59+
--> tests/ui/unnecessary_fold.rs:35:25
6060
|
6161
LL | let _: i32 = (0..3).fold(1, i32::mul);
6262
| ^^^^^^^^^^^^^^^^^ help: try: `product()`
6363

6464
error: this `.fold` can be written more succinctly using another method
65-
--> tests/ui/unnecessary_fold.rs:42:41
65+
--> tests/ui/unnecessary_fold.rs:41:41
6666
|
6767
LL | let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2);
6868
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)`
6969
|
7070
= note: the `any` method is short circuiting and may change the program semantics if the iterator has side effects
7171

7272
error: this `.fold` can be written more succinctly using another method
73-
--> tests/ui/unnecessary_fold.rs:100:10
73+
--> tests/ui/unnecessary_fold.rs:99:10
7474
|
7575
LL | .fold(false, |acc, x| acc || x > 2);
7676
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)`
7777
|
7878
= note: the `any` method is short circuiting and may change the program semantics if the iterator has side effects
7979

8080
error: this `.fold` can be written more succinctly using another method
81-
--> tests/ui/unnecessary_fold.rs:113:33
81+
--> tests/ui/unnecessary_fold.rs:112:33
8282
|
8383
LL | assert_eq!(map.values().fold(0, |x, y| x + y), 0);
8484
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
8585

8686
error: this `.fold` can be written more succinctly using another method
87-
--> tests/ui/unnecessary_fold.rs:117:30
87+
--> tests/ui/unnecessary_fold.rs:116:30
8888
|
8989
LL | let _ = map.values().fold(0, |x, y| x + y);
9090
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
9191

9292
error: this `.fold` can be written more succinctly using another method
93-
--> tests/ui/unnecessary_fold.rs:119:30
93+
--> tests/ui/unnecessary_fold.rs:118:30
9494
|
9595
LL | let _ = map.values().fold(0, Add::add);
9696
| ^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
9797

9898
error: this `.fold` can be written more succinctly using another method
99-
--> tests/ui/unnecessary_fold.rs:121:30
99+
--> tests/ui/unnecessary_fold.rs:120:30
100100
|
101101
LL | let _ = map.values().fold(1, |x, y| x * y);
102102
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::<i32>()`
103103

104104
error: this `.fold` can be written more succinctly using another method
105-
--> tests/ui/unnecessary_fold.rs:123:30
105+
--> tests/ui/unnecessary_fold.rs:122:30
106106
|
107107
LL | let _ = map.values().fold(1, Mul::mul);
108108
| ^^^^^^^^^^^^^^^^^ help: try: `product::<i32>()`
109109

110110
error: this `.fold` can be written more succinctly using another method
111-
--> tests/ui/unnecessary_fold.rs:125:35
111+
--> tests/ui/unnecessary_fold.rs:124:35
112112
|
113113
LL | let _: i32 = map.values().fold(0, |x, y| x + y);
114114
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()`
115115

116116
error: this `.fold` can be written more succinctly using another method
117-
--> tests/ui/unnecessary_fold.rs:127:35
117+
--> tests/ui/unnecessary_fold.rs:126:35
118118
|
119119
LL | let _: i32 = map.values().fold(0, Add::add);
120120
| ^^^^^^^^^^^^^^^^^ help: try: `sum()`
121121

122122
error: this `.fold` can be written more succinctly using another method
123-
--> tests/ui/unnecessary_fold.rs:129:35
123+
--> tests/ui/unnecessary_fold.rs:128:35
124124
|
125125
LL | let _: i32 = map.values().fold(1, |x, y| x * y);
126126
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()`
127127

128128
error: this `.fold` can be written more succinctly using another method
129-
--> tests/ui/unnecessary_fold.rs:131:35
129+
--> tests/ui/unnecessary_fold.rs:130:35
130130
|
131131
LL | let _: i32 = map.values().fold(1, Mul::mul);
132132
| ^^^^^^^^^^^^^^^^^ help: try: `product()`
133133

134134
error: this `.fold` can be written more succinctly using another method
135-
--> tests/ui/unnecessary_fold.rs:133:31
135+
--> tests/ui/unnecessary_fold.rs:132:31
136136
|
137137
LL | anything(map.values().fold(0, |x, y| x + y));
138138
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
139139

140140
error: this `.fold` can be written more succinctly using another method
141-
--> tests/ui/unnecessary_fold.rs:135:31
141+
--> tests/ui/unnecessary_fold.rs:134:31
142142
|
143143
LL | anything(map.values().fold(0, Add::add));
144144
| ^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
145145

146146
error: this `.fold` can be written more succinctly using another method
147-
--> tests/ui/unnecessary_fold.rs:137:31
147+
--> tests/ui/unnecessary_fold.rs:136:31
148148
|
149149
LL | anything(map.values().fold(1, |x, y| x * y));
150150
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::<i32>()`
151151

152152
error: this `.fold` can be written more succinctly using another method
153-
--> tests/ui/unnecessary_fold.rs:139:31
153+
--> tests/ui/unnecessary_fold.rs:138:31
154154
|
155155
LL | anything(map.values().fold(1, Mul::mul));
156156
| ^^^^^^^^^^^^^^^^^ help: try: `product::<i32>()`
157157

158158
error: this `.fold` can be written more succinctly using another method
159-
--> tests/ui/unnecessary_fold.rs:141:26
159+
--> tests/ui/unnecessary_fold.rs:140:26
160160
|
161161
LL | num(map.values().fold(0, |x, y| x + y));
162162
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()`
163163

164164
error: this `.fold` can be written more succinctly using another method
165-
--> tests/ui/unnecessary_fold.rs:143:26
165+
--> tests/ui/unnecessary_fold.rs:142:26
166166
|
167167
LL | num(map.values().fold(0, Add::add));
168168
| ^^^^^^^^^^^^^^^^^ help: try: `sum()`
169169

170170
error: this `.fold` can be written more succinctly using another method
171-
--> tests/ui/unnecessary_fold.rs:145:26
171+
--> tests/ui/unnecessary_fold.rs:144:26
172172
|
173173
LL | num(map.values().fold(1, |x, y| x * y));
174174
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()`
175175

176176
error: this `.fold` can be written more succinctly using another method
177-
--> tests/ui/unnecessary_fold.rs:147:26
177+
--> tests/ui/unnecessary_fold.rs:146:26
178178
|
179179
LL | num(map.values().fold(1, Mul::mul));
180180
| ^^^^^^^^^^^^^^^^^ help: try: `product()`
181181

182182
error: this `.fold` can be written more succinctly using another method
183-
--> tests/ui/unnecessary_fold.rs:154:16
183+
--> tests/ui/unnecessary_fold.rs:153:16
184184
|
185185
LL | (0..3).fold(0, |acc, x| acc + x)
186186
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()`
187187

188188
error: this `.fold` can be written more succinctly using another method
189-
--> tests/ui/unnecessary_fold.rs:158:16
189+
--> tests/ui/unnecessary_fold.rs:157:16
190190
|
191191
LL | (0..3).fold(1, |acc, x| acc * x)
192192
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()`
193193

194194
error: this `.fold` can be written more succinctly using another method
195-
--> tests/ui/unnecessary_fold.rs:162:16
195+
--> tests/ui/unnecessary_fold.rs:161:16
196196
|
197197
LL | (0..3).fold(0, |acc, x| acc + x)
198198
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
199199

200200
error: this `.fold` can be written more succinctly using another method
201-
--> tests/ui/unnecessary_fold.rs:166:16
201+
--> tests/ui/unnecessary_fold.rs:165:16
202202
|
203203
LL | (0..3).fold(1, |acc, x| acc * x)
204204
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product::<i32>()`
205205

206206
error: this `.fold` can be written more succinctly using another method
207-
--> tests/ui/unnecessary_fold.rs:172:21
207+
--> tests/ui/unnecessary_fold.rs:171:21
208208
|
209209
LL | let _ = (2..=3).fold(1, |a, b| a * b);
210210
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::<i32>()`
211211

212212
error: this `.fold` can be written more succinctly using another method
213-
--> tests/ui/unnecessary_fold.rs:174:21
213+
--> tests/ui/unnecessary_fold.rs:173:21
214214
|
215215
LL | let _ = (1..=3).fold(0, |a, b| a + b);
216216
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
217217

218218
error: this `.fold` can be written more succinctly using another method
219-
--> tests/ui/unnecessary_fold.rs:176:21
219+
--> tests/ui/unnecessary_fold.rs:175:21
220220
|
221221
LL | let _ = (2..=3).fold(1, |b, a| a * b);
222222
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::<i32>()`
223223

224224
error: this `.fold` can be written more succinctly using another method
225-
--> tests/ui/unnecessary_fold.rs:178:21
225+
--> tests/ui/unnecessary_fold.rs:177:21
226226
|
227227
LL | let _ = (1..=3).fold(0, |b, a| a + b);
228228
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
229229

230230
error: this `.fold` can be written more succinctly using another method
231-
--> tests/ui/unnecessary_fold.rs:181:20
231+
--> tests/ui/unnecessary_fold.rs:180:20
232232
|
233233
LL | let _ = (0..3).fold(false, |acc, x| x > 2 || acc);
234234
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)`
235235
|
236236
= note: the `any` method is short circuiting and may change the program semantics if the iterator has side effects
237237

238238
error: this `.fold` can be written more succinctly using another method
239-
--> tests/ui/unnecessary_fold.rs:183:20
239+
--> tests/ui/unnecessary_fold.rs:182:20
240240
|
241241
LL | let _ = (0..3).fold(true, |acc, x| x > 2 && acc);
242242
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `all(|x| x > 2)`
243243
|
244244
= note: the `all` method is short circuiting and may change the program semantics if the iterator has side effects
245245

246246
error: this `.fold` can be written more succinctly using another method
247-
--> tests/ui/unnecessary_fold.rs:185:20
247+
--> tests/ui/unnecessary_fold.rs:184:20
248248
|
249249
LL | let _ = (0..3).fold(0, |acc, x| x + acc);
250250
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::<i32>()`
251251

252252
error: this `.fold` can be written more succinctly using another method
253-
--> tests/ui/unnecessary_fold.rs:187:20
253+
--> tests/ui/unnecessary_fold.rs:186:20
254254
|
255255
LL | let _ = (0..3).fold(1, |acc, x| x * acc);
256256
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product::<i32>()`
257257

258258
error: this `.fold` can be written more succinctly using another method
259-
--> tests/ui/unnecessary_fold.rs:198:20
259+
--> tests/ui/unnecessary_fold.rs:197:20
260260
|
261261
LL | let _ = (0..3).fold(false, |acc: bool, x| acc || test_expr!(x));
262262
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| test_expr!(x))`

0 commit comments

Comments
 (0)