Skip to content

Commit 711c5cb

Browse files
committed
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`.
1 parent 3f0c977 commit 711c5cb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/ui/manual_flatten.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ fn main() {
9191
}
9292
}
9393

94+
struct Test {
95+
a: usize,
96+
}
97+
98+
let mut vec_of_struct = [Some(Test { a: 1 }), None];
99+
100+
// Usage of `if let` expression should not trigger lint
101+
for n in vec_of_struct.iter_mut() {
102+
if let Some(z) = n {
103+
*n = None;
104+
}
105+
}
106+
94107
// Using manual flatten should not trigger the lint
95108
for n in vec![Some(1), Some(2), Some(3)].iter().flatten() {
96109
println!("{}", n);

0 commit comments

Comments
 (0)