mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user