]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/infer/error_reporting.rs
Auto merge of #39309 - eddyb:map-shmap, r=nikomatsakis
[rust.git] / src / librustc / infer / error_reporting.rs
index d859a8b44db0c2af41723e3889427d3042cede3c..23106d2bdc7d36f8373f77ec5651a46562cb7dd9 100644 (file)
@@ -73,7 +73,7 @@
 
 use std::collections::HashSet;
 
-use hir::map as ast_map;
+use hir::map as hir_map;
 use hir;
 
 use lint;
@@ -144,16 +144,16 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                     format!("{}unknown scope: {:?}{}.  Please report a bug.",
                             prefix, scope, suffix)
                 };
-                let span = match scope.span(&self.region_maps, &self.map) {
+                let span = match scope.span(&self.region_maps, &self.hir) {
                     Some(s) => s,
                     None => {
                         err.note(&unknown_scope());
                         return;
                     }
                 };
-                let tag = match self.map.find(scope.node_id(&self.region_maps)) {
-                    Some(ast_map::NodeBlock(_)) => "block",
-                    Some(ast_map::NodeExpr(expr)) => match expr.node {
+                let tag = match self.hir.find(scope.node_id(&self.region_maps)) {
+                    Some(hir_map::NodeBlock(_)) => "block",
+                    Some(hir_map::NodeExpr(expr)) => match expr.node {
                         hir::ExprCall(..) => "call",
                         hir::ExprMethodCall(..) => "method call",
                         hir::ExprMatch(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
@@ -162,10 +162,10 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                         hir::ExprMatch(..) => "match",
                         _ => "expression",
                     },
-                    Some(ast_map::NodeStmt(_)) => "statement",
-                    Some(ast_map::NodeItem(it)) => item_scope_tag(&it),
-                    Some(ast_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
-                    Some(ast_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
+                    Some(hir_map::NodeStmt(_)) => "statement",
+                    Some(hir_map::NodeItem(it)) => item_scope_tag(&it),
+                    Some(hir_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
+                    Some(hir_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
                     Some(_) | None => {
                         err.span_note(span, &unknown_scope());
                         return;
@@ -206,19 +206,19 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
 
                 let node = fr.scope.node_id(&self.region_maps);
                 let unknown;
-                let tag = match self.map.find(node) {
-                    Some(ast_map::NodeBlock(_)) |
-                    Some(ast_map::NodeExpr(_)) => "body",
-                    Some(ast_map::NodeItem(it)) => item_scope_tag(&it),
-                    Some(ast_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
-                    Some(ast_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
+                let tag = match self.hir.find(node) {
+                    Some(hir_map::NodeBlock(_)) |
+                    Some(hir_map::NodeExpr(_)) => "body",
+                    Some(hir_map::NodeItem(it)) => item_scope_tag(&it),
+                    Some(hir_map::NodeTraitItem(it)) => trait_item_scope_tag(&it),
+                    Some(hir_map::NodeImplItem(it)) => impl_item_scope_tag(&it),
 
                     // this really should not happen, but it does:
                     // FIXME(#27942)
                     Some(_) => {
                         unknown = format!("unexpected node ({}) for scope {:?}.  \
                                            Please report a bug.",
-                                          self.map.node_to_string(node), fr.scope);
+                                          self.hir.node_to_string(node), fr.scope);
                         &unknown
                     }
                     None => {
@@ -227,7 +227,7 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                         &unknown
                     }
                 };
-                let (msg, opt_span) = explain_span(self, tag, self.map.span(node));
+                let (msg, opt_span) = explain_span(self, tag, self.hir.span(node));
                 (format!("{} {}", prefix, msg), opt_span)
             }
 
@@ -467,18 +467,18 @@ fn free_regions_from_same_fn<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                 },
                 _ => return None
             };
-            let parent = tcx.map.get_parent(scope_id);
-            let parent_node = tcx.map.find(parent);
+            let parent = tcx.hir.get_parent(scope_id);
+            let parent_node = tcx.hir.find(parent);
             match parent_node {
                 Some(node) => match node {
-                    ast_map::NodeItem(item) => match item.node {
+                    hir_map::NodeItem(item) => match item.node {
                         hir::ItemFn(..) => {
                             Some(FreeRegionsFromSameFn::new(fr1, fr2, scope_id))
                         },
                         _ => None
                     },
-                    ast_map::NodeImplItem(..) |
-                    ast_map::NodeTraitItem(..) => {
+                    hir_map::NodeImplItem(..) |
+                    hir_map::NodeTraitItem(..) => {
                         Some(FreeRegionsFromSameFn::new(fr1, fr2, scope_id))
                     },
                     _ => None
@@ -1071,13 +1071,13 @@ fn report_processed_errors(&self,
 
     fn give_suggestion(&self, err: &mut DiagnosticBuilder, same_regions: &[SameRegions]) {
         let scope_id = same_regions[0].scope_id;
-        let parent = self.tcx.map.get_parent(scope_id);
-        let parent_node = self.tcx.map.find(parent);
+        let parent = self.tcx.hir.get_parent(scope_id);
+        let parent_node = self.tcx.hir.find(parent);
         let taken = lifetimes_in_scope(self.tcx, scope_id);
         let life_giver = LifeGiver::with_taken(&taken[..]);
         let node_inner = match parent_node {
             Some(ref node) => match *node {
-                ast_map::NodeItem(ref item) => {
+                hir_map::NodeItem(ref item) => {
                     match item.node {
                         hir::ItemFn(ref fn_decl, unsafety, constness, _, ref gen, body) => {
                             Some((fn_decl, gen, unsafety, constness, item.name, item.span, body))
@@ -1085,9 +1085,9 @@ fn give_suggestion(&self, err: &mut DiagnosticBuilder, same_regions: &[SameRegio
                         _ => None,
                     }
                 }
-                ast_map::NodeImplItem(item) => {
-                    let id = self.tcx.map.get_parent(item.id);
-                    if let Some(ast_map::NodeItem(parent_scope)) = self.tcx.map.find(id) {
+                hir_map::NodeImplItem(item) => {
+                    let id = self.tcx.hir.get_parent(item.id);
+                    if let Some(hir_map::NodeItem(parent_scope)) = self.tcx.hir.find(id) {
                         if let hir::ItemImpl(_, _, _, None, _, _) = parent_scope.node {
                             // this impl scope implements a trait, do not recomend
                             // using explicit lifetimes (#37363)
@@ -1106,7 +1106,7 @@ fn give_suggestion(&self, err: &mut DiagnosticBuilder, same_regions: &[SameRegio
                         None
                     }
                 },
-                ast_map::NodeTraitItem(item) => {
+                hir_map::NodeTraitItem(item) => {
                     match item.node {
                         hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
                             Some((&sig.decl,
@@ -1657,7 +1657,7 @@ fn give_expl_lifetime_param(&self,
                                 generics: &hir::Generics,
                                 span: Span,
                                 body: hir::BodyId) {
-        let s = hir::print::to_string(&self.tcx.map, |s| {
+        let s = hir::print::to_string(&self.tcx.hir, |s| {
             use syntax::abi::Abi;
             use syntax::print::pprust::PrintState;
 
@@ -1894,17 +1894,17 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                                       scope_id: ast::NodeId)
                                       -> Vec<hir::LifetimeDef> {
     let mut taken = Vec::new();
-    let parent = tcx.map.get_parent(scope_id);
-    let method_id_opt = match tcx.map.find(parent) {
+    let parent = tcx.hir.get_parent(scope_id);
+    let method_id_opt = match tcx.hir.find(parent) {
         Some(node) => match node {
-            ast_map::NodeItem(item) => match item.node {
+            hir_map::NodeItem(item) => match item.node {
                 hir::ItemFn(.., ref gen, _) => {
                     taken.extend_from_slice(&gen.lifetimes);
                     None
                 },
                 _ => None
             },
-            ast_map::NodeImplItem(ii) => {
+            hir_map::NodeImplItem(ii) => {
                 match ii.node {
                     hir::ImplItemKind::Method(ref sig, _) => {
                         taken.extend_from_slice(&sig.generics.lifetimes);
@@ -1918,10 +1918,10 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
         None => None
     };
     if let Some(method_id) = method_id_opt {
-        let parent = tcx.map.get_parent(method_id);
-        if let Some(node) = tcx.map.find(parent) {
+        let parent = tcx.hir.get_parent(method_id);
+        if let Some(node) = tcx.hir.find(parent) {
             match node {
-                ast_map::NodeItem(item) => match item.node {
+                hir_map::NodeItem(item) => match item.node {
                     hir::ItemImpl(_, _, ref gen, ..) => {
                         taken.extend_from_slice(&gen.lifetimes);
                     }