]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/utils/hir_utils.rs
Run rustfmt
[rust.git] / clippy_lints / src / utils / hir_utils.rs
index 658a07ca146813df8c4de5936cb74d8365f8ba0c..0b3f409adf44dda5493c0e7133e5b5c052ff0739 100644 (file)
@@ -23,14 +23,14 @@ pub struct SpanlessEq<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
     pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
-        SpanlessEq {
+        Self {
             cx: cx,
             ignore_fn: false,
         }
     }
 
     pub fn ignore_fn(self) -> Self {
-        SpanlessEq {
+        Self {
             cx: self.cx,
             ignore_fn: true,
         }
@@ -195,18 +195,19 @@ fn eq_path(&self, left: &Path, right: &Path) -> bool {
     }
 
     fn eq_path_parameters(&self, left: &PathParameters, right: &PathParameters) -> bool {
-        match (left, right) {
-            (&AngleBracketedParameters(ref left), &AngleBracketedParameters(ref right)) => {
-                over(&left.lifetimes, &right.lifetimes, |l, r| self.eq_lifetime(l, r)) &&
-                    over(&left.types, &right.types, |l, r| self.eq_ty(l, r)) &&
-                    over(&left.bindings, &right.bindings, |l, r| self.eq_type_binding(l, r))
-            },
-            (&ParenthesizedParameters(ref left), &ParenthesizedParameters(ref right)) => {
-                over(&left.inputs, &right.inputs, |l, r| self.eq_ty(l, r)) &&
-                    both(&left.output, &right.output, |l, r| self.eq_ty(l, r))
-            },
-            (&AngleBracketedParameters(_), &ParenthesizedParameters(_)) |
-            (&ParenthesizedParameters(_), &AngleBracketedParameters(_)) => false,
+        if !(left.parenthesized || right.parenthesized) {
+            over(&left.lifetimes, &right.lifetimes, |l, r| self.eq_lifetime(l, r)) &&
+                over(&left.types, &right.types, |l, r| self.eq_ty(l, r)) &&
+                over(&left.bindings, &right.bindings, |l, r| self.eq_type_binding(l, r))
+        } else if left.parenthesized && right.parenthesized {
+            over(left.inputs(), right.inputs(), |l, r| self.eq_ty(l, r)) &&
+                both(
+                    &Some(&left.bindings[0].ty),
+                    &Some(&right.bindings[0].ty),
+                    |l, r| self.eq_ty(l, r),
+                )
+        } else {
+            false
         }
     }
 
@@ -283,7 +284,7 @@ pub struct SpanlessHash<'a, 'tcx: 'a> {
 
 impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
     pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
-        SpanlessHash {
+        Self {
             cx: cx,
             s: DefaultHasher::new(),
         }
@@ -324,6 +325,11 @@ pub fn hash_expr(&mut self, e: &Expr) {
                     self.hash_name(&i.node.name);
                 }
             },
+            ExprYield(ref e) => {
+                let c: fn(_) -> _ = ExprYield;
+                c.hash(&mut self.s);
+                self.hash_expr(e);
+            },
             ExprAssign(ref l, ref r) => {
                 let c: fn(_, _) -> _ = ExprAssign;
                 c.hash(&mut self.s);
@@ -376,8 +382,8 @@ pub fn hash_expr(&mut self, e: &Expr) {
                 self.hash_expr(e);
                 // TODO: _ty
             },
-            ExprClosure(cap, _, eid, _) => {
-                let c: fn(_, _, _, _) -> _ = ExprClosure;
+            ExprClosure(cap, _, eid, _, _) => {
+                let c: fn(_, _, _, _, _) -> _ = ExprClosure;
                 c.hash(&mut self.s);
                 cap.hash(&mut self.s);
                 self.hash_expr(&self.cx.tcx.hir.body(eid).value);