]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_alternatives.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / pattern_type_mismatch / pattern_alternatives.rs
diff --git a/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_alternatives.rs b/src/tools/clippy/tests/ui/pattern_type_mismatch/pattern_alternatives.rs
new file mode 100644 (file)
index 0000000..065ea9f
--- /dev/null
@@ -0,0 +1,24 @@
+#![allow(clippy::all)]
+#![warn(clippy::pattern_type_mismatch)]
+
+fn main() {}
+
+fn alternatives() {
+    enum Value<'a> {
+        Unused,
+        A(&'a Option<i32>),
+        B,
+    }
+    let ref_value = &Value::A(&Some(23));
+
+    // not ok
+    if let Value::B | Value::A(_) = ref_value {}
+    if let &Value::B | &Value::A(Some(_)) = ref_value {}
+    if let Value::B | Value::A(Some(_)) = *ref_value {}
+
+    // ok
+    if let &Value::B | &Value::A(_) = ref_value {}
+    if let Value::B | Value::A(_) = *ref_value {}
+    if let &Value::B | &Value::A(&Some(_)) = ref_value {}
+    if let Value::B | Value::A(&Some(_)) = *ref_value {}
+}