Skip to content

Commit 40cb24f

Browse files
committed
fix: simplify suggestion
1 parent 11162d1 commit 40cb24f

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

clippy_lints/src/methods/unnecessary_filter_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>, a
7979
},
8080
expr.span,
8181
format!("this `.{name}` can be written more simply"),
82-
format!("try replacing with `.{sugg}`"),
82+
format!("try instead"),
8383
sugg.to_string(),
8484
Applicability::MaybeIncorrect,
8585
);

tests/ui/unnecessary_filter_map.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: this `.filter_map` can be written more simply
22
--> tests/ui/unnecessary_filter_map.rs:5:13
33
|
44
LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.filter`: `filter`
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)]`
@@ -18,7 +18,7 @@ LL | | return Some(x);
1818
LL | | };
1919
LL | | None
2020
LL | | });
21-
| |______^ help: try replacing with `.filter`: `filter`
21+
| |______^ help: try instead: `filter`
2222

2323
error: this `.filter_map` can be written more simply
2424
--> tests/ui/unnecessary_filter_map.rs:15:13
@@ -29,13 +29,13 @@ LL | |
2929
LL | | 0 | 1 => None,
3030
LL | | _ => Some(x),
3131
LL | | });
32-
| |______^ help: try replacing with `.filter`: `filter`
32+
| |______^ help: try instead: `filter`
3333

3434
error: this `.filter_map` can be written more simply
3535
--> tests/ui/unnecessary_filter_map.rs:21:13
3636
|
3737
LL | let _ = (0..4).filter_map(|x| Some(x + 1));
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.map`: `map`
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map`
3939

4040
error: redundant closure
4141
--> tests/ui/unnecessary_filter_map.rs:28:57
@@ -56,13 +56,13 @@ error: this `.filter_map` can be written more simply
5656
--> tests/ui/unnecessary_filter_map.rs:28:13
5757
|
5858
LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x));
59-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.map`: `map`
59+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map`
6060

6161
error: this `.filter_map` can be written more simply
6262
--> tests/ui/unnecessary_filter_map.rs:165:14
6363
|
6464
LL | let _x = std::iter::once(1).filter_map(|n| (n > 1).then_some(n));
65-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.filter`: `filter`
65+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `filter`
6666

6767
error: aborting due to 8 previous errors
6868

tests/ui/unnecessary_find_map.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: this `.find_map` can be written more simply
22
--> tests/ui/unnecessary_find_map.rs:5:13
33
|
44
LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None });
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.find`: `find`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `find`
66
|
77
= note: `-D clippy::unnecessary-find-map` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_find_map)]`
@@ -18,7 +18,7 @@ LL | | return Some(x);
1818
LL | | };
1919
LL | | None
2020
LL | | });
21-
| |______^ help: try replacing with `.find`: `find`
21+
| |______^ help: try instead: `find`
2222

2323
error: this `.find_map` can be written more simply
2424
--> tests/ui/unnecessary_find_map.rs:15:13
@@ -29,19 +29,19 @@ LL | |
2929
LL | | 0 | 1 => None,
3030
LL | | _ => Some(x),
3131
LL | | });
32-
| |______^ help: try replacing with `.find`: `find`
32+
| |______^ help: try instead: `find`
3333

3434
error: this `.find_map` can be written more simply
3535
--> tests/ui/unnecessary_find_map.rs:21:13
3636
|
3737
LL | let _ = (0..4).find_map(|x| Some(x + 1));
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.map(..).next()`: `map(..).next()`
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map(..).next()`
3939

4040
error: this `.find_map` can be written more simply
4141
--> tests/ui/unnecessary_find_map.rs:33:14
4242
|
4343
LL | let _x = std::iter::once(1).find_map(|n| (n > 1).then_some(n));
44-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.find`: `find`
44+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `find`
4545

4646
error: aborting due to 5 previous errors
4747

0 commit comments

Comments
 (0)