mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-26 14:40:32 +00:00
fix: simplify suggestion
This commit is contained in:
parent
11162d1b48
commit
40cb24f23c
3 changed files with 12 additions and 12 deletions
|
@ -79,7 +79,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>, a
|
|||
},
|
||||
expr.span,
|
||||
format!("this `.{name}` can be written more simply"),
|
||||
format!("try replacing with `.{sugg}`"),
|
||||
format!("try instead"),
|
||||
sugg.to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
|
|
@ -2,7 +2,7 @@ error: this `.filter_map` can be written more simply
|
|||
--> tests/ui/unnecessary_filter_map.rs:5:13
|
||||
|
|
||||
LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.filter`: `filter`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `filter`
|
||||
|
|
||||
= note: `-D clippy::unnecessary-filter-map` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_filter_map)]`
|
||||
|
@ -18,7 +18,7 @@ LL | | return Some(x);
|
|||
LL | | };
|
||||
LL | | None
|
||||
LL | | });
|
||||
| |______^ help: try replacing with `.filter`: `filter`
|
||||
| |______^ help: try instead: `filter`
|
||||
|
||||
error: this `.filter_map` can be written more simply
|
||||
--> tests/ui/unnecessary_filter_map.rs:15:13
|
||||
|
@ -29,13 +29,13 @@ LL | |
|
|||
LL | | 0 | 1 => None,
|
||||
LL | | _ => Some(x),
|
||||
LL | | });
|
||||
| |______^ help: try replacing with `.filter`: `filter`
|
||||
| |______^ help: try instead: `filter`
|
||||
|
||||
error: this `.filter_map` can be written more simply
|
||||
--> tests/ui/unnecessary_filter_map.rs:21:13
|
||||
|
|
||||
LL | let _ = (0..4).filter_map(|x| Some(x + 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.map`: `map`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map`
|
||||
|
||||
error: redundant closure
|
||||
--> tests/ui/unnecessary_filter_map.rs:28:57
|
||||
|
@ -56,13 +56,13 @@ error: this `.filter_map` can be written more simply
|
|||
--> tests/ui/unnecessary_filter_map.rs:28:13
|
||||
|
|
||||
LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.map`: `map`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map`
|
||||
|
||||
error: this `.filter_map` can be written more simply
|
||||
--> tests/ui/unnecessary_filter_map.rs:165:14
|
||||
|
|
||||
LL | let _x = std::iter::once(1).filter_map(|n| (n > 1).then_some(n));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.filter`: `filter`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `filter`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error: this `.find_map` can be written more simply
|
|||
--> tests/ui/unnecessary_find_map.rs:5:13
|
||||
|
|
||||
LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.find`: `find`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `find`
|
||||
|
|
||||
= note: `-D clippy::unnecessary-find-map` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_find_map)]`
|
||||
|
@ -18,7 +18,7 @@ LL | | return Some(x);
|
|||
LL | | };
|
||||
LL | | None
|
||||
LL | | });
|
||||
| |______^ help: try replacing with `.find`: `find`
|
||||
| |______^ help: try instead: `find`
|
||||
|
||||
error: this `.find_map` can be written more simply
|
||||
--> tests/ui/unnecessary_find_map.rs:15:13
|
||||
|
@ -29,19 +29,19 @@ LL | |
|
|||
LL | | 0 | 1 => None,
|
||||
LL | | _ => Some(x),
|
||||
LL | | });
|
||||
| |______^ help: try replacing with `.find`: `find`
|
||||
| |______^ help: try instead: `find`
|
||||
|
||||
error: this `.find_map` can be written more simply
|
||||
--> tests/ui/unnecessary_find_map.rs:21:13
|
||||
|
|
||||
LL | let _ = (0..4).find_map(|x| Some(x + 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.map(..).next()`: `map(..).next()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map(..).next()`
|
||||
|
||||
error: this `.find_map` can be written more simply
|
||||
--> tests/ui/unnecessary_find_map.rs:33:14
|
||||
|
|
||||
LL | let _x = std::iter::once(1).find_map(|n| (n > 1).then_some(n));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing with `.find`: `find`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `find`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue