mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
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:
parent
5b3a6669f7
commit
3c14075b46
2 changed files with 28 additions and 0 deletions
|
@ -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> {
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue