diff options
| author | tamaron <tamaron1203@gmail.com> | 2022-08-11 12:00:46 +0900 |
|---|---|---|
| committer | tamaron <tamaron1203@gmail.com> | 2022-08-11 15:07:39 +0900 |
| commit | 45084eeefb4edb981ce437c7fee6a07e61ff224b (patch) | |
| tree | 407d832b48e0e30ab9087885ca0b80c21d82071f /tests | |
| parent | 459821b1914248180cac691128dd35d945bfde88 (diff) | |
| download | rust-45084eeefb4edb981ce437c7fee6a07e61ff224b.tar.gz rust-45084eeefb4edb981ce437c7fee6a07e61ff224b.zip | |
give up when gurad has side effects
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/needless_match.fixed | 15 | ||||
| -rw-r--r-- | tests/ui/needless_match.rs | 15 |
2 files changed, 28 insertions, 2 deletions
diff --git a/tests/ui/needless_match.fixed b/tests/ui/needless_match.fixed index 9d4427f1df2..7e47406798c 100644 --- a/tests/ui/needless_match.fixed +++ b/tests/ui/needless_match.fixed @@ -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, + }; } } diff --git a/tests/ui/needless_match.rs b/tests/ui/needless_match.rs index cae850fb059..809c694bf40 100644 --- a/tests/ui/needless_match.rs +++ b/tests/ui/needless_match.rs @@ -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, + }; } } |
