give up when gurad has side effects
This commit is contained in:
parent
459821b191
commit
45084eeefb
3 changed files with 45 additions and 3 deletions
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue