Add false positive test for manual_flatten

Add a scenario where `manual_flatten` is triggered when match expression will still be used after the match in `if let`.
This commit is contained in:
dswij 2021-08-14 16:59:08 +08:00
parent 3f0c97740f
commit 711c5cb6d2

View file

@ -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);