give up when gurad has side effects

This commit is contained in:
tamaron 2022-08-11 12:00:46 +09:00
parent 459821b191
commit 45084eeefb
3 changed files with 45 additions and 3 deletions

View file

@ -209,7 +209,7 @@ impl Tr for Result<i32, i32> {
mod issue9084 {
fn wildcard_if() {
let some_bool = true;
let mut some_bool = true;
let e = Some(1);
// should lint
@ -230,6 +230,19 @@ mod issue9084 {
_ if some_bool => e,
_ => e,
};
// should not lint (guard has side effects)
let _ = match e {
Some(i) => Some(i),
_ if {
some_bool = false;
some_bool
} =>
{
e
},
_ => e,
};
}
}

View file

@ -246,7 +246,7 @@ impl Tr for Result<i32, i32> {
mod issue9084 {
fn wildcard_if() {
let some_bool = true;
let mut some_bool = true;
let e = Some(1);
// should lint
@ -274,6 +274,19 @@ mod issue9084 {
_ if some_bool => e,
_ => e,
};
// should not lint (guard has side effects)
let _ = match e {
Some(i) => Some(i),
_ if {
some_bool = false;
some_bool
} =>
{
e
},
_ => e,
};
}
}