]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_passes/loops.rs
Rollup merge of #60766 - vorner:weak-into-raw, r=sfackler
[rust.git] / src / librustc_passes / loops.rs
index 533e043efa9d223f4f3f1addc239f21a25d58b46..97bbb0adb2d79ed803e73a0f1619c364b48b04c5 100644 (file)
@@ -8,7 +8,6 @@
 use rustc::hir::map::Map;
 use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
 use rustc::hir::{self, Node, Destination};
-use syntax::ast;
 use syntax::struct_span_err;
 use syntax_pos::Span;
 use errors::Applicability;
@@ -46,12 +45,6 @@ struct CheckLoopVisitor<'a, 'hir: 'a> {
     cx: Context,
 }
 
-pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
-    for &module in tcx.hir().krate().modules.keys() {
-        tcx.ensure().check_mod_loops(tcx.hir().local_def_id(module));
-    }
-}
-
 fn check_mod_loops<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
     tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckLoopVisitor {
         sess: &tcx.sess,
@@ -105,25 +98,25 @@ fn visit_expr(&mut self, e: &'hir hir::Expr) {
 
                 let loop_id = match label.target_id.into() {
                     Ok(loop_id) => loop_id,
-                    Err(hir::LoopIdError::OutsideLoopScope) => ast::DUMMY_NODE_ID,
+                    Err(hir::LoopIdError::OutsideLoopScope) => hir::DUMMY_HIR_ID,
                     Err(hir::LoopIdError::UnlabeledCfInWhileCondition) => {
                         self.emit_unlabled_cf_in_while_condition(e.span, "break");
-                        ast::DUMMY_NODE_ID
+                        hir::DUMMY_HIR_ID
                     },
-                    Err(hir::LoopIdError::UnresolvedLabel) => ast::DUMMY_NODE_ID,
+                    Err(hir::LoopIdError::UnresolvedLabel) => hir::DUMMY_HIR_ID,
                 };
 
-                if loop_id != ast::DUMMY_NODE_ID {
-                    if let Node::Block(_) = self.hir_map.find(loop_id).unwrap() {
+                if loop_id != hir::DUMMY_HIR_ID {
+                    if let Node::Block(_) = self.hir_map.find_by_hir_id(loop_id).unwrap() {
                         return
                     }
                 }
 
                 if opt_expr.is_some() {
-                    let loop_kind = if loop_id == ast::DUMMY_NODE_ID {
+                    let loop_kind = if loop_id == hir::DUMMY_HIR_ID {
                         None
                     } else {
-                        Some(match self.hir_map.expect_expr(loop_id).node {
+                        Some(match self.hir_map.expect_expr_by_hir_id(loop_id).node {
                             hir::ExprKind::While(..) => LoopKind::WhileLoop,
                             hir::ExprKind::Loop(_, _, source) => LoopKind::Loop(source),
                             ref r => span_bug!(e.span,
@@ -162,7 +155,7 @@ fn visit_expr(&mut self, e: &'hir hir::Expr) {
 
                 match destination.target_id {
                     Ok(loop_id) => {
-                        if let Node::Block(block) = self.hir_map.find(loop_id).unwrap() {
+                        if let Node::Block(block) = self.hir_map.find_by_hir_id(loop_id).unwrap() {
                             struct_span_err!(self.sess, e.span, E0696,
                                             "`continue` pointing to a labeled block")
                                 .span_label(e.span,