Skip to content

Commit

Permalink
Add false positive test for manual_flatten
Browse files Browse the repository at this point in the history
Add a scenario where `manual_flatten` is triggered when match expression will still be used after the match in `if let`.
  • Loading branch information
dswij committed Aug 16, 2021
1 parent 3f0c977 commit 711c5cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/ui/manual_flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ fn main() {
}
}

struct Test {
a: usize,
}

let mut vec_of_struct = [Some(Test { a: 1 }), None];

// Usage of `if let` expression should not trigger lint
for n in vec_of_struct.iter_mut() {
if let Some(z) = n {
*n = None;
}
}

// Using manual flatten should not trigger the lint
for n in vec![Some(1), Some(2), Some(3)].iter().flatten() {
println!("{}", n);
Expand Down

0 comments on commit 711c5cb

Please sign in to comment.