From 85e1646afcf4010b8bb74b64762f247e73912884 Mon Sep 17 00:00:00 2001 From: Quinn Sinclair Date: Sun, 24 Dec 2023 17:32:00 +0200 Subject: [PATCH] more tests --- tests/ui/iter_filter_is_ok.fixed | 4 ++++ tests/ui/iter_filter_is_ok.rs | 4 ++++ tests/ui/iter_filter_is_ok.stderr | 8 +++++++- tests/ui/iter_filter_is_some.fixed | 5 +++++ tests/ui/iter_filter_is_some.rs | 5 +++++ tests/ui/iter_filter_is_some.stderr | 8 +++++++- 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/ui/iter_filter_is_ok.fixed b/tests/ui/iter_filter_is_ok.fixed index acfd097675c9..a5ca41528afd 100644 --- a/tests/ui/iter_filter_is_ok.fixed +++ b/tests/ui/iter_filter_is_ok.fixed @@ -6,6 +6,10 @@ fn main() { let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().flatten(); //~^ HELP: consider using `flatten` instead + #[rustfmt::skip] + let _ = vec![Ok(1), Err(2)].into_iter().flatten(); + //~^ HELP: consider using `flatten` instead + // Don't lint below let mut counter = 0; let _ = vec![Ok(1), Err(2)].into_iter().filter(|o| { diff --git a/tests/ui/iter_filter_is_ok.rs b/tests/ui/iter_filter_is_ok.rs index f13a28ad0e3c..e4e73f5ada1c 100644 --- a/tests/ui/iter_filter_is_ok.rs +++ b/tests/ui/iter_filter_is_ok.rs @@ -6,6 +6,10 @@ fn main() { let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|a| a.is_ok()); //~^ HELP: consider using `flatten` instead + #[rustfmt::skip] + let _ = vec![Ok(1), Err(2)].into_iter().filter(|o| { o.is_ok() }); + //~^ HELP: consider using `flatten` instead + // Don't lint below let mut counter = 0; let _ = vec![Ok(1), Err(2)].into_iter().filter(|o| { diff --git a/tests/ui/iter_filter_is_ok.stderr b/tests/ui/iter_filter_is_ok.stderr index a5d7da977ff7..f3acbe38d8a8 100644 --- a/tests/ui/iter_filter_is_ok.stderr +++ b/tests/ui/iter_filter_is_ok.stderr @@ -13,5 +13,11 @@ error: `filter` for `is_ok` on iterator over `Result`s LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` -error: aborting due to 2 previous errors +error: `filter` for `is_ok` on iterator over `Result`s + --> $DIR/iter_filter_is_ok.rs:10:45 + | +LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|o| { o.is_ok() }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` + +error: aborting due to 3 previous errors diff --git a/tests/ui/iter_filter_is_some.fixed b/tests/ui/iter_filter_is_some.fixed index f70f54b622e3..c3fa93f0ab21 100644 --- a/tests/ui/iter_filter_is_some.fixed +++ b/tests/ui/iter_filter_is_some.fixed @@ -6,12 +6,17 @@ fn main() { let _ = vec![Some(1)].into_iter().flatten(); //~^ HELP: consider using `flatten` instead + #[rustfmt::skip] + let _ = vec![Some(1)].into_iter().flatten(); + //~^ HELP: consider using `flatten` instead + // Don't lint below let mut counter = 0; let _ = vec![Some(1)].into_iter().filter(|o| { counter += 1; o.is_some() }); + let _ = vec![Some(1)].into_iter().filter(|o| { // Roses are red, // Violets are blue, diff --git a/tests/ui/iter_filter_is_some.rs b/tests/ui/iter_filter_is_some.rs index 18d450e8a986..b023776abe46 100644 --- a/tests/ui/iter_filter_is_some.rs +++ b/tests/ui/iter_filter_is_some.rs @@ -6,12 +6,17 @@ fn main() { let _ = vec![Some(1)].into_iter().filter(|o| o.is_some()); //~^ HELP: consider using `flatten` instead + #[rustfmt::skip] + let _ = vec![Some(1)].into_iter().filter(|o| { o.is_some() }); + //~^ HELP: consider using `flatten` instead + // Don't lint below let mut counter = 0; let _ = vec![Some(1)].into_iter().filter(|o| { counter += 1; o.is_some() }); + let _ = vec![Some(1)].into_iter().filter(|o| { // Roses are red, // Violets are blue, diff --git a/tests/ui/iter_filter_is_some.stderr b/tests/ui/iter_filter_is_some.stderr index a9ef1d547a95..1f2b10036fef 100644 --- a/tests/ui/iter_filter_is_some.stderr +++ b/tests/ui/iter_filter_is_some.stderr @@ -13,5 +13,11 @@ error: `filter` for `is_some` on iterator over `Option` LL | let _ = vec![Some(1)].into_iter().filter(|o| o.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` -error: aborting due to 2 previous errors +error: `filter` for `is_some` on iterator over `Option` + --> $DIR/iter_filter_is_some.rs:10:39 + | +LL | let _ = vec![Some(1)].into_iter().filter(|o| { o.is_some() }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` + +error: aborting due to 3 previous errors