1
- error: this `.filter_map` can be written more simply using `.filter`
2
- --> tests/ui/unnecessary_filter_map.rs:4 :13
1
+ error: this `.filter_map` can be written more simply
2
+ --> tests/ui/unnecessary_filter_map.rs:5 :13
3
3
|
4
4
LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
5
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `filter`
6
6
|
7
7
= note: `-D clippy::unnecessary-filter-map` implied by `-D warnings`
8
8
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_filter_map)]`
9
9
10
- error: this `.filter_map` can be written more simply using `.filter`
11
- --> tests/ui/unnecessary_filter_map.rs:7 :13
10
+ error: this `.filter_map` can be written more simply
11
+ --> tests/ui/unnecessary_filter_map.rs:8 :13
12
12
|
13
13
LL | let _ = (0..4).filter_map(|x| {
14
14
| _____________^
@@ -18,30 +18,51 @@ LL | | return Some(x);
18
18
LL | | };
19
19
LL | | None
20
20
LL | | });
21
- | |______^
21
+ | |______^ help: try instead: `filter`
22
22
23
- error: this `.filter_map` can be written more simply using `.filter`
24
- --> tests/ui/unnecessary_filter_map.rs:14 :13
23
+ error: this `.filter_map` can be written more simply
24
+ --> tests/ui/unnecessary_filter_map.rs:15 :13
25
25
|
26
26
LL | let _ = (0..4).filter_map(|x| match x {
27
27
| _____________^
28
28
LL | |
29
29
LL | | 0 | 1 => None,
30
30
LL | | _ => Some(x),
31
31
LL | | });
32
- | |______^
32
+ | |______^ help: try instead: `filter`
33
33
34
- error: this `.filter_map` can be written more simply using `.map`
35
- --> tests/ui/unnecessary_filter_map.rs:20 :13
34
+ error: this `.filter_map` can be written more simply
35
+ --> tests/ui/unnecessary_filter_map.rs:21 :13
36
36
|
37
37
LL | let _ = (0..4).filter_map(|x| Some(x + 1));
38
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map`
39
39
40
- error: this `.filter_map` can be written more simply using `.filter`
41
- --> tests/ui/unnecessary_filter_map.rs:160:14
40
+ error: redundant closure
41
+ --> tests/ui/unnecessary_filter_map.rs:28:57
42
+ |
43
+ LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x));
44
+ | ^^^^^^^^^^^ help: replace the closure with the function itself: `Some`
45
+ |
46
+ = note: `-D clippy::redundant-closure` implied by `-D warnings`
47
+ = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]`
48
+
49
+ error: filter_map is unnecessary
50
+ --> tests/ui/unnecessary_filter_map.rs:28:61
51
+ |
52
+ LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x));
53
+ | ^^^^ help: try removing the filter_map
54
+
55
+ error: this `.filter_map` can be written more simply
56
+ --> tests/ui/unnecessary_filter_map.rs:28:13
57
+ |
58
+ LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x));
59
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map`
60
+
61
+ error: this `.filter_map` can be written more simply
62
+ --> tests/ui/unnecessary_filter_map.rs:165:14
42
63
|
43
64
LL | let _x = std::iter::once(1).filter_map(|n| (n > 1).then_some(n));
44
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `filter`
45
66
46
- error: aborting due to 5 previous errors
67
+ error: aborting due to 8 previous errors
47
68
0 commit comments