]> git.lizzy.rs Git - rust.git/commitdiff
rustup
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 27 Feb 2017 08:45:02 +0000 (09:45 +0100)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 27 Feb 2017 08:45:02 +0000 (09:45 +0100)
clippy_lints/src/loops.rs
clippy_lints/src/unused_label.rs
clippy_lints/src/utils/hir.rs
clippy_lints/src/utils/mod.rs

index 734f832d51eb62e16853c2c9081a3b17db99286c..dd9ec1f6e2388b9aeaf8e8575658491a09737a62 100644 (file)
@@ -1028,7 +1028,7 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> {
 /// Return true if expr contains a single break expr (maybe within a block).
 fn is_break_expr(expr: &Expr) -> bool {
     match expr.node {
-        ExprBreak(None, _) => true,
+        ExprBreak(dest, _) if dest.ident.is_none() => true,
         ExprBlock(ref b) => {
             match extract_first_expr(b) {
                 Some(subexpr) => is_break_expr(subexpr),
index c74554d5083b4f0de1175f4b48a44fe3fd90a6a2..e004b80323e70f4c518b035e93127d1e5e8c38e2 100644 (file)
@@ -69,9 +69,11 @@ fn check_fn(
 impl<'a, 'tcx: 'a> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> {
     fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
         match expr.node {
-            hir::ExprBreak(Some(label), _) |
-            hir::ExprAgain(Some(label)) => {
-                self.labels.remove(&label.name.as_str());
+            hir::ExprBreak(destination, _) |
+            hir::ExprAgain(destination) => {
+                if let Some(label) = destination.ident {
+                    self.labels.remove(&label.node.name.as_str());
+                }
             },
             hir::ExprLoop(_, Some(label), _) |
             hir::ExprWhile(_, _, Some(label)) => {
index 2c5c19b2185d4e081bd2f637398f44f909ebdafd..8421e8efd5e8e2bd8d6763095d0c787de2f54350 100644 (file)
@@ -68,7 +68,7 @@ pub fn eq_expr(&self, left: &Expr, right: &Expr) -> bool {
 
         match (&left.node, &right.node) {
             (&ExprAddrOf(l_mut, ref le), &ExprAddrOf(r_mut, ref re)) => l_mut == r_mut && self.eq_expr(le, re),
-            (&ExprAgain(li), &ExprAgain(ri)) => both(&li, &ri, |l, r| l.name.as_str() == r.name.as_str()),
+            (&ExprAgain(li), &ExprAgain(ri)) => both(&li.ident, &ri.ident, |l, r| l.node.name.as_str() == r.node.name.as_str()),
             (&ExprAssign(ref ll, ref lr), &ExprAssign(ref rl, ref rr)) => self.eq_expr(ll, rl) && self.eq_expr(lr, rr),
             (&ExprAssignOp(ref lo, ref ll, ref lr), &ExprAssignOp(ref ro, ref rl, ref rr)) => {
                 lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
@@ -81,7 +81,7 @@ pub fn eq_expr(&self, left: &Expr, right: &Expr) -> bool {
                 })
             },
             (&ExprBreak(li, ref le), &ExprBreak(ri, ref re)) => {
-                both(&li, &ri, |l, r| l.name.as_str() == r.name.as_str()) && both(le, re, |l, r| self.eq_expr(l, r))
+                both(&li.ident, &ri.ident, |l, r| l.node.name.as_str() == r.node.name.as_str()) && both(le, re, |l, r| self.eq_expr(l, r))
             },
             (&ExprBox(ref l), &ExprBox(ref r)) => self.eq_expr(l, r),
             (&ExprCall(ref l_fun, ref l_args), &ExprCall(ref r_fun, ref r_args)) => {
@@ -310,8 +310,8 @@ pub fn hash_expr(&mut self, e: &Expr) {
             ExprAgain(i) => {
                 let c: fn(_) -> _ = ExprAgain;
                 c.hash(&mut self.s);
-                if let Some(i) = i {
-                    self.hash_name(&i.name);
+                if let Some(i) = i.ident {
+                    self.hash_name(&i.node.name);
                 }
             },
             ExprAssign(ref l, ref r) => {
@@ -342,8 +342,8 @@ pub fn hash_expr(&mut self, e: &Expr) {
             ExprBreak(i, ref j) => {
                 let c: fn(_, _) -> _ = ExprBreak;
                 c.hash(&mut self.s);
-                if let Some(i) = i {
-                    self.hash_name(&i.name);
+                if let Some(i) = i.ident {
+                    self.hash_name(&i.node.name);
                 }
                 if let Some(ref j) = *j {
                     self.hash_expr(&*j);
index 25b3ad3bfb9c337a9bf63a2aac462e61e9902538..2dae1cf1723cc2f8f6b83bafe1088b69b4ad7d07 100644 (file)
@@ -900,7 +900,7 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {
         Def::AssociatedConst(id) |
         Def::Local(id) |
         Def::Upvar(id, ..) |
-        Def::Macro(id) => Some(id),
+        Def::Macro(id, _) => Some(id),
 
         Def::Label(..) | Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => None,
     }