Skip to content

Commit c333d46

Browse files
committed
Formatted the ui tests
1 parent a15b160 commit c333d46

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

tests/ui/map_identity.fixed

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
fn main() {
66
let x: [u16; 3] = [1, 2, 3];
77
// should lint
8-
let _: Vec<_> = x.iter().collect();
8+
let _: Vec<_> = x.iter().map(not_identity).collect();
99
let _: Vec<_> = x.iter().collect();
1010
let _: Option<u8> = Some(3);
11+
let _: Result<i8, f32> = Ok(-3);
1112
// should not lint
12-
let _: Vec<_> = x.iter().map(|x| 2*x).collect();
13-
let _: Vec<_> = x.iter().map(not_identity).collect();
13+
let _: Vec<_> = x.iter().map(|x| 2 * x).collect();
14+
let _: Vec<_> = x.iter().map(not_identity).map(|x| return x - 4).collect();
15+
let _: Option<u8> = None.map(|x: u8| x - 1);
16+
let _: Result<i8, f32> = Err(2.3).map(|x: i8| {
17+
return x + 3;
18+
});
1419
}
1520

1621
#[allow(dead_code)]

tests/ui/map_identity.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
fn main() {
66
let x: [u16; 3] = [1, 2, 3];
77
// should lint
8-
let _: Vec<_> = x.iter().map(|x| { return x }).collect();
9-
let _: Vec<_> = x.iter().map(identity).collect();
8+
let _: Vec<_> = x.iter().map(not_identity).map(|x| return x).collect();
9+
let _: Vec<_> = x.iter().map(identity).map(|y| y).collect();
1010
let _: Option<u8> = Some(3).map(|x| x);
11+
let _: Result<i8, f32> = Ok(-3).map(|x| {
12+
return x;
13+
});
1114
// should not lint
12-
let _: Vec<_> = x.iter().map(|x| 2*x).collect();
13-
let _: Vec<_> = x.iter().map(not_identity).collect();
15+
let _: Vec<_> = x.iter().map(|x| 2 * x).collect();
16+
let _: Vec<_> = x.iter().map(not_identity).map(|x| return x - 4).collect();
17+
let _: Option<u8> = None.map(|x: u8| x - 1);
18+
let _: Result<i8, f32> = Err(2.3).map(|x: i8| {
19+
return x + 3;
20+
});
1421
}
1522

1623
#[allow(dead_code)]

tests/ui/map_identity.stderr

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
error: unnecessary map of the identity function
22
--> $DIR/map_identity.rs:8:29
33
|
4-
LL | let _: Vec<_> = x.iter().map(|x| { return x }).collect();
5-
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map`
4+
LL | let _: Vec<_> = x.iter().map(not_identity).map(|x| return x).collect();
5+
| ^^^^^^^^^^^^^^^^^^ help: remove the call to `map`
66
|
77
= note: `-D clippy::map-identity` implied by `-D warnings`
88

9+
error: unnecessary map of the identity function
10+
--> $DIR/map_identity.rs:9:43
11+
|
12+
LL | let _: Vec<_> = x.iter().map(identity).map(|y| y).collect();
13+
| ^^^^^^^^^^^ help: remove the call to `map`
14+
915
error: unnecessary map of the identity function
1016
--> $DIR/map_identity.rs:9:29
1117
|
12-
LL | let _: Vec<_> = x.iter().map(identity).collect();
18+
LL | let _: Vec<_> = x.iter().map(identity).map(|y| y).collect();
1319
| ^^^^^^^^^^^^^^ help: remove the call to `map`
1420

1521
error: unnecessary map of the identity function
@@ -18,5 +24,14 @@ error: unnecessary map of the identity function
1824
LL | let _: Option<u8> = Some(3).map(|x| x);
1925
| ^^^^^^^^^^^ help: remove the call to `map`
2026

21-
error: aborting due to 3 previous errors
27+
error: unnecessary map of the identity function
28+
--> $DIR/map_identity.rs:11:36
29+
|
30+
LL | let _: Result<i8, f32> = Ok(-3).map(|x| {
31+
| ____________________________________^
32+
LL | | return x;
33+
LL | | });
34+
| |______^ help: remove the call to `map`
35+
36+
error: aborting due to 5 previous errors
2237

0 commit comments

Comments
 (0)