manual_filter: add a related test

The related issue is #9766 where the `manual_filter`
lint would remove side effects
This commit is contained in:
Eric Wu 2022-12-16 09:29:32 -05:00
parent 5b3a6669f7
commit 3c14075b46
2 changed files with 28 additions and 0 deletions

View file

@ -139,6 +139,20 @@ fn main() {
} else {
None
};
let allowed_integers = vec![3, 4, 5, 6];
// Don't lint, since there's a side effect in the else branch
match Some(21) {
Some(x) => {
if allowed_integers.contains(&x) {
Some(x)
} else {
println!("Invalid integer: {x:?}");
None
}
},
None => None,
};
}
fn maybe_some() -> Option<u32> {

View file

@ -263,6 +263,20 @@ fn main() {
} else {
None
};
let allowed_integers = vec![3, 4, 5, 6];
// Don't lint, since there's a side effect in the else branch
match Some(21) {
Some(x) => {
if allowed_integers.contains(&x) {
Some(x)
} else {
println!("Invalid integer: {x:?}");
None
}
},
None => None,
};
}
fn maybe_some() -> Option<u32> {