summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/needless_match.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/needless_match.rs')
-rw-r--r--src/tools/clippy/tests/ui/needless_match.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/needless_match.rs b/src/tools/clippy/tests/ui/needless_match.rs
index f66f01d7c..809c694bf 100644
--- a/src/tools/clippy/tests/ui/needless_match.rs
+++ b/src/tools/clippy/tests/ui/needless_match.rs
@@ -244,4 +244,50 @@ impl Tr for Result<i32, i32> {
}
}
+mod issue9084 {
+ fn wildcard_if() {
+ let mut some_bool = true;
+ let e = Some(1);
+
+ // should lint
+ let _ = match e {
+ _ if some_bool => e,
+ _ => e,
+ };
+
+ // should lint
+ let _ = match e {
+ Some(i) => Some(i),
+ _ if some_bool => e,
+ _ => e,
+ };
+
+ // should not lint
+ let _ = match e {
+ _ if some_bool => e,
+ _ => Some(2),
+ };
+
+ // should not lint
+ let _ = match e {
+ Some(i) => Some(i + 1),
+ _ 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,
+ };
+ }
+}
+
fn main() {}