diff --git a/tests/ui/filter_map_next.rs b/tests/ui/filter_map_next.rs index 7a53ae765326..cce526060f61 100644 --- a/tests/ui/filter_map_next.rs +++ b/tests/ui/filter_map_next.rs @@ -3,6 +3,6 @@ fn main() { let a = ["1", "lol", "3", "NaN", "5"]; - let element : Option = a.iter().filter_map(|s| s.parse().ok()).next(); + let element: Option = a.iter().filter_map(|s| s.parse().ok()).next(); assert_eq!(element, Some(1)); -} \ No newline at end of file +} diff --git a/tests/ui/filter_map_next.stderr b/tests/ui/filter_map_next.stderr index 518ff04b31e5..6c0ea8985dcc 100644 --- a/tests/ui/filter_map_next.stderr +++ b/tests/ui/filter_map_next.stderr @@ -1,8 +1,8 @@ error: called `filter_map(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(p)` instead. - --> $DIR/filter_map_next.rs:6:33 + --> $DIR/filter_map_next.rs:6:32 | -LL | let element : Option = a.iter().filter_map(|s| s.parse().ok()).next(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let element: Option = a.iter().filter_map(|s| s.parse().ok()).next(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::filter-map-next` implied by `-D warnings` = note: replace `filter_map(|s| s.parse().ok()).next()` with `find_map(|s| s.parse().ok())` diff --git a/tests/ui/find_map.rs b/tests/ui/find_map.rs index 207748b18498..c28cca144ca3 100644 --- a/tests/ui/find_map.rs +++ b/tests/ui/find_map.rs @@ -1,38 +1,32 @@ #![warn(clippy::all, clippy::pedantic)] -#[derive(Debug,Copy,Clone)] +#[derive(Debug, Copy, Clone)] enum Flavor { Chocolate, } -#[derive(Debug,Copy,Clone)] +#[derive(Debug, Copy, Clone)] enum Dessert { Banana, Pudding, - Cake(Flavor) + Cake(Flavor), } fn main() { - let desserts_of_the_week = vec![ - Dessert::Banana, - Dessert::Cake(Flavor::Chocolate), - Dessert::Pudding, - ]; + let desserts_of_the_week = vec![Dessert::Banana, Dessert::Cake(Flavor::Chocolate), Dessert::Pudding]; let a = ["lol", "NaN", "2", "5", "Xunda"]; - let _ : Option = a.iter().find(|s| s.parse::().is_ok()) - .map(|s| s.parse().unwrap()); + let _: Option = a.iter().find(|s| s.parse::().is_ok()).map(|s| s.parse().unwrap()); - let _ : Option = desserts_of_the_week.iter().find(|dessert|{ - match *dessert { + let _: Option = desserts_of_the_week + .iter() + .find(|dessert| match *dessert { Dessert::Cake(_) => true, - _ => false - } - }).map(|dessert|{ - match *dessert { + _ => false, + }) + .map(|dessert| match *dessert { Dessert::Cake(ref flavor) => *flavor, - _ => unreachable!() - } - }); -} \ No newline at end of file + _ => unreachable!(), + }); +} diff --git a/tests/ui/find_map.stderr b/tests/ui/find_map.stderr index 03c7efd2a069..0417c7f3dc9a 100644 --- a/tests/ui/find_map.stderr +++ b/tests/ui/find_map.stderr @@ -1,25 +1,23 @@ error: called `find(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead. - --> $DIR/find_map.rs:24:27 + --> $DIR/find_map.rs:20:26 | -LL | let _ : Option = a.iter().find(|s| s.parse::().is_ok()) - | ___________________________^ -LL | | .map(|s| s.parse().unwrap()); - | |______________________________________________________________^ +LL | let _: Option = a.iter().find(|s| s.parse::().is_ok()).map(|s| s.parse().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::find-map` implied by `-D warnings` error: called `find(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead. - --> $DIR/find_map.rs:27:30 + --> $DIR/find_map.rs:22:29 | -LL | let _ : Option = desserts_of_the_week.iter().find(|dessert|{ - | ______________________________^ -LL | | match *dessert { +LL | let _: Option = desserts_of_the_week + | _____________________________^ +LL | | .iter() +LL | | .find(|dessert| match *dessert { LL | | Dessert::Cake(_) => true, -LL | | _ => false ... | -LL | | } -LL | | }); - | |______^ +LL | | _ => unreachable!(), +LL | | }); + | |__________^ error: aborting due to 2 previous errors