]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/eval_order_dependence.rs
Auto merge of #4551 - mikerite:fix-ice-reporting, r=llogiq
[rust.git] / clippy_lints / src / eval_order_dependence.rs
index a62bb3cda9b6e893043071e4362946b3f16a5530..b915d50671b3b017390f2c7d1fc57a17c93bb003 100644 (file)
@@ -42,7 +42,9 @@
     /// shorthand.
     ///
     /// **Example:**
-    /// ```rust
+    /// ```rust,no_run
+    /// # fn b() -> bool { true }
+    /// # fn c() -> bool { true }
     /// let a = b() || panic!() || c();
     /// // `c()` is dead, `panic!()` is only called if `b()` returns `false`
     /// let x = (a, b, c, panic!());
@@ -63,7 +65,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
                 if let ExprKind::Path(ref qpath) = lhs.node {
                     if let QPath::Resolved(_, ref path) = *qpath {
                         if path.segments.len() == 1 {
-                            if let def::Def::Local(var) = cx.tables.qpath_def(qpath, lhs.hir_id) {
+                            if let def::Res::Local(var) = cx.tables.qpath_res(qpath, lhs.hir_id) {
                                 let mut visitor = ReadVisitor {
                                     cx,
                                     var,
@@ -92,7 +94,7 @@ fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
     }
 }
 
-struct DivergenceVisitor<'a, 'tcx: 'a> {
+struct DivergenceVisitor<'a, 'tcx> {
     cx: &'a LateContext<'a, 'tcx>,
 }
 
@@ -176,11 +178,11 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
     let map = &vis.cx.tcx.hir();
     let mut cur_id = vis.write_expr.hir_id;
     loop {
-        let parent_id = map.get_parent_node_by_hir_id(cur_id);
+        let parent_id = map.get_parent_node(cur_id);
         if parent_id == cur_id {
             break;
         }
-        let parent_node = match map.find_by_hir_id(parent_id) {
+        let parent_node = match map.find(parent_id) {
             Some(parent) => parent,
             None => break,
         };
@@ -272,7 +274,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St
 }
 
 /// A visitor that looks for reads from a variable.
-struct ReadVisitor<'a, 'tcx: 'a> {
+struct ReadVisitor<'a, 'tcx> {
     cx: &'a LateContext<'a, 'tcx>,
     /// The ID of the variable we're looking for.
     var: HirId,
@@ -295,7 +297,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr) {
                 if_chain! {
                     if let QPath::Resolved(None, ref path) = *qpath;
                     if path.segments.len() == 1;
-                    if let def::Def::Local(local_id) = self.cx.tables.qpath_def(qpath, expr.hir_id);
+                    if let def::Res::Local(local_id) = self.cx.tables.qpath_res(qpath, expr.hir_id);
                     if local_id == self.var;
                     // Check that this is a read, not a write.
                     if !is_in_assignment_position(self.cx, expr);