Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m-rph committed Dec 24, 2023
1 parent 2177f2c commit 85e1646
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/ui/iter_filter_is_ok.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/iter_filter_is_ok.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/iter_filter_is_ok.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

5 changes: 5 additions & 0 deletions tests/ui/iter_filter_is_some.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/iter_filter_is_some.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/iter_filter_is_some.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 85e1646

Please sign in to comment.