]> git.lizzy.rs Git - rust.git/commitdiff
added missing PatKind::Path + tests
authorAndre Bogus <bogusandre@gmail.com>
Tue, 31 May 2016 20:01:56 +0000 (22:01 +0200)
committermcarton <cartonmartin+git@gmail.com>
Tue, 31 May 2016 21:35:42 +0000 (23:35 +0200)
clippy_lints/src/matches.rs
clippy_lints/src/utils/hir.rs
tests/compile-fail/matches.rs

index 4d1d9ac3ffa3fe12f8d9e63aceb988c596fd9883..46bd251016b6d41ae52626968ab5b5088f6f6803 100644 (file)
@@ -201,6 +201,7 @@ fn check_single_match_opt_like(cx: &LateContext, ex: &Expr, arms: &[Arm], expr:
             path.to_string()
         }
         PatKind::Binding(BindByValue(MutImmutable), ident, None) => ident.node.to_string(),
+        PatKind::Path(ref path) => path.to_string(),
         _ => return,
     };
 
index 95028376dcae0b631aefee01712043eb7a8dbf32..e9c4023e22604f9ff17b6d6d612049e90f823b6a 100644 (file)
@@ -148,6 +148,7 @@ pub fn eq_pat(&self, left: &Pat, right: &Pat) -> bool {
             (&PatKind::Binding(ref lb, ref li, ref lp), &PatKind::Binding(ref rb, ref ri, ref rp)) => {
                 lb == rb && li.node.as_str() == ri.node.as_str() && both(lp, rp, |l, r| self.eq_pat(l, r))
             }
+            (&PatKind::Path(ref l), &PatKind::Path(ref r)) => self.eq_path(l, r),
             (&PatKind::Lit(ref l), &PatKind::Lit(ref r)) => self.eq_expr(l, r),
             (&PatKind::QPath(ref ls, ref lp), &PatKind::QPath(ref rs, ref rp)) => {
                 self.eq_qself(ls, rs) && self.eq_path(lp, rp)
index 3444e49ec513604e0198916834eb6dacc5c5426a..affa7e4e86e6e76ab7a24e77eb920d4016451865 100644 (file)
@@ -216,6 +216,12 @@ fn overlapping() {
         11 ... 50 => println!("0 ... 10"),
         _ => (),
     }
+    
+    if let None = Some(42) {
+        // nothing
+    } else if let None = Some(42) {
+        // another nothing :-)
+    }
 }
 
 fn main() {