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
33 |
44LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
5- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `filter`
66 |
77 = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings`
88 = help: to override `-D warnings` add `#[allow(clippy::unnecessary_filter_map)]`
99
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
1212 |
1313LL | let _ = (0..4).filter_map(|x| {
1414 | _____________^
@@ -18,30 +18,51 @@ LL | | return Some(x);
1818LL | | };
1919LL | | None
2020LL | | });
21- | |______^
21+ | |______^ help: try instead: `filter`
2222
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
2525 |
2626LL | let _ = (0..4).filter_map(|x| match x {
2727 | _____________^
2828LL | |
2929LL | | 0 | 1 => None,
3030LL | | _ => Some(x),
3131LL | | });
32- | |______^
32+ | |______^ help: try instead: `filter`
3333
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
3636 |
3737LL | let _ = (0..4).filter_map(|x| Some(x + 1));
38- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map`
3939
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
4263 |
4364LL | let _x = std::iter::once(1).filter_map(|n| (n > 1).then_some(n));
44- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `filter`
4566
46- error: aborting due to 5 previous errors
67+ error: aborting due to 8 previous errors
4768
0 commit comments