From 45c8c5678a3065c5d1f75b2413bd800a792cf3d9 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 26 Jan 2017 02:41:06 +0200 Subject: [PATCH 1/2] rustc: rename TyCtxt's `map` field to `hir`. --- src/librustc/cfg/construct.rs | 6 +- src/librustc/dep_graph/dep_node.rs | 4 +- src/librustc/dep_graph/dep_tracking_map.rs | 2 +- src/librustc/dep_graph/visit.rs | 8 +- src/librustc/hir/itemlikevisit.rs | 2 +- src/librustc/infer/error_reporting.rs | 32 ++--- src/librustc/infer/mod.rs | 10 +- src/librustc/lint/context.rs | 10 +- src/librustc/middle/dataflow.rs | 2 +- src/librustc/middle/dead.rs | 20 +-- src/librustc/middle/effect.rs | 6 +- src/librustc/middle/expr_use_visitor.rs | 4 +- src/librustc/middle/intrinsicck.rs | 2 +- src/librustc/middle/liveness.rs | 22 +-- src/librustc/middle/mem_categorization.rs | 12 +- src/librustc/middle/reachable.rs | 30 ++-- src/librustc/middle/stability.rs | 26 ++-- src/librustc/mir/mod.rs | 6 +- src/librustc/mir/transform.rs | 6 +- src/librustc/traits/error_reporting.rs | 6 +- src/librustc/ty/context.rs | 12 +- src/librustc/ty/error.rs | 4 +- .../ty/inhabitedness/def_id_forest.rs | 2 +- src/librustc/ty/item_path.rs | 6 +- src/librustc/ty/mod.rs | 80 +++++------ src/librustc/util/ppaux.rs | 8 +- src/librustc_borrowck/borrowck/check_loans.rs | 4 +- src/librustc_borrowck/borrowck/fragments.rs | 6 +- .../borrowck/gather_loans/mod.rs | 4 +- src/librustc_borrowck/borrowck/mir/mod.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 40 +++--- src/librustc_const_eval/check_match.rs | 8 +- src/librustc_const_eval/eval.rs | 36 ++--- src/librustc_const_eval/pattern.rs | 2 +- src/librustc_driver/driver.rs | 2 +- src/librustc_driver/pretty.rs | 16 +-- src/librustc_driver/test.rs | 4 +- src/librustc_incremental/assert_dep_graph.rs | 6 +- src/librustc_incremental/calculate_svh/mod.rs | 6 +- .../calculate_svh/svh_visitor.rs | 2 +- .../persist/dirty_clean.rs | 8 +- src/librustc_lint/bad_style.rs | 2 +- src/librustc_lint/builtin.rs | 32 ++--- src/librustc_lint/types.rs | 6 +- src/librustc_lint/unused.rs | 2 +- src/librustc_metadata/astencode.rs | 4 +- src/librustc_metadata/cstore_impl.rs | 2 +- src/librustc_metadata/decoder.rs | 2 +- src/librustc_metadata/encoder.rs | 60 ++++---- src/librustc_metadata/index_builder.rs | 6 +- src/librustc_mir/build/block.rs | 2 +- src/librustc_mir/build/mod.rs | 10 +- src/librustc_mir/build/scope.rs | 2 +- src/librustc_mir/graphviz.rs | 2 +- src/librustc_mir/hair/cx/expr.rs | 12 +- src/librustc_mir/hair/cx/mod.rs | 4 +- src/librustc_mir/mir_map.rs | 12 +- src/librustc_mir/pretty.rs | 4 +- src/librustc_mir/transform/copy_prop.rs | 2 +- src/librustc_mir/transform/deaggregator.rs | 2 +- src/librustc_mir/transform/qualify_consts.rs | 14 +- src/librustc_passes/consts.rs | 14 +- src/librustc_passes/rvalues.rs | 2 +- src/librustc_privacy/lib.rs | 72 +++++----- src/librustc_save_analysis/dump_visitor.rs | 20 +-- src/librustc_save_analysis/external_data.rs | 80 +++++------ src/librustc_save_analysis/lib.rs | 22 +-- src/librustc_trans/assert_module_sources.rs | 2 +- src/librustc_trans/back/symbol_export.rs | 6 +- src/librustc_trans/back/symbol_names.rs | 4 +- src/librustc_trans/base.rs | 10 +- src/librustc_trans/collector.rs | 26 ++-- src/librustc_trans/consts.rs | 6 +- src/librustc_trans/debuginfo/gdb.rs | 2 +- src/librustc_trans/debuginfo/metadata.rs | 2 +- src/librustc_trans/debuginfo/mod.rs | 2 +- src/librustc_trans/declare.rs | 2 +- src/librustc_trans/partitioning.rs | 6 +- src/librustc_trans/symbol_map.rs | 4 +- src/librustc_trans/symbol_names_test.rs | 4 +- src/librustc_trans/trans_item.rs | 16 +-- src/librustc_typeck/astconv.rs | 22 +-- src/librustc_typeck/check/_match.rs | 6 +- src/librustc_typeck/check/callee.rs | 6 +- src/librustc_typeck/check/closure.rs | 4 +- src/librustc_typeck/check/compare_method.rs | 48 +++---- src/librustc_typeck/check/dropck.rs | 10 +- src/librustc_typeck/check/intrinsic.rs | 4 +- src/librustc_typeck/check/method/probe.rs | 2 +- src/librustc_typeck/check/method/suggest.rs | 10 +- src/librustc_typeck/check/mod.rs | 70 +++++----- src/librustc_typeck/check/regionck.rs | 4 +- src/librustc_typeck/check/upvar.rs | 10 +- src/librustc_typeck/check/wfcheck.rs | 20 +-- src/librustc_typeck/check/writeback.rs | 12 +- src/librustc_typeck/check_unused.rs | 2 +- src/librustc_typeck/coherence/builtin.rs | 20 +-- src/librustc_typeck/coherence/mod.rs | 2 +- src/librustc_typeck/coherence/orphan.rs | 10 +- src/librustc_typeck/coherence/overlap.rs | 10 +- src/librustc_typeck/coherence/unsafety.rs | 4 +- src/librustc_typeck/collect.rs | 128 +++++++++--------- src/librustc_typeck/impl_wf_check.rs | 6 +- src/librustc_typeck/lib.rs | 8 +- src/librustc_typeck/variance/constraints.rs | 26 ++-- src/librustc_typeck/variance/solve.rs | 4 +- src/librustc_typeck/variance/terms.rs | 8 +- src/librustdoc/clean/mod.rs | 74 +++++----- src/librustdoc/core.rs | 6 +- src/librustdoc/visit_ast.rs | 24 ++-- .../issue-37290/auxiliary/lint.rs | 4 +- 111 files changed, 761 insertions(+), 761 deletions(-) diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 6f2b9ca0c4220..595059332895d 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -46,18 +46,18 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Find the function this expression is from. let mut node_id = body.id; loop { - let node = tcx.map.get(node_id); + let node = tcx.hir.get(node_id); if hir::map::blocks::FnLikeNode::from_node(node).is_some() { break; } - let parent = tcx.map.get_parent_node(node_id); + let parent = tcx.hir.get_parent_node(node_id); assert!(node_id != parent); node_id = parent; } let mut cfg_builder = CFGBuilder { tcx: tcx, - tables: tcx.item_tables(tcx.map.local_def_id(node_id)), + tables: tcx.item_tables(tcx.hir.local_def_id(node_id)), graph: graph, fn_exit: fn_exit, loop_scopes: Vec::new() diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index d9fd0b9a1f939..df6db366df5b3 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -29,10 +29,10 @@ pub enum DepNode { // Represents the `Krate` as a whole (the `hir::Krate` value) (as // distinct from the krate module). This is basically a hash of // the entire krate, so if you read from `Krate` (e.g., by calling - // `tcx.map.krate()`), we will have to assume that any change + // `tcx.hir.krate()`), we will have to assume that any change // means that you need to be recompiled. This is because the // `Krate` value gives you access to all other items. To avoid - // this fate, do not call `tcx.map.krate()`; instead, prefer + // this fate, do not call `tcx.hir.krate()`; instead, prefer // wrappers like `tcx.visit_all_items_in_krate()`. If there is no // suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain // access to the krate, but you must remember to add suitable diff --git a/src/librustc/dep_graph/dep_tracking_map.rs b/src/librustc/dep_graph/dep_tracking_map.rs index 50dfe9d22f12f..9660758220368 100644 --- a/src/librustc/dep_graph/dep_tracking_map.rs +++ b/src/librustc/dep_graph/dep_tracking_map.rs @@ -117,7 +117,7 @@ impl MemoizationMap for RefCell> { /// /// ``` /// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> { - /// let item_def_id = ccx.tcx.map.local_def_id(it.id); + /// let item_def_id = ccx.tcx.hir.local_def_id(it.id); /// ccx.tcx.item_types.memoized(item_def_id, || { /// ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); // (*) /// compute_type_of_item(ccx, item) diff --git a/src/librustc/dep_graph/visit.rs b/src/librustc/dep_graph/visit.rs index 1990574ca9a83..f0a81fd1cfd33 100644 --- a/src/librustc/dep_graph/visit.rs +++ b/src/librustc/dep_graph/visit.rs @@ -36,7 +36,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx> where F: FnMut(DefId) -> DepNode, V: ItemLikeVisitor<'tcx> { fn visit_item(&mut self, i: &'tcx hir::Item) { - let item_def_id = self.tcx.map.local_def_id(i.id); + let item_def_id = self.tcx.hir.local_def_id(i.id); let task_id = (self.dep_node_fn)(item_def_id); let _task = self.tcx.dep_graph.in_task(task_id.clone()); debug!("Started task {:?}", task_id); @@ -46,7 +46,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx> } fn visit_trait_item(&mut self, i: &'tcx hir::TraitItem) { - let trait_item_def_id = self.tcx.map.local_def_id(i.id); + let trait_item_def_id = self.tcx.hir.local_def_id(i.id); let task_id = (self.dep_node_fn)(trait_item_def_id); let _task = self.tcx.dep_graph.in_task(task_id.clone()); debug!("Started task {:?}", task_id); @@ -56,7 +56,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx> } fn visit_impl_item(&mut self, i: &'tcx hir::ImplItem) { - let impl_item_def_id = self.tcx.map.local_def_id(i.id); + let impl_item_def_id = self.tcx.hir.local_def_id(i.id); let task_id = (self.dep_node_fn)(impl_item_def_id); let _task = self.tcx.dep_graph.in_task(task_id.clone()); debug!("Started task {:?}", task_id); @@ -66,7 +66,7 @@ pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx> } } - let krate = tcx.dep_graph.with_ignore(|| tcx.map.krate()); + let krate = tcx.dep_graph.with_ignore(|| tcx.hir.krate()); let mut tracking_visitor = TrackingVisitor { tcx: tcx, dep_node_fn: &mut dep_node_fn, diff --git a/src/librustc/hir/itemlikevisit.rs b/src/librustc/hir/itemlikevisit.rs index f359ca2016359..0d79017066b01 100644 --- a/src/librustc/hir/itemlikevisit.rs +++ b/src/librustc/hir/itemlikevisit.rs @@ -44,7 +44,7 @@ use super::intravisit::Visitor; /// - How: Implement `intravisit::Visitor` and override the /// `visit_nested_map()` methods to return /// `NestedVisitorMap::All`. Walk your crate with -/// `intravisit::walk_crate()` invoked on `tcx.map.krate()`. +/// `intravisit::walk_crate()` invoked on `tcx.hir.krate()`. /// - Pro: Visitor methods for any kind of HIR node, not just item-like things. /// - Pro: Preserves nesting information /// - Con: Does not integrate well into dependency tracking. diff --git a/src/librustc/infer/error_reporting.rs b/src/librustc/infer/error_reporting.rs index 095d2a78a94cd..0b43f32e3dc29 100644 --- a/src/librustc/infer/error_reporting.rs +++ b/src/librustc/infer/error_reporting.rs @@ -144,14 +144,14 @@ impl<'a, 'gcx, '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)) { + let tag = match self.hir.find(scope.node_id(&self.region_maps)) { Some(ast_map::NodeBlock(_)) => "block", Some(ast_map::NodeExpr(expr)) => match expr.node { hir::ExprCall(..) => "call", @@ -206,7 +206,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let node = fr.scope.node_id(&self.region_maps); let unknown; - let tag = match self.map.find(node) { + let tag = match self.hir.find(node) { Some(ast_map::NodeBlock(_)) | Some(ast_map::NodeExpr(_)) => "body", Some(ast_map::NodeItem(it)) => item_scope_tag(&it), @@ -218,7 +218,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { 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 @@ impl<'a, 'gcx, '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,8 +467,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'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 { @@ -1068,8 +1068,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { 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 { @@ -1083,8 +1083,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } } 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) { + let id = self.tcx.hir.get_parent(item.id); + if let Some(ast_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) @@ -1654,7 +1654,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { 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; @@ -1891,8 +1891,8 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, scope_id: ast::NodeId) -> Vec { 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::ItemFn(.., ref gen, _) => { @@ -1915,8 +1915,8 @@ 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::ItemImpl(_, _, ref gen, ..) => { diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 4e64dda1a3044..45a58333f781f 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -453,8 +453,8 @@ impl<'a, 'tcx> InferEnv<'a, 'tcx> for hir::BodyId { -> (Option<&'a ty::TypeckTables<'tcx>>, Option>, Option>) { - let item_id = tcx.map.body_owner(self); - (Some(tcx.item_tables(tcx.map.local_def_id(item_id))), + let item_id = tcx.hir.body_owner(self); + (Some(tcx.item_tables(tcx.hir.local_def_id(item_id))), None, Some(ty::ParameterEnvironment::for_item(tcx, item_id))) } @@ -1269,7 +1269,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.tcx.types.err, None => { bug!("no type for node {}: {} in fcx", - id, self.tcx.map.node_to_string(id)); + id, self.tcx.hir.node_to_string(id)); } } } @@ -1639,7 +1639,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { -> Option { if let InferTables::InProgress(tables) = self.tables { - if let Some(id) = self.tcx.map.as_local_node_id(def_id) { + if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { return tables.borrow().closure_kinds.get(&id).cloned(); } } @@ -1657,7 +1657,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { -> ty::ClosureTy<'tcx> { if let InferTables::InProgress(tables) = self.tables { - if let Some(id) = self.tcx.map.as_local_node_id(def_id) { + if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { if let Some(ty) = tables.borrow().closure_tys.get(&id) { return ty.subst(self.tcx, substs.substs); } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 5ac000923e071..3506a9c067ca6 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -768,7 +768,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> { /// items in the context of the outer item, so enable /// deep-walking. fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'tcx> { - hir_visit::NestedVisitorMap::All(&self.tcx.map) + hir_visit::NestedVisitorMap::All(&self.tcx.hir) } // Output any lints that were previously added to the session. @@ -784,7 +784,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> { fn visit_nested_body(&mut self, body: hir::BodyId) { let old_tables = self.tables; self.tables = self.tcx.body_tables(body); - let body = self.tcx.map.body(body); + let body = self.tcx.hir.body(body); self.visit_body(body); self.tables = old_tables; } @@ -834,7 +834,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> { // in order for `check_fn` to be able to use them. let old_tables = self.tables; self.tables = self.tcx.body_tables(body_id); - let body = self.tcx.map.body(body_id); + let body = self.tcx.hir.body(body_id); run_lints!(self, check_fn, late_passes, fk, decl, body, span, id); hir_visit::walk_fn(self, fk, decl, body_id, span, id); run_lints!(self, check_fn_post, late_passes, fk, decl, body, span, id); @@ -1206,7 +1206,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: &AccessLevels) { let _task = tcx.dep_graph.in_task(DepNode::LateLintCheck); - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); // We want to own the lint store, so move it out of the session. let lint_store = mem::replace(&mut *tcx.sess.lint_store.borrow_mut(), LintStore::new()); @@ -1236,7 +1236,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, for early_lint in v { span_bug!(early_lint.diagnostic.span.clone(), "unprocessed lint {:?} at {}", - early_lint, tcx.map.node_to_string(*id)); + early_lint, tcx.hir.node_to_string(*id)); } } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index dfcb5cb7b79fe..7d62103e386c4 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -109,7 +109,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> { fn nested(&self, state: &mut pprust::State, nested: pprust::Nested) -> io::Result<()> { - pprust::PpAnn::nested(&self.tcx.map, state, nested) + pprust::PpAnn::nested(&self.tcx.hir, state, nested) } fn pre(&self, ps: &mut pprust::State, diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 38fbe650a89bd..fe1dadca05134 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -35,7 +35,7 @@ use syntax_pos; // may need to be marked as live. fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) -> bool { - match tcx.map.find(node_id) { + match tcx.hir.find(node_id) { Some(ast_map::NodeItem(..)) | Some(ast_map::NodeImplItem(..)) | Some(ast_map::NodeForeignItem(..)) | @@ -59,7 +59,7 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { fn check_def_id(&mut self, def_id: DefId) { - if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) { + if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { if should_explore(self.tcx, node_id) { self.worklist.push(node_id); } @@ -68,7 +68,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { } fn insert_def_id(&mut self, def_id: DefId) { - if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) { + if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { debug_assert!(!should_explore(self.tcx, node_id)); self.live_symbols.insert(node_id); } @@ -143,7 +143,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { } scanned.insert(id); - if let Some(ref node) = self.tcx.map.find(id) { + if let Some(ref node) = self.tcx.hir.find(id) { self.live_symbols.insert(id); self.visit_node(node); } @@ -203,7 +203,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> { fn visit_nested_body(&mut self, body: hir::BodyId) { let old_tables = self.tables; self.tables = self.tcx.body_tables(body); - let body = self.tcx.map.body(body); + let body = self.tcx.hir.body(body); self.visit_body(body); self.tables = old_tables; } @@ -434,7 +434,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { } fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool { - let field_type = self.tcx.item_type(self.tcx.map.local_def_id(field.id)); + let field_type = self.tcx.item_type(self.tcx.hir.local_def_id(field.id)); let is_marker_field = match field_type.ty_to_def_id() { Some(def_id) => self.tcx.lang_items.items().iter().any(|item| *item == Some(def_id)), _ => false @@ -478,10 +478,10 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { // method of a private type is used, but the type itself is never // called directly. if let Some(impl_list) = - self.tcx.inherent_impls.borrow().get(&self.tcx.map.local_def_id(id)) { + self.tcx.inherent_impls.borrow().get(&self.tcx.hir.local_def_id(id)) { for &impl_did in impl_list.iter() { for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] { - if let Some(item_node_id) = self.tcx.map.as_local_node_id(item_did) { + if let Some(item_node_id) = self.tcx.hir.as_local_node_id(item_did) { if self.live_symbols.contains(&item_node_id) { return true; } @@ -514,7 +514,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { /// an error. We could do this also by checking the parents, but /// this is how the code is setup and it seems harmless enough. fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::All(&self.tcx.map) + NestedVisitorMap::All(&self.tcx.hir) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -596,7 +596,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: &privacy::AccessLevels) { let _task = tcx.dep_graph.in_task(DepNode::DeadCheck); - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); let live_symbols = find_live(tcx, access_levels, krate); let mut visitor = DeadVisitor { tcx: tcx, live_symbols: live_symbols }; intravisit::walk_crate(&mut visitor, krate); diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index f90d9143e9d57..ab33c3843aae5 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -101,7 +101,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> { fn visit_nested_body(&mut self, body: hir::BodyId) { let old_tables = self.tables; self.tables = self.tcx.body_tables(body); - let body = self.tcx.map.body(body); + let body = self.tcx.hir.body(body); self.visit_body(body); self.tables = old_tables; } @@ -203,7 +203,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> { if let Def::Static(def_id, mutbl) = path.def { if mutbl { self.require_unsafe(expr.span, "use of mutable static"); - } else if match self.tcx.map.get_if_local(def_id) { + } else if match self.tcx.hir.get_if_local(def_id) { Some(hir::map::NodeForeignItem(..)) => true, Some(..) => false, None => self.tcx.sess.cstore.is_foreign_item(def_id), @@ -249,5 +249,5 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { unsafe_context: UnsafeContext::new(SafeContext), }; - tcx.map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); } diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 0eacbba3fdd44..738bd0009abae 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -1020,7 +1020,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { self.tcx().with_freevars(closure_expr.id, |freevars| { for freevar in freevars { let def_id = freevar.def.def_id(); - let id_var = self.tcx().map.as_local_node_id(def_id).unwrap(); + let id_var = self.tcx().hir.as_local_node_id(def_id).unwrap(); let upvar_id = ty::UpvarId { var_id: id_var, closure_expr_id: closure_expr.id }; let upvar_capture = self.mc.infcx.upvar_capture(upvar_id).unwrap(); @@ -1052,7 +1052,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { -> mc::McResult> { // Create the cmt for the variable being borrowed, from the // caller's perspective - let var_id = self.tcx().map.as_local_node_id(upvar_def.def_id()).unwrap(); + let var_id = self.tcx().hir.as_local_node_id(upvar_def.def_id()).unwrap(); let var_ty = self.mc.infcx.node_ty(var_id)?; self.mc.cat_def(closure_id, closure_span, var_ty, upvar_def) } diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index d42b866d47209..05be35df95991 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -110,7 +110,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> { } fn visit_nested_body(&mut self, body_id: hir::BodyId) { - let body = self.tcx.map.body(body_id); + let body = self.tcx.hir.body(body_id); self.tcx.infer_ctxt(body_id, Reveal::All).enter(|infcx| { let mut visitor = ExprVisitor { infcx: &infcx diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index e0521f98416bc..7fa3365694c26 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -183,7 +183,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt) -> String { impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.map) + NestedVisitorMap::OnlyBodies(&self.tcx.hir) } fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl, @@ -197,7 +197,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let _task = tcx.dep_graph.in_task(DepNode::Liveness); - tcx.map.krate().visit_all_item_likes(&mut IrMaps::new(tcx).as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut IrMaps::new(tcx).as_deep_visitor()); tcx.sess.abort_if_errors(); } @@ -364,7 +364,7 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>, debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps); - let body = ir.tcx.map.body(body_id); + let body = ir.tcx.hir.body(body_id); for arg in &body.arguments { arg.pat.each_binding(|_bm, arg_id, _x, path1| { @@ -440,7 +440,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { ir.tcx.with_freevars(expr.id, |freevars| { for fv in freevars { if let Def::Local(def_id) = fv.def { - let rv = ir.tcx.map.as_local_node_id(def_id).unwrap(); + let rv = ir.tcx.hir.as_local_node_id(def_id).unwrap(); let fv_ln = ir.add_live_node(FreeVarNode(fv.span)); call_caps.push(CaptureInfo {ln: fv_ln, var_nid: rv}); @@ -807,7 +807,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // effectively a return---this only occurs in `for` loops, // where the body is really a closure. - debug!("compute: using id for body, {}", self.ir.tcx.map.node_to_pretty_string(body.id)); + debug!("compute: using id for body, {}", self.ir.tcx.hir.node_to_pretty_string(body.id)); let exit_ln = self.s.exit_ln; let entry_ln: LiveNode = self.with_loop_nodes(body.id, exit_ln, exit_ln, |this| { @@ -900,7 +900,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode { - debug!("propagate_through_expr: {}", self.ir.tcx.map.node_to_pretty_string(expr.id)); + debug!("propagate_through_expr: {}", self.ir.tcx.hir.node_to_pretty_string(expr.id)); match expr.node { // Interesting cases with control flow or which gen/kill @@ -919,7 +919,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { hir::ExprClosure(.., blk_id, _) => { debug!("{} is an ExprClosure", - self.ir.tcx.map.node_to_pretty_string(expr.id)); + self.ir.tcx.hir.node_to_pretty_string(expr.id)); /* The next-node for a break is the successor of the entire @@ -1241,7 +1241,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { -> LiveNode { match path.def { Def::Local(def_id) => { - let nid = self.ir.tcx.map.as_local_node_id(def_id).unwrap(); + let nid = self.ir.tcx.hir.as_local_node_id(def_id).unwrap(); let ln = self.live_node(id, path.span); if acc != 0 { self.init_from_succ(ln, succ); @@ -1295,7 +1295,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } debug!("propagate_through_loop: using id for loop body {} {}", - expr.id, self.ir.tcx.map.node_to_pretty_string(body.id)); + expr.id, self.ir.tcx.hir.node_to_pretty_string(body.id)); let cond_ln = match kind { LoopLoop => ln, @@ -1440,7 +1440,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { entry_ln: LiveNode, body: &hir::Body) { - let fn_ty = self.ir.tcx.item_type(self.ir.tcx.map.local_def_id(id)); + let fn_ty = self.ir.tcx.item_type(self.ir.tcx.hir.local_def_id(id)); let fn_ret = match fn_ty.sty { ty::TyClosure(closure_def_id, substs) => self.ir.tcx.closure_type(closure_def_id, substs).sig.output(), @@ -1477,7 +1477,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // if there is no later assignment. If this local is actually // mutable, then check for a reassignment to flag the mutability // as being used. - let nid = self.ir.tcx.map.as_local_node_id(def_id).unwrap(); + let nid = self.ir.tcx.hir.as_local_node_id(def_id).unwrap(); let ln = self.live_node(expr.id, expr.span); let var = self.variable(nid, expr.span); self.warn_about_dead_assign(expr.span, expr.id, ln, var); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 92e69d7d72957..d4438f5ecfa1a 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -268,7 +268,7 @@ impl MutabilityCategory { } fn from_local(tcx: TyCtxt, id: ast::NodeId) -> MutabilityCategory { - let ret = match tcx.map.get(id) { + let ret = match tcx.hir.get(id) { ast_map::NodeLocal(p) => match p.node { PatKind::Binding(bind_mode, ..) => { if bind_mode == hir::BindByValue(hir::MutMutable) { @@ -279,7 +279,7 @@ impl MutabilityCategory { } _ => span_bug!(p.span, "expected identifier pattern") }, - _ => span_bug!(tcx.map.span(id), "expected identifier pattern") + _ => span_bug!(tcx.hir.span(id), "expected identifier pattern") }; debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}", "from_local", id, ret); @@ -539,7 +539,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } Def::Upvar(def_id, _, fn_node_id) => { - let var_id = self.tcx().map.as_local_node_id(def_id).unwrap(); + let var_id = self.tcx().hir.as_local_node_id(def_id).unwrap(); let ty = self.node_ty(fn_node_id)?; match ty.sty { ty::TyClosure(closure_id, _) => { @@ -576,7 +576,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { } Def::Local(def_id) => { - let vid = self.tcx().map.as_local_node_id(def_id).unwrap(); + let vid = self.tcx().hir.as_local_node_id(def_id).unwrap(); Ok(Rc::new(cmt_ { id: id, span: span, @@ -698,7 +698,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // Look up the node ID of the closure body so we can construct // a free region within it let fn_body_id = { - let fn_expr = match self.tcx().map.find(upvar_id.closure_expr_id) { + let fn_expr = match self.tcx().hir.find(upvar_id.closure_expr_id) { Some(ast_map::NodeExpr(e)) => e, _ => bug!() }; @@ -1313,7 +1313,7 @@ impl<'tcx> cmt_<'tcx> { "non-lvalue".to_string() } Categorization::Local(vid) => { - if tcx.map.is_argument(vid) { + if tcx.hir.is_argument(vid) { "argument".to_string() } else { "local variable".to_string() diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 385dd3d9bf764..9b00fc3f220ec 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -63,8 +63,8 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, generics_require_inlining(&sig.generics) { return true } - if let Some(impl_node_id) = tcx.map.as_local_node_id(impl_src) { - match tcx.map.find(impl_node_id) { + if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) { + match tcx.hir.find(impl_node_id) { Some(ast_map::NodeItem(item)) => item_might_be_inlined(&item), Some(..) | None => @@ -97,7 +97,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> { fn visit_nested_body(&mut self, body: hir::BodyId) { let old_tables = self.tables; self.tables = self.tcx.body_tables(body); - let body = self.tcx.map.body(body); + let body = self.tcx.hir.body(body); self.visit_body(body); self.tables = old_tables; } @@ -117,7 +117,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> { if let Some(def) = def { let def_id = def.def_id(); - if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) { + if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { if self.def_id_represents_local_inlined_item(def_id) { self.worklist.push(node_id); } else { @@ -147,12 +147,12 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // Returns true if the given def ID represents a local item that is // eligible for inlining and false otherwise. fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool { - let node_id = match self.tcx.map.as_local_node_id(def_id) { + let node_id = match self.tcx.hir.as_local_node_id(def_id) { Some(node_id) => node_id, None => { return false; } }; - match self.tcx.map.find(node_id) { + match self.tcx.hir.find(node_id) { Some(ast_map::NodeItem(item)) => { match item.node { hir::ItemFn(..) => item_might_be_inlined(&item), @@ -176,13 +176,13 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { true } else { let impl_did = self.tcx - .map + .hir .get_parent_did(node_id); // Check the impl. If the generics on the self // type of the impl require inlining, this method // does too. - let impl_node_id = self.tcx.map.as_local_node_id(impl_did).unwrap(); - match self.tcx.map.expect_item(impl_node_id).node { + let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap(); + match self.tcx.hir.expect_item(impl_node_id).node { hir::ItemImpl(_, _, ref generics, ..) => { generics_require_inlining(generics) } @@ -210,7 +210,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { continue } - if let Some(ref item) = self.tcx.map.find(search_item) { + if let Some(ref item) = self.tcx.hir.find(search_item) { self.propagate_node(item, search_item); } } @@ -287,7 +287,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { self.visit_nested_body(body); } hir::ImplItemKind::Method(ref sig, body) => { - let did = self.tcx.map.get_parent_did(search_item); + let did = self.tcx.hir.get_parent_did(search_item); if method_might_be_inlined(self.tcx, sig, impl_item, did) { self.visit_nested_body(body) } @@ -303,7 +303,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { ast_map::NodeTy(_) => {} _ => { bug!("found unexpected thingy in worklist: {}", - self.tcx.map.node_to_string(search_item)) + self.tcx.hir.node_to_string(search_item)) } } } @@ -343,7 +343,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, for default_method in self.tcx.provided_trait_methods(trait_def_id) { let node_id = self.tcx - .map + .hir .as_local_node_id(default_method.def_id) .unwrap(); self.worklist.push(node_id); @@ -386,7 +386,7 @@ pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } for item in tcx.lang_items.items().iter() { if let Some(did) = *item { - if let Some(node_id) = tcx.map.as_local_node_id(did) { + if let Some(node_id) = tcx.hir.as_local_node_id(did) { reachable_context.worklist.push(node_id); } } @@ -397,7 +397,7 @@ pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: access_levels, worklist: &mut reachable_context.worklist, }; - tcx.map.krate().visit_all_item_likes(&mut collect_private_impl_items); + tcx.hir.krate().visit_all_item_likes(&mut collect_private_impl_items); } // Step 2: Mark all symbols that the symbols on the worklist touch. diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index e6c9d2c36d013..487e13b47fec2 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -178,7 +178,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { } } - let def_id = self.tcx.map.local_def_id(id); + let def_id = self.tcx.hir.local_def_id(id); self.index.stab_map.insert(def_id, Some(stab)); let orig_parent_stab = replace(&mut self.parent_stab, Some(stab)); @@ -188,7 +188,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { debug!("annotate: not found, parent = {:?}", self.parent_stab); if let Some(stab) = self.parent_stab { if stab.level.is_unstable() { - let def_id = self.tcx.map.local_def_id(id); + let def_id = self.tcx.hir.local_def_id(id); self.index.stab_map.insert(def_id, Some(stab)); } } @@ -211,7 +211,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { } // `Deprecation` is just two pointers, no need to intern it - let def_id = self.tcx.map.local_def_id(id); + let def_id = self.tcx.hir.local_def_id(id); let depr_entry = Some(DeprecationEntry::local(depr, def_id)); self.index.depr_map.insert(def_id, depr_entry.clone()); @@ -219,7 +219,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { visit_children(self); self.parent_depr = orig_parent_depr; } else if let parent_depr @ Some(_) = self.parent_depr.clone() { - let def_id = self.tcx.map.local_def_id(id); + let def_id = self.tcx.hir.local_def_id(id); self.index.depr_map.insert(def_id, parent_depr); visit_children(self); } else { @@ -234,7 +234,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { /// nested items in the context of the outer item, so enable /// deep-walking. fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::All(&self.tcx.map) + NestedVisitorMap::All(&self.tcx.hir) } fn visit_item(&mut self, i: &'tcx Item) { @@ -313,7 +313,7 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> { impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> { fn check_missing_stability(&self, id: NodeId, span: Span) { - let def_id = self.tcx.map.local_def_id(id); + let def_id = self.tcx.hir.local_def_id(id); let is_error = !self.tcx.sess.opts.test && !self.tcx.stability.borrow().stab_map.contains_key(&def_id) && self.access_levels.is_reachable(id); @@ -325,7 +325,7 @@ impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.map) + NestedVisitorMap::OnlyBodies(&self.tcx.hir) } fn visit_item(&mut self, i: &'tcx Item) { @@ -348,7 +348,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { } fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) { - let impl_def_id = self.tcx.map.local_def_id(self.tcx.map.get_parent(ii.id)); + let impl_def_id = self.tcx.hir.local_def_id(self.tcx.hir.get_parent(ii.id)); if self.tcx.impl_trait_ref(impl_def_id).is_none() { self.check_missing_stability(ii.id, ii.span); } @@ -384,7 +384,7 @@ impl<'a, 'tcx> Index<'tcx> { self.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect(); let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex); - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); let mut annotator = Annotator { tcx: tcx, index: self, @@ -484,7 +484,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let skip = if id == ast::DUMMY_NODE_ID { true } else { - let parent_def_id = self.map.local_def_id(self.map.get_parent(id)); + let parent_def_id = self.hir.local_def_id(self.hir.get_parent(id)); self.lookup_deprecation_entry(parent_def_id).map_or(false, |parent_depr| { parent_depr.same_origin(&depr_entry) }) @@ -555,7 +555,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { /// nested items in the context of the outer item, so enable /// deep-walking. fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.map) + NestedVisitorMap::OnlyBodies(&self.tcx.hir) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -578,7 +578,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { hir::ItemImpl(.., Some(ref t), _, ref impl_item_refs) => { if let Def::Trait(trait_did) = t.path.def { for impl_item_ref in impl_item_refs { - let impl_item = self.tcx.map.impl_item(impl_item_ref.id); + let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); let trait_item_def_id = self.tcx.associated_items(trait_did) .find(|item| item.name == impl_item.name).map(|item| item.def_id); if let Some(def_id) = trait_item_def_id { @@ -658,7 +658,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if tcx.stability.borrow().staged_api[&LOCAL_CRATE] && tcx.sess.features.borrow().staged_api { let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex); - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); let mut missing = MissingStabilityAnnotations { tcx: tcx, access_levels: access_levels, diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 5bae0e347f7c4..6e9091cf31728 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1163,14 +1163,14 @@ impl<'tcx> Debug for Rvalue<'tcx> { } AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| { - if let Some(node_id) = tcx.map.as_local_node_id(def_id) { - let name = format!("[closure@{:?}]", tcx.map.span(node_id)); + if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { + let name = format!("[closure@{:?}]", tcx.hir.span(node_id)); let mut struct_fmt = fmt.debug_struct(&name); tcx.with_freevars(node_id, |freevars| { for (freevar, lv) in freevars.iter().zip(lvs) { let def_id = freevar.def.def_id(); - let var_id = tcx.map.as_local_node_id(def_id).unwrap(); + let var_id = tcx.hir.as_local_node_id(def_id).unwrap(); let var_name = tcx.local_var_name_str(var_id); struct_fmt.field(&var_name, lv); } diff --git a/src/librustc/mir/transform.rs b/src/librustc/mir/transform.rs index 3c5a91f4ff04c..652fef76f288a 100644 --- a/src/librustc/mir/transform.rs +++ b/src/librustc/mir/transform.rs @@ -40,13 +40,13 @@ impl<'a, 'tcx> MirSource { use hir::*; // Handle constants in enum discriminants, types, and repeat expressions. - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); let def_key = tcx.def_key(def_id); if def_key.disambiguated_data.data == DefPathData::Initializer { return MirSource::Const(id); } - match tcx.map.get(id) { + match tcx.hir.get(id) { map::NodeItem(&Item { node: ItemConst(..), .. }) | map::NodeTraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) | map::NodeImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) => { @@ -124,7 +124,7 @@ impl<'tcx, T: MirPass<'tcx>> MirMapPass<'tcx> for T { let mir = &mut tcx.mir_map.borrow()[&def_id].borrow_mut(); tcx.dep_graph.write(DepNode::Mir(def_id)); - let id = tcx.map.as_local_node_id(def_id).unwrap(); + let id = tcx.hir.as_local_node_id(def_id).unwrap(); let src = MirSource::from_node(tcx, id); for hook in &mut *hooks { diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 5cc9875e8018b..1658efb03235a 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -441,7 +441,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { E0276, "impl has stricter requirements than trait"); - if let Some(trait_item_span) = self.tcx.map.span_if_local(trait_item_def_id) { + if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) { err.span_label(trait_item_span, &format!("definition of `{}` from trait", item_name)); } @@ -594,7 +594,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ty::Predicate::ClosureKind(closure_def_id, kind) => { let found_kind = self.closure_kind(closure_def_id).unwrap(); - let closure_span = self.tcx.map.span_if_local(closure_def_id).unwrap(); + let closure_span = self.tcx.hir.span_if_local(closure_def_id).unwrap(); let mut err = struct_span_err!( self.tcx.sess, closure_span, E0525, "expected a closure that implements the `{}` trait, \ @@ -653,7 +653,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { -> DiagnosticBuilder<'tcx> { assert!(type_def_id.is_local()); - let span = self.map.span_if_local(type_def_id).unwrap(); + let span = self.hir.span_if_local(type_def_id).unwrap(); let mut err = struct_span_err!(self.sess, span, E0072, "recursive type `{}` has infinite size", self.item_path_str(type_def_id)); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index c32e40c6cef22..7f26fdfba5693 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -265,7 +265,7 @@ impl<'tcx> TypeckTables<'tcx> { Some(ty) => ty, None => { bug!("node_id_to_type: no type for node `{}`", - tls::with(|tcx| tcx.map.node_to_string(id))) + tls::with(|tcx| tcx.hir.node_to_string(id))) } } } @@ -428,7 +428,7 @@ pub struct GlobalCtxt<'tcx> { /// additional acyclicity requirements). pub super_predicates: RefCell>>, - pub map: ast_map::Map<'tcx>, + pub hir: ast_map::Map<'tcx>, /// Maps from the def-id of a function/method or const/static /// to its MIR. Mutation is done at an item granularity to @@ -628,7 +628,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { debug!("retrace_path(path={:?}, krate={:?})", path_data, self.crate_name(krate)); if krate == LOCAL_CRATE { - self.map + self.hir .definitions() .def_path_table() .retrace_path(path_data) @@ -730,7 +730,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { arena: &'tcx DroplessArena, resolutions: ty::Resolutions, named_region_map: resolve_lifetime::NamedRegionMap, - map: ast_map::Map<'tcx>, + hir: ast_map::Map<'tcx>, region_maps: RegionMaps, lang_items: middle::lang_items::LanguageItems, stability: stability::Index<'tcx>, @@ -741,7 +741,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let data_layout = TargetDataLayout::parse(s); let interners = CtxtInterners::new(arena); let common_types = CommonTypes::new(&interners); - let dep_graph = map.dep_graph.clone(); + let dep_graph = hir.dep_graph.clone(); let fulfilled_predicates = traits::GlobalFulfilledPredicates::new(dep_graph.clone()); tls::enter_global(GlobalCtxt { specializes_cache: RefCell::new(traits::SpecializesCache::new()), @@ -765,7 +765,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { predicates: RefCell::new(DepTrackingMap::new(dep_graph.clone())), super_predicates: RefCell::new(DepTrackingMap::new(dep_graph.clone())), fulfilled_predicates: RefCell::new(fulfilled_predicates), - map: map, + hir: hir, mir_map: RefCell::new(DepTrackingMap::new(dep_graph.clone())), freevars: RefCell::new(resolutions.freevars), maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports, diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index e95ce97e13577..91087a3dcecd0 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -283,7 +283,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { expected.ty, found.ty)); - match self.map.span_if_local(expected.def_id) { + match self.hir.span_if_local(expected.def_id) { Some(span) => { db.span_note(span, "a default was defined here..."); } @@ -297,7 +297,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { expected.origin_span, "...that was applied to an unconstrained type variable here"); - match self.map.span_if_local(found.def_id) { + match self.hir.span_if_local(found.def_id) { Some(span) => { db.span_note(span, "a second default was defined here..."); } diff --git a/src/librustc/ty/inhabitedness/def_id_forest.rs b/src/librustc/ty/inhabitedness/def_id_forest.rs index 16bc65603f135..6801e82fe7476 100644 --- a/src/librustc/ty/inhabitedness/def_id_forest.rs +++ b/src/librustc/ty/inhabitedness/def_id_forest.rs @@ -43,7 +43,7 @@ impl<'a, 'gcx, 'tcx> DefIdForest { /// crate. #[inline] pub fn full(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> DefIdForest { - let crate_id = tcx.map.local_def_id(CRATE_NODE_ID); + let crate_id = tcx.hir.local_def_id(CRATE_NODE_ID); DefIdForest::from_id(crate_id) } diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index 0e4c14029e9b9..d488cd1c42711 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -52,7 +52,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Returns a string identifying this local node-id. pub fn node_path_str(self, id: ast::NodeId) -> String { - self.item_path_str(self.map.local_def_id(id)) + self.item_path_str(self.hir.local_def_id(id)) } /// Returns a string identifying this def-id. This string is @@ -286,8 +286,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // only occur very early in the compiler pipeline. let parent_def_id = self.parent_def_id(impl_def_id).unwrap(); self.push_item_path(buffer, parent_def_id); - let node_id = self.map.as_local_node_id(impl_def_id).unwrap(); - let item = self.map.expect_item(node_id); + let node_id = self.hir.as_local_node_id(impl_def_id).unwrap(); + let item = self.hir.expect_item(node_id); let span_str = self.sess.codemap().span_to_string(item.span); buffer.push(&format!("", span_str)); } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 697ab6ee491d4..7a8788f053dd0 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -261,7 +261,7 @@ impl Visibility { def => Visibility::Restricted(def.def_id()), }, hir::Inherited => { - Visibility::Restricted(tcx.map.local_def_id(tcx.map.get_module_parent(id))) + Visibility::Restricted(tcx.hir.local_def_id(tcx.hir.get_module_parent(id))) } } } @@ -1198,14 +1198,14 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { /// Construct a parameter environment given an item, impl item, or trait item pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId) -> ParameterEnvironment<'tcx> { - match tcx.map.find(id) { + match tcx.hir.find(id) { Some(ast_map::NodeImplItem(ref impl_item)) => { match impl_item.node { hir::ImplItemKind::Type(_) | hir::ImplItemKind::Const(..) => { // associated types don't have their own entry (for some reason), // so for now just grab environment for the impl - let impl_id = tcx.map.get_parent(id); - let impl_def_id = tcx.map.local_def_id(impl_id); + let impl_id = tcx.hir.get_parent(id); + let impl_def_id = tcx.hir.local_def_id(impl_id); tcx.construct_parameter_environment(impl_item.span, impl_def_id, tcx.region_maps.item_extent(id)) @@ -1213,7 +1213,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { hir::ImplItemKind::Method(_, ref body) => { tcx.construct_parameter_environment( impl_item.span, - tcx.map.local_def_id(id), + tcx.hir.local_def_id(id), tcx.region_maps.call_site_extent(id, body.node_id)) } } @@ -1223,8 +1223,8 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { hir::TraitItemKind::Type(..) | hir::TraitItemKind::Const(..) => { // associated types don't have their own entry (for some reason), // so for now just grab environment for the trait - let trait_id = tcx.map.get_parent(id); - let trait_def_id = tcx.map.local_def_id(trait_id); + let trait_id = tcx.hir.get_parent(id); + let trait_def_id = tcx.hir.local_def_id(trait_id); tcx.construct_parameter_environment(trait_item.span, trait_def_id, tcx.region_maps.item_extent(id)) @@ -1242,7 +1242,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { }; tcx.construct_parameter_environment( trait_item.span, - tcx.map.local_def_id(id), + tcx.hir.local_def_id(id), extent) } } @@ -1251,7 +1251,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { match item.node { hir::ItemFn(.., body_id) => { // We assume this is a function. - let fn_def_id = tcx.map.local_def_id(id); + let fn_def_id = tcx.hir.local_def_id(id); tcx.construct_parameter_environment( item.span, @@ -1265,13 +1265,13 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { hir::ItemImpl(..) | hir::ItemConst(..) | hir::ItemStatic(..) => { - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); tcx.construct_parameter_environment(item.span, def_id, tcx.region_maps.item_extent(id)) } hir::ItemTrait(..) => { - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); tcx.construct_parameter_environment(item.span, def_id, tcx.region_maps.item_extent(id)) @@ -1287,7 +1287,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { Some(ast_map::NodeExpr(expr)) => { // This is a convenience to allow closures to work. if let hir::ExprClosure(.., body, _) = expr.node { - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); let base_def_id = tcx.closure_base_def_id(def_id); tcx.construct_parameter_environment( expr.span, @@ -1298,7 +1298,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { } } Some(ast_map::NodeForeignItem(item)) => { - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); tcx.construct_parameter_environment(item.span, def_id, ROOT_CODE_EXTENT) @@ -1306,7 +1306,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { _ => { bug!("ParameterEnvironment::from_item(): \ `{}` is not an item", - tcx.map.node_to_string(id)) + tcx.hir.node_to_string(id)) } } } @@ -1918,7 +1918,7 @@ impl BorrowKind { impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> { - self.item_tables(self.map.body_owner_def_id(body)) + self.item_tables(self.hir.body_owner_def_id(body)) } pub fn item_tables(self, def_id: DefId) -> &'gcx TypeckTables<'gcx> { @@ -1944,7 +1944,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn expr_span(self, id: NodeId) -> Span { - match self.map.find(id) { + match self.hir.find(id) { Some(ast_map::NodeExpr(e)) => { e.span } @@ -1958,7 +1958,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn local_var_name_str(self, id: NodeId) -> InternedString { - match self.map.find(id) { + match self.hir.find(id) { Some(ast_map::NodeLocal(pat)) => { match pat.node { hir::PatKind::Binding(_, _, ref path1, _) => path1.node.as_str(), @@ -2031,8 +2031,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn trait_impl_polarity(self, id: DefId) -> hir::ImplPolarity { - if let Some(id) = self.map.as_local_node_id(id) { - match self.map.expect_item(id).node { + if let Some(id) = self.hir.as_local_node_id(id) { + match self.hir.expect_item(id).node { hir::ItemImpl(_, polarity, ..) => polarity, ref item => bug!("trait_impl_polarity: {:?} not an impl", item) } @@ -2077,10 +2077,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // those tasks that just need to scan the names of items // and so forth. - let id = self.map.as_local_node_id(def_id).unwrap(); - let parent_id = self.map.get_parent(id); - let parent_def_id = self.map.local_def_id(parent_id); - let parent_item = self.map.expect_item(parent_id); + let id = self.hir.as_local_node_id(def_id).unwrap(); + let parent_id = self.hir.get_parent(id); + let parent_def_id = self.hir.local_def_id(parent_id); + let parent_item = self.hir.expect_item(parent_id); match parent_item.node { hir::ItemImpl(.., ref impl_trait_ref, _, ref impl_item_refs) => { for impl_item_ref in impl_item_refs { @@ -2115,7 +2115,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { parent_def_id: DefId, trait_item_ref: &hir::TraitItemRef) -> AssociatedItem { - let def_id = self.map.local_def_id(trait_item_ref.id.node_id); + let def_id = self.hir.local_def_id(trait_item_ref.id.node_id); let (kind, has_self) = match trait_item_ref.kind { hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false), hir::AssociatedItemKind::Method { has_self } => { @@ -2140,7 +2140,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { from_trait_impl: bool, impl_item_ref: &hir::ImplItemRef) -> AssociatedItem { - let def_id = self.map.local_def_id(impl_item_ref.id.node_id); + let def_id = self.hir.local_def_id(impl_item_ref.id.node_id); let (kind, has_self) = match impl_item_ref.kind { hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false), hir::AssociatedItemKind::Method { has_self } => { @@ -2170,19 +2170,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { return Rc::new(self.sess.cstore.associated_item_def_ids(def_id)); } - let id = self.map.as_local_node_id(def_id).unwrap(); - let item = self.map.expect_item(id); + let id = self.hir.as_local_node_id(def_id).unwrap(); + let item = self.hir.expect_item(id); let vec: Vec<_> = match item.node { hir::ItemTrait(.., ref trait_item_refs) => { trait_item_refs.iter() .map(|trait_item_ref| trait_item_ref.id) - .map(|id| self.map.local_def_id(id.node_id)) + .map(|id| self.hir.local_def_id(id.node_id)) .collect() } hir::ItemImpl(.., ref impl_item_refs) => { impl_item_refs.iter() .map(|impl_item_ref| impl_item_ref.id) - .map(|id| self.map.local_def_id(id.node_id)) + .map(|id| self.hir.local_def_id(id.node_id)) .collect() } _ => span_bug!(item.span, "associated_item_def_ids: not impl or trait") @@ -2227,7 +2227,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn def_key(self, id: DefId) -> ast_map::DefKey { if id.is_local() { - self.map.def_key(id) + self.hir.def_key(id) } else { self.sess.cstore.def_key(id) } @@ -2240,27 +2240,27 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // be a non-local `DefPath`. pub fn def_path(self, id: DefId) -> ast_map::DefPath { if id.is_local() { - self.map.def_path(id) + self.hir.def_path(id) } else { self.sess.cstore.def_path(id) } } pub fn def_span(self, def_id: DefId) -> Span { - if let Some(id) = self.map.as_local_node_id(def_id) { - self.map.span(id) + if let Some(id) = self.hir.as_local_node_id(def_id) { + self.hir.span(id) } else { self.sess.cstore.def_span(&self.sess, def_id) } } pub fn vis_is_accessible_from(self, vis: Visibility, block: NodeId) -> bool { - vis.is_accessible_from(self.map.local_def_id(self.map.get_module_parent(block)), self) + vis.is_accessible_from(self.hir.local_def_id(self.hir.get_module_parent(block)), self) } pub fn item_name(self, id: DefId) -> ast::Name { - if let Some(id) = self.map.as_local_node_id(id) { - self.map.name(id) + if let Some(id) = self.hir.as_local_node_id(id) { + self.hir.name(id) } else if id.index == CRATE_DEF_INDEX { self.sess.cstore.original_crate_name(id.krate) } else { @@ -2372,8 +2372,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Get the attributes of a definition. pub fn get_attrs(self, did: DefId) -> Cow<'gcx, [ast::Attribute]> { - if let Some(id) = self.map.as_local_node_id(did) { - Cow::Borrowed(self.map.attrs(id)) + if let Some(id) = self.hir.as_local_node_id(did) { + Cow::Borrowed(self.hir.attrs(id)) } else { Cow::Owned(self.sess.cstore.item_attrs(did)) } @@ -2656,8 +2656,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// with the name of the crate containing the impl. pub fn span_of_impl(self, impl_did: DefId) -> Result { if impl_did.is_local() { - let node_id = self.map.as_local_node_id(impl_did).unwrap(); - Ok(self.map.span(node_id)) + let node_id = self.hir.as_local_node_id(impl_did).unwrap(); + Ok(self.hir.span(node_id)) } else { Err(self.sess.cstore.crate_name(impl_did.krate)) } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 38b38e5b49764..e90e1a94be951 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -285,7 +285,7 @@ fn in_binder<'a, 'gcx, 'tcx, T, U>(f: &mut fmt::Formatter, ty::BrEnv => { let name = Symbol::intern("'r"); let _ = write!(f, "{}", name); - ty::BrNamed(tcx.map.local_def_id(CRATE_NODE_ID), + ty::BrNamed(tcx.hir.local_def_id(CRATE_NODE_ID), name, ty::Issue32330::WontChange) } @@ -833,13 +833,13 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> { let upvar_tys = substs.upvar_tys(did, tcx); write!(f, "[closure")?; - if let Some(node_id) = tcx.map.as_local_node_id(did) { - write!(f, "@{:?}", tcx.map.span(node_id))?; + if let Some(node_id) = tcx.hir.as_local_node_id(did) { + write!(f, "@{:?}", tcx.hir.span(node_id))?; let mut sep = " "; tcx.with_freevars(node_id, |freevars| { for (freevar, upvar_ty) in freevars.iter().zip(upvar_tys) { let def_id = freevar.def.def_id(); - let node_id = tcx.map.as_local_node_id(def_id).unwrap(); + let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); write!(f, "{}{}:{}", sep, diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 0605644d497db..e3dec97472a48 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -460,7 +460,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { // 3. Where does old loan expire. let previous_end_span = - self.tcx().map.span(old_loan.kill_scope.node_id(&self.tcx().region_maps)) + self.tcx().hir.span(old_loan.kill_scope.node_id(&self.tcx().region_maps)) .end_point(); let mut err = match (new_loan.kind, old_loan.kind) { @@ -704,7 +704,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { borrow_kind: ty::BorrowKind) -> UseError<'tcx> { debug!("analyze_restrictions_on_use(expr_id={}, use_path={:?})", - self.tcx().map.node_to_string(expr_id), + self.tcx().hir.node_to_string(expr_id), use_path); let mut ret = UseOk; diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index b0a1b3498545f..285f3ab9047c8 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -132,7 +132,7 @@ pub fn build_unfragmented_map(this: &mut borrowck::BorrowckCtxt, } let mut fraginfo_map = this.tcx.fragment_infos.borrow_mut(); - let fn_did = this.tcx.map.local_def_id(id); + let fn_did = this.tcx.hir.local_def_id(id); let prev = fraginfo_map.insert(fn_did, fragment_infos); assert!(prev.is_none()); } @@ -202,7 +202,7 @@ pub fn instrument_move_fragments<'a, 'tcx>(this: &MoveData<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, id: ast::NodeId) { - let span_err = tcx.map.attrs(id).iter() + let span_err = tcx.hir.attrs(id).iter() .any(|a| a.check_name("rustc_move_fragments")); let print = tcx.sess.opts.debugging_opts.print_move_fragments; @@ -496,7 +496,7 @@ fn add_fragment_siblings_for_extension<'a, 'tcx>(this: &MoveData<'tcx>, }, ref ty => { - let span = origin_id.map_or(DUMMY_SP, |id| tcx.map.span(id)); + let span = origin_id.map_or(DUMMY_SP, |id| tcx.hir.span(id)); span_bug!(span, "type {:?} ({:?}) is not fragmentable", parent_ty, ty); diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 7101d843b4ce3..7f7f73d9a9678 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -53,7 +53,7 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, move_error_collector: move_error::MoveErrorCollector::new(), }; - let body = glcx.bccx.tcx.map.body(body); + let body = glcx.bccx.tcx.hir.body(body); euv::ExprUseVisitor::new(&mut glcx, &infcx).consume_body(body); glcx.report_potential_errors(); @@ -553,6 +553,6 @@ pub fn gather_loans_in_static_initializer(bccx: &mut BorrowckCtxt, body: hir::Bo body_id: body }; - let body = sicx.bccx.tcx.map.body(body); + let body = sicx.bccx.tcx.hir.body(body); sicx.visit_body(body); } diff --git a/src/librustc_borrowck/borrowck/mir/mod.rs b/src/librustc_borrowck/borrowck/mir/mod.rs index c7bd5b7ed0461..372eb1d5d64f0 100644 --- a/src/librustc_borrowck/borrowck/mir/mod.rs +++ b/src/librustc_borrowck/borrowck/mir/mod.rs @@ -57,7 +57,7 @@ pub fn borrowck_mir(bcx: &mut BorrowckCtxt, id: ast::NodeId, attributes: &[ast::Attribute]) { let tcx = bcx.tcx; - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); debug!("borrowck_mir({}) UNIMPLEMENTED", tcx.item_path_str(def_id)); let mir = &tcx.item_mir(def_id); diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index c0e038d183dad..3464f1fa89a27 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -64,7 +64,7 @@ pub type LoanDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, LoanDataFlowOperator impl<'a, 'tcx> Visitor<'tcx> for BorrowckCtxt<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.map) + NestedVisitorMap::OnlyBodies(&self.tcx.hir) } fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl, @@ -167,7 +167,7 @@ fn borrowck_fn<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>, attributes: &[ast::Attribute]) { debug!("borrowck_fn(id={})", id); - let body = this.tcx.map.body(body_id); + let body = this.tcx.hir.body(body_id); if attributes.iter().any(|item| item.check_name("rustc_mir_borrowck")) { this.with_temp_region_map(id, |this| { @@ -201,9 +201,9 @@ fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>, { // Check the body of fn items. let tcx = this.tcx; - let body = tcx.map.body(body_id); + let body = tcx.hir.body(body_id); let id_range = { - let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.map); + let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.hir); visitor.visit_body(body); visitor.result() }; @@ -398,7 +398,7 @@ pub enum LoanPathElem<'tcx> { pub fn closure_to_block(closure_id: ast::NodeId, tcx: TyCtxt) -> ast::NodeId { - match tcx.map.get(closure_id) { + match tcx.hir.get(closure_id) { hir_map::NodeExpr(expr) => match expr.node { hir::ExprClosure(.., body_id, _) => { body_id.node_id @@ -685,10 +685,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { move_data::MoveExpr | move_data::MovePat => - (self.tcx.map.span(the_move.id), ""), + (self.tcx.hir.span(the_move.id), ""), move_data::Captured => - (match self.tcx.map.expect_expr(the_move.id).node { + (match self.tcx.hir.expect_expr(the_move.id).node { hir::ExprClosure(.., fn_decl_span) => fn_decl_span, ref r => bug!("Captured({}) maps to non-closure: {:?}", the_move.id, r), @@ -882,10 +882,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { // happen for nested closures, so we know the enclosing // closure incorrectly accepts an `Fn` while it needs to // be `FnMut`. - span_help!(&mut err, self.tcx.map.span(id), + span_help!(&mut err, self.tcx.hir.span(id), "consider changing this to accept closures that implement `FnMut`"); } else { - span_help!(&mut err, self.tcx.map.span(id), + span_help!(&mut err, self.tcx.hir.span(id), "consider changing this closure to take self by mutable reference"); } err @@ -948,7 +948,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { fn region_end_span(&self, region: &'tcx ty::Region) -> Option { match *region { ty::ReScope(scope) => { - match scope.span(&self.tcx.region_maps, &self.tcx.map) { + match scope.span(&self.tcx.region_maps, &self.tcx.hir) { Some(s) => { Some(s.end_point()) } @@ -1097,7 +1097,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { _ => bug!() }; if kind == ty::ClosureKind::Fn { - db.span_help(self.tcx.map.span(upvar_id.closure_expr_id), + db.span_help(self.tcx.hir.span(upvar_id.closure_expr_id), "consider changing this closure to take \ self by mutable reference"); } @@ -1105,10 +1105,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { _ => { if let Categorization::Deref(ref inner_cmt, ..) = err.cmt.cat { if let Categorization::Local(local_id) = inner_cmt.cat { - let parent = self.tcx.map.get_parent_node(local_id); + let parent = self.tcx.hir.get_parent_node(local_id); - if let Some(fn_like) = FnLikeNode::from_node(self.tcx.map.get(parent)) { - if let Some(i) = self.tcx.map.body(fn_like.body()).arguments.iter() + if let Some(fn_like) = FnLikeNode::from_node(self.tcx.hir.get(parent)) { + if let Some(i) = self.tcx.hir.body(fn_like.body()).arguments.iter() .position(|arg| arg.pat.id == local_id) { let arg_ty = &fn_like.decl().inputs[i]; if let hir::TyRptr( @@ -1141,7 +1141,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } } } else if let Categorization::Local(local_id) = err.cmt.cat { - let span = self.tcx.map.span(local_id); + let span = self.tcx.hir.span(local_id); if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) { if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") { db.span_label(*error_span, &format!("cannot reborrow mutably")); @@ -1253,7 +1253,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { fn statement_scope_span(tcx: TyCtxt, region: &ty::Region) -> Option { match *region { ty::ReScope(scope) => { - match tcx.map.find(scope.node_id(&tcx.region_maps)) { + match tcx.hir.find(scope.node_id(&tcx.region_maps)) { Some(hir_map::NodeStmt(stmt)) => Some(stmt.span), _ => None } @@ -1302,11 +1302,11 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.kind { LpVar(id) => { - write!(f, "$({})", ty::tls::with(|tcx| tcx.map.node_to_string(id))) + write!(f, "$({})", ty::tls::with(|tcx| tcx.hir.node_to_string(id))) } LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => { - let s = ty::tls::with(|tcx| tcx.map.node_to_string(var_id)); + let s = ty::tls::with(|tcx| tcx.hir.node_to_string(var_id)); write!(f, "$({} captured by id={})", s, closure_expr_id) } @@ -1334,11 +1334,11 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.kind { LpVar(id) => { - write!(f, "$({})", ty::tls::with(|tcx| tcx.map.node_to_user_string(id))) + write!(f, "$({})", ty::tls::with(|tcx| tcx.hir.node_to_user_string(id))) } LpUpvar(ty::UpvarId{ var_id, closure_expr_id: _ }) => { - let s = ty::tls::with(|tcx| tcx.map.node_to_user_string(var_id)); + let s = ty::tls::with(|tcx| tcx.hir.node_to_user_string(var_id)); write!(f, "$({} captured by closure)", s) } diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index a6452a3f0310a..0b1f2465a4d59 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -42,7 +42,7 @@ struct OuterVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx> } impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.map) + NestedVisitorMap::OnlyBodies(&self.tcx.hir) } fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl, @@ -53,7 +53,7 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> { tcx: self.tcx, tables: self.tcx.body_tables(b), param_env: &ty::ParameterEnvironment::for_item(self.tcx, id) - }.visit_body(self.tcx.map.body(b)); + }.visit_body(self.tcx.hir.body(b)); } } @@ -152,7 +152,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { } } - let module = self.tcx.map.local_def_id(self.tcx.map.get_module_parent(scrut.id)); + let module = self.tcx.hir.local_def_id(self.tcx.hir.get_module_parent(scrut.id)); MatchCheckCtxt::create_and_enter(self.tcx, module, |ref mut cx| { let mut have_errors = false; @@ -195,7 +195,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { "local binding" }; - let module = self.tcx.map.local_def_id(self.tcx.map.get_module_parent(pat.id)); + let module = self.tcx.hir.local_def_id(self.tcx.hir.get_module_parent(pat.id)); MatchCheckCtxt::create_and_enter(self.tcx, module, |ref mut cx| { let mut patcx = PatternContext::new(self.tcx, self.tables); let pattern = patcx.lower_pattern(pat); diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 2325c37bc4050..e8055602087e5 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -53,15 +53,15 @@ macro_rules! math { fn lookup_variant_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, variant_def: DefId) -> Option<(&'tcx Expr, Option<&'a ty::TypeckTables<'tcx>>)> { - if let Some(variant_node_id) = tcx.map.as_local_node_id(variant_def) { - let enum_node_id = tcx.map.get_parent(variant_node_id); - if let Some(ast_map::NodeItem(it)) = tcx.map.find(enum_node_id) { + if let Some(variant_node_id) = tcx.hir.as_local_node_id(variant_def) { + let enum_node_id = tcx.hir.get_parent(variant_node_id); + if let Some(ast_map::NodeItem(it)) = tcx.hir.find(enum_node_id) { if let hir::ItemEnum(ref edef, _) = it.node { for variant in &edef.variants { if variant.node.data.id() == variant_node_id { return variant.node.disr_expr.map(|e| { - let def_id = tcx.map.body_owner_def_id(e); - (&tcx.map.body(e).value, + let def_id = tcx.hir.body_owner_def_id(e); + (&tcx.hir.body(e).value, tcx.tables.borrow().get(&def_id).cloned()) }); } @@ -83,8 +83,8 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> Option<(&'tcx Expr, Option<&'a ty::TypeckTables<'tcx>>, Option>)> { - if let Some(node_id) = tcx.map.as_local_node_id(def_id) { - match tcx.map.find(node_id) { + if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { + match tcx.hir.find(node_id) { None => None, Some(ast_map::NodeItem(&hir::Item { node: hir::ItemConst(ref ty, body), .. @@ -92,7 +92,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Some(ast_map::NodeImplItem(&hir::ImplItem { node: hir::ImplItemKind::Const(ref ty, body), .. })) => { - Some((&tcx.map.body(body).value, + Some((&tcx.hir.body(body).value, tcx.tables.borrow().get(&def_id).cloned(), tcx.ast_ty_to_prim_ty(ty))) } @@ -102,10 +102,10 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // If we have a trait item and the substitutions for it, // `resolve_trait_associated_const` will select an impl // or the default. - let trait_id = tcx.map.get_parent(node_id); - let trait_id = tcx.map.local_def_id(trait_id); + let trait_id = tcx.hir.get_parent(node_id); + let trait_id = tcx.hir.local_def_id(trait_id); let default_value = default.map(|body| { - (&tcx.map.body(body).value, + (&tcx.hir.body(body).value, tcx.tables.borrow().get(&def_id).cloned(), tcx.ast_ty_to_prim_ty(ty)) }); @@ -156,10 +156,10 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn lookup_const_fn_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option<(&'tcx hir::Body, Option<&'a ty::TypeckTables<'tcx>>)> { - if let Some(node_id) = tcx.map.as_local_node_id(def_id) { - FnLikeNode::from_node(tcx.map.get(node_id)).and_then(|fn_like| { + if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { + FnLikeNode::from_node(tcx.hir.get(node_id)).and_then(|fn_like| { if fn_like.constness() == hir::Constness::Const { - Some((tcx.map.body(fn_like.body()), + Some((tcx.hir.body(fn_like.body()), tcx.tables.borrow().get(&def_id).cloned())) } else { None @@ -232,7 +232,7 @@ pub struct ConstContext<'a, 'tcx: 'a> { impl<'a, 'tcx> ConstContext<'a, 'tcx> { pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, body: hir::BodyId) -> Self { - let def_id = tcx.map.body_owner_def_id(body); + let def_id = tcx.hir.body_owner_def_id(body); ConstContext { tcx: tcx, tables: tcx.tables.borrow().get(&def_id).cloned(), @@ -808,7 +808,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, _ => bug!() } } else { - let n = &tcx.map.body(count).value; + let n = &tcx.hir.body(count).value; match ConstContext::new(tcx, count).eval(n, len_hint)? { Integral(Usize(i)) => i.as_u64(tcx.sess.target.uint_type), Integral(_) => signal!(e, RepeatCountNotNatural), @@ -1203,7 +1203,7 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> Result { let hint = UncheckedExprHint(tcx.types.usize); - let count_expr = &tcx.map.body(count).value; + let count_expr = &tcx.hir.body(count).value; match ConstContext::new(tcx, count).eval(count_expr, hint) { Ok(Integral(Usize(count))) => { let val = count.as_u64(tcx.sess.target.uint_type); @@ -1227,7 +1227,7 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if let hir::ExprPath(hir::QPath::Resolved(None, ref path)) = count_expr.node { if let Def::Local(..) = path.def { diag.note(&format!("`{}` is a variable", - tcx.map.node_to_pretty_string(count_expr.id))); + tcx.hir.node_to_pretty_string(count_expr.id))); } } diff --git a/src/librustc_const_eval/pattern.rs b/src/librustc_const_eval/pattern.rs index 24c795befa3c8..a3b80ebddcf00 100644 --- a/src/librustc_const_eval/pattern.rs +++ b/src/librustc_const_eval/pattern.rs @@ -360,7 +360,7 @@ impl<'a, 'gcx, 'tcx> PatternContext<'a, 'gcx, 'tcx> { } PatKind::Binding(bm, def_id, ref ident, ref sub) => { - let id = self.tcx.map.as_local_node_id(def_id).unwrap(); + let id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let var_ty = self.tables.node_id_to_type(pat.id); let region = match var_ty.sty { ty::TyRef(r, _) => Some(r), diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 83dec4b0b77ab..1991fbb58edf1 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -181,7 +181,7 @@ pub fn compile_input(sess: &Session, outdir, output, opt_crate, - tcx.map.krate(), + tcx.hir.krate(), &analysis, tcx, &crate_name); diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index c5e0e8fb45f64..1885f76f1e4cd 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -502,7 +502,7 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> { } fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> { - Some(&self.tcx.map) + Some(&self.tcx.hir) } fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn { @@ -521,7 +521,7 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> { if let pprust_hir::Nested::Body(id) = nested { self.tables.set(self.tcx.body_tables(id)); } - pprust_hir::PpAnn::nested(&self.tcx.map, state, nested)?; + pprust_hir::PpAnn::nested(&self.tcx.hir, state, nested)?; self.tables.set(old_tables); Ok(()) } @@ -739,13 +739,13 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec, let cfg = match code { blocks::Code::Expr(expr) => cfg::CFG::new(tcx, expr), blocks::Code::FnLike(fn_like) => { - let body = tcx.map.body(fn_like.body()); + let body = tcx.hir.body(fn_like.body()); cfg::CFG::new(tcx, &body.value) }, }; let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges; let lcfg = LabelledCFG { - ast_map: &tcx.map, + ast_map: &tcx.hir, cfg: &cfg, name: format!("node_{}", code.id()), labelled_edges: labelled_edges, @@ -1005,7 +1005,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, match ppm { PpmMir | PpmMirCFG => { if let Some(nodeid) = nodeid { - let def_id = tcx.map.local_def_id(nodeid); + let def_id = tcx.hir.local_def_id(nodeid); match ppm { PpmMir => write_mir_pretty(tcx, iter::once(def_id), &mut out), PpmMirCFG => write_mir_graphviz(tcx, iter::once(def_id), &mut out), @@ -1030,11 +1030,11 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, let nodeid = nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \ suffix (b::c::d)"); - let node = tcx.map.find(nodeid).unwrap_or_else(|| { + let node = tcx.hir.find(nodeid).unwrap_or_else(|| { tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid)) }); - match blocks::Code::from_node(&tcx.map, nodeid) { + match blocks::Code::from_node(&tcx.hir, nodeid) { Some(code) => { let variants = gather_flowgraph_variants(tcx.sess); @@ -1047,7 +1047,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, got {:?}", node); - tcx.sess.span_fatal(tcx.map.span(nodeid), &message) + tcx.sess.span_fatal(tcx.hir.span(nodeid), &message) } } } diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 4ce5f96f171ed..0ac95d12eeef3 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -197,7 +197,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { #[allow(dead_code)] // this seems like it could be useful, even if we don't use it now pub fn lookup_item(&self, names: &[String]) -> ast::NodeId { - return match search_mod(self, &self.infcx.tcx.map.krate().module, 0, names) { + return match search_mod(self, &self.infcx.tcx.hir.krate().module, 0, names) { Some(id) => id, None => { panic!("no item found: `{}`", names.join("::")); @@ -211,7 +211,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { -> Option { assert!(idx < names.len()); for item in &m.item_ids { - let item = this.infcx.tcx.map.expect_item(item.id); + let item = this.infcx.tcx.hir.expect_item(item.id); if item.name.to_string() == names[idx] { return search(this, item, idx + 1, names); } diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index b5fe158f158ca..287ee7dd13e4e 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -79,8 +79,8 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut visitor = IfThisChanged { tcx: tcx, if_this_changed: vec![], then_this_would_need: vec![] }; - visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.map.krate().attrs); - tcx.map.krate().visit_all_item_likes(&mut visitor); + visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir.krate().attrs); + tcx.hir.krate().visit_all_item_likes(&mut visitor); (visitor.if_this_changed, visitor.then_this_would_need) }; @@ -120,7 +120,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> { } fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) { - let def_id = self.tcx.map.local_def_id(node_id); + let def_id = self.tcx.hir.local_def_id(node_id); for attr in attrs { if attr.check_name(ATTR_IF_THIS_CHANGED) { let dep_node_interned = self.argument(attr); diff --git a/src/librustc_incremental/calculate_svh/mod.rs b/src/librustc_incremental/calculate_svh/mod.rs index 49609fbc7984f..b9e6426dc01d8 100644 --- a/src/librustc_incremental/calculate_svh/mod.rs +++ b/src/librustc_incremental/calculate_svh/mod.rs @@ -102,7 +102,7 @@ impl<'a> ::std::ops::Index<&'a DepNode> for IncrementalHashesMap { pub fn compute_incremental_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> IncrementalHashesMap { let _ignore = tcx.dep_graph.in_ignore(); - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); let hash_spans = tcx.sess.opts.debuginfo != NoDebugInfo; let mut visitor = HashItemsVisitor { tcx: tcx, @@ -141,7 +141,7 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> { fn calculate_node_id(&mut self, id: ast::NodeId, walk_op: W) where W: for<'v> FnMut(&mut StrictVersionHashVisitor<'v, 'a, 'tcx>) { - let def_id = self.tcx.map.local_def_id(id); + let def_id = self.tcx.hir.local_def_id(id); self.calculate_def_id(def_id, walk_op) } @@ -178,7 +178,7 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> { } fn compute_crate_hash(&mut self) { - let krate = self.tcx.map.krate(); + let krate = self.tcx.hir.krate(); let mut crate_state = IchHasher::new(); diff --git a/src/librustc_incremental/calculate_svh/svh_visitor.rs b/src/librustc_incremental/calculate_svh/svh_visitor.rs index 3427a42526181..69237f406760d 100644 --- a/src/librustc_incremental/calculate_svh/svh_visitor.rs +++ b/src/librustc_incremental/calculate_svh/svh_visitor.rs @@ -561,7 +561,7 @@ macro_rules! hash_span { impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'hash, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> visit::NestedVisitorMap<'this, 'tcx> { if self.hash_bodies { - visit::NestedVisitorMap::OnlyBodies(&self.tcx.map) + visit::NestedVisitorMap::OnlyBodies(&self.tcx.hir) } else { visit::NestedVisitorMap::None } diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 4cefc16efe5ab..6e66dac6470f0 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -72,7 +72,7 @@ pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .collect(); let query = tcx.dep_graph.query(); debug!("query-nodes: {:?}", query.nodes()); - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); krate.visit_all_item_likes(&mut DirtyCleanVisitor { tcx: tcx, query: &query, @@ -171,7 +171,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { - let def_id = self.tcx.map.local_def_id(item.id); + let def_id = self.tcx.hir.local_def_id(item.id); for attr in self.tcx.get_attrs(def_id).iter() { if attr.check_name(ATTR_DIRTY) { if check_config(self.tcx, attr) { @@ -200,7 +200,7 @@ pub fn check_dirty_clean_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } tcx.dep_graph.with_ignore(||{ - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); krate.visit_all_item_likes(&mut DirtyCleanMetadataVisitor { tcx: tcx, prev_metadata_hashes: prev_metadata_hashes, @@ -217,7 +217,7 @@ pub struct DirtyCleanMetadataVisitor<'a, 'tcx:'a, 'm> { impl<'a, 'tcx, 'm> ItemLikeVisitor<'tcx> for DirtyCleanMetadataVisitor<'a, 'tcx, 'm> { fn visit_item(&mut self, item: &'tcx hir::Item) { - let def_id = self.tcx.map.local_def_id(item.id); + let def_id = self.tcx.hir.local_def_id(item.id); for attr in self.tcx.get_attrs(def_id).iter() { if attr.check_name(ATTR_DIRTY_METADATA) { diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index 2baef47c214c2..d4ab31da8a31e 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -28,7 +28,7 @@ pub enum MethodLateContext { } pub fn method_context(cx: &LateContext, id: ast::NodeId, span: Span) -> MethodLateContext { - let def_id = cx.tcx.map.local_def_id(id); + let def_id = cx.tcx.hir.local_def_id(id); match cx.tcx.associated_items.borrow().get(&def_id) { None => span_bug!(span, "missing method descriptor?!"), Some(item) => { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 8d86e7e2e8b9e..2892d61b8bd6f 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -117,7 +117,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { hir::ItemEnum(..) | hir::ItemStruct(..) | hir::ItemUnion(..) => { - let def_id = cx.tcx.map.local_def_id(it.id); + let def_id = cx.tcx.hir.local_def_id(it.id); self.check_heap_type(cx, it.span, cx.tcx.item_type(def_id)) } _ => () @@ -128,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { hir::ItemStruct(ref struct_def, _) | hir::ItemUnion(ref struct_def, _) => { for struct_field in struct_def.fields() { - let def_id = cx.tcx.map.local_def_id(struct_field.id); + let def_id = cx.tcx.hir.local_def_id(struct_field.id); self.check_heap_type(cx, struct_field.span, cx.tcx.item_type(def_id)); } @@ -390,8 +390,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc { // If the trait is private, add the impl items to private_traits so they don't get // reported for missing docs. let real_trait = trait_ref.path.def.def_id(); - if let Some(node_id) = cx.tcx.map.as_local_node_id(real_trait) { - match cx.tcx.map.find(node_id) { + if let Some(node_id) = cx.tcx.hir.as_local_node_id(real_trait) { + match cx.tcx.hir.find(node_id) { Some(hir_map::NodeItem(item)) => { if item.vis == hir::Visibility::Inherited { for impl_item_ref in impl_item_refs { @@ -504,21 +504,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations { if ast_generics.is_parameterized() { return; } - let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id)); + let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } hir::ItemUnion(_, ref ast_generics) => { if ast_generics.is_parameterized() { return; } - let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id)); + let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } hir::ItemEnum(_, ref ast_generics) => { if ast_generics.is_parameterized() { return; } - let def = cx.tcx.lookup_adt_def(cx.tcx.map.local_def_id(item.id)); + let def = cx.tcx.lookup_adt_def(cx.tcx.hir.local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } _ => return, @@ -586,7 +586,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { let mut impls = NodeSet(); debug_def.for_each_impl(cx.tcx, |d| { if let Some(ty_def) = cx.tcx.item_type(d).ty_to_def_id() { - if let Some(node_id) = cx.tcx.map.as_local_node_id(ty_def) { + if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def) { impls.insert(node_id); } } @@ -680,7 +680,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { let method = match fn_kind { FnKind::ItemFn(..) => None, FnKind::Method(..) => { - Some(cx.tcx.associated_item(cx.tcx.map.local_def_id(id))) + Some(cx.tcx.associated_item(cx.tcx.hir.local_def_id(id))) } // closures can't recur, so they don't matter. FnKind::Closure(_) => return, @@ -745,7 +745,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { false }; if self_recursive { - self_call_spans.push(cx.tcx.map.span(node_id)); + self_call_spans.push(cx.tcx.hir.span(node_id)); // this is a self call, so we shouldn't explore past // this node in the CFG. continue; @@ -788,14 +788,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { // represents a call to the function `fn_id`/method `method`. fn expr_refers_to_this_fn(cx: &LateContext, fn_id: ast::NodeId, id: ast::NodeId) -> bool { - match cx.tcx.map.get(id) { + match cx.tcx.hir.get(id) { hir_map::NodeExpr(&hir::Expr { node: hir::ExprCall(ref callee, _), .. }) => { let def = if let hir::ExprPath(ref qpath) = callee.node { cx.tables.qpath_def(qpath, callee.id) } else { return false; }; - def.def_id() == cx.tcx.map.local_def_id(fn_id) + def.def_id() == cx.tcx.hir.local_def_id(fn_id) } _ => false, } @@ -830,7 +830,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { } // Check for calls to methods via explicit paths (e.g. `T::method()`). - match cx.tcx.map.get(id) { + match cx.tcx.hir.get(id) { hir_map::NodeExpr(&hir::Expr { node: hir::ExprCall(ref callee, _), .. }) => { let def = if let hir::ExprPath(ref qpath) = callee.node { cx.tables.qpath_def(qpath, callee.id) @@ -871,7 +871,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { ty::TraitContainer(trait_def_id) => { let trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, callee_substs); let trait_ref = ty::Binder(trait_ref); - let span = tcx.map.span(expr_id); + let span = tcx.hir.span(expr_id); let obligation = traits::Obligation::new(traits::ObligationCause::misc(span, expr_id), trait_ref.to_poly_trait_predicate()); @@ -879,7 +879,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { // unwrap() is ok here b/c `method` is the method // defined in this crate whose body we are // checking, so it's always local - let node_id = tcx.map.as_local_node_id(method.def_id).unwrap(); + let node_id = tcx.hir.as_local_node_id(method.def_id).unwrap(); let param_env = ty::ParameterEnvironment::for_item(tcx, node_id); tcx.infer_ctxt(param_env, Reveal::NotSpecializable).enter(|infcx| { @@ -1151,7 +1151,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields { if let hir::ItemUnion(ref vdata, _) = item.node { let param_env = &ty::ParameterEnvironment::for_item(ctx.tcx, item.id); for field in vdata.fields() { - let field_ty = ctx.tcx.item_type(ctx.tcx.map.local_def_id(field.id)); + let field_ty = ctx.tcx.item_type(ctx.tcx.hir.local_def_id(field.id)); if ctx.tcx.type_needs_drop_given_env(field_ty, param_env) { ctx.span_lint(UNIONS_WITH_DROP_FIELDS, field.span, diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 2a77e9a4a7c8b..532e602226450 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -631,7 +631,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) { - let def_id = self.cx.tcx.map.local_def_id(id); + let def_id = self.cx.tcx.hir.local_def_id(id); let sig = self.cx.tcx.item_type(def_id).fn_sig(); let sig = self.cx.tcx.erase_late_bound_regions(&sig); @@ -648,7 +648,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) { - let def_id = self.cx.tcx.map.local_def_id(id); + let def_id = self.cx.tcx.hir.local_def_id(id); let ty = self.cx.tcx.item_type(def_id); self.check_type_for_ffi_and_report_errors(span, ty); } @@ -696,7 +696,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { if let hir::ItemEnum(ref enum_definition, ref gens) = it.node { if gens.ty_params.is_empty() { // sizes only make sense for non-generic types - let t = cx.tcx.item_type(cx.tcx.map.local_def_id(it.id)); + let t = cx.tcx.item_type(cx.tcx.hir.local_def_id(it.id)); let layout = cx.tcx.infer_ctxt((), Reveal::All).enter(|infcx| { let ty = cx.tcx.erase_regions(&t); ty.layout(&infcx).unwrap_or_else(|e| { diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 48d9f5e72c26d..a85b47c8ada7a 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -64,7 +64,7 @@ impl UnusedMut { for (_, v) in &mutables { if !v.iter().any(|e| used_mutables.contains(e)) { cx.span_lint(UNUSED_MUT, - cx.tcx.map.span(v[0]), + cx.tcx.hir.span(v[0]), "variable does not need to be mutable"); } } diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index ef7bb80312eb5..459132eb9c613 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -28,7 +28,7 @@ pub struct Ast<'tcx> { impl<'a, 'tcx> EncodeContext<'a, 'tcx> { pub fn encode_body(&mut self, body_id: hir::BodyId) -> Lazy> { - let body = self.tcx.map.body(body_id); + let body = self.tcx.hir.body(body_id); let lazy_body = self.lazy(body); let tables = self.tcx.body_tables(body_id); @@ -67,7 +67,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for NestedBodyEncodingVisitor<'a, 'b, 'tcx> { } fn visit_nested_body(&mut self, body: hir::BodyId) { - let body = self.ecx.tcx.map.body(body); + let body = self.ecx.tcx.hir.body(body); body.encode(self.ecx).unwrap(); self.count += 1; diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index f6107bc135915..d100cb53a8b01 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -428,7 +428,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { def_id: DefId) -> Option<&'tcx hir::Body> { - if let Some(cached) = tcx.map.get_inlined_body(def_id) { + if let Some(cached) = tcx.hir.get_inlined_body(def_id) { return Some(cached); } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 4abdee345c298..101531b52afb8 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -776,7 +776,7 @@ impl<'a, 'tcx> CrateMetadata { tcx.tables.borrow_mut().insert(def_id, tcx.alloc_tables(tables)); let body = ast.body.decode((self, tcx)); - tcx.map.intern_inlined_body(def_id, body) + tcx.hir.intern_inlined_body(def_id, body) }) } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 7de768b7b9049..2f71776ecf758 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -267,8 +267,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { struct_ctor: None, }; - let enum_id = tcx.map.as_local_node_id(enum_did).unwrap(); - let enum_vis = &tcx.map.expect_item(enum_id).vis; + let enum_id = tcx.hir.as_local_node_id(enum_did).unwrap(); + let enum_vis = &tcx.hir.expect_item(enum_id).vis; Entry { kind: EntryKind::Variant(self.lazy(&data)), @@ -299,7 +299,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { &hir::Visibility)>) -> Entry<'tcx> { let tcx = self.tcx; - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); let data = ModData { reexports: match self.reexports.get(&id) { @@ -314,7 +314,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { span: self.lazy(&md.inner), attributes: self.encode_attributes(attrs), children: self.lazy_seq(md.item_ids.iter().map(|item_id| { - tcx.map.local_def_id(item_id.id).index + tcx.hir.local_def_id(item_id.id).index })), stability: self.encode_stability(def_id), deprecation: self.encode_deprecation(def_id), @@ -361,8 +361,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let field = &variant.fields[field_index]; let def_id = field.did; - let variant_id = tcx.map.as_local_node_id(variant.did).unwrap(); - let variant_data = tcx.map.expect_variant_data(variant_id); + let variant_id = tcx.hir.as_local_node_id(variant.did).unwrap(); + let variant_data = tcx.hir.expect_variant_data(variant_id); Entry { kind: EntryKind::Field, @@ -394,8 +394,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { struct_ctor: Some(def_id.index), }; - let struct_id = tcx.map.as_local_node_id(adt_def_id).unwrap(); - let struct_vis = &tcx.map.expect_item(struct_id).vis; + let struct_id = tcx.hir.as_local_node_id(adt_def_id).unwrap(); + let struct_vis = &tcx.hir.expect_item(struct_id).vis; Entry { kind: EntryKind::Struct(self.lazy(&data)), @@ -430,8 +430,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { fn encode_info_for_trait_item(&mut self, def_id: DefId) -> Entry<'tcx> { let tcx = self.tcx; - let node_id = tcx.map.as_local_node_id(def_id).unwrap(); - let ast_item = tcx.map.expect_trait_item(node_id); + let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let ast_item = tcx.hir.expect_trait_item(node_id); let trait_item = tcx.associated_item(def_id); let container = match trait_item.defaultness { @@ -508,8 +508,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_info_for_impl_item(&mut self, def_id: DefId) -> Entry<'tcx> { - let node_id = self.tcx.map.as_local_node_id(def_id).unwrap(); - let ast_item = self.tcx.map.expect_impl_item(node_id); + let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); + let ast_item = self.tcx.hir.expect_impl_item(node_id); let impl_item = self.tcx.associated_item(def_id); let container = match impl_item.defaultness { @@ -576,7 +576,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { fn encode_fn_arg_names_for_body(&mut self, body_id: hir::BodyId) -> LazySeq { let _ignore = self.tcx.dep_graph.in_ignore(); - let body = self.tcx.map.body(body_id); + let body = self.tcx.hir.body(body_id); self.lazy_seq(body.arguments.iter().map(|arg| { match arg.pat.node { PatKind::Binding(_, _, name, _) => name.node, @@ -646,7 +646,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { // for methods, write all the stuff get_trait_method // needs to know let struct_ctor = if !struct_def.is_struct() { - Some(tcx.map.local_def_id(struct_def.id()).index) + Some(tcx.hir.local_def_id(struct_def.id()).index) } else { None }; @@ -725,7 +725,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { hir::ItemForeignMod(ref fm) => { self.lazy_seq(fm.items .iter() - .map(|foreign_item| tcx.map.local_def_id(foreign_item.id).index)) + .map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index)) } hir::ItemEnum(..) => { let def = self.tcx.lookup_adt_def(def_id); @@ -855,7 +855,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { /// so it's easier to do that here then to wait until we would encounter /// normally in the visitor walk. fn encode_addl_info_for_item(&mut self, item: &hir::Item) { - let def_id = self.tcx.map.local_def_id(item.id); + let def_id = self.tcx.hir.local_def_id(item.id); match item.node { hir::ItemStatic(..) | hir::ItemConst(..) | @@ -883,7 +883,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { // If the struct has a constructor, encode it. if !struct_def.is_struct() { - let ctor_def_id = self.tcx.map.local_def_id(struct_def.id()); + let ctor_def_id = self.tcx.hir.local_def_id(struct_def.id()); self.record(ctor_def_id, EncodeContext::encode_struct_ctor, (def_id, ctor_def_id)); @@ -957,7 +957,7 @@ struct EncodeVisitor<'a, 'b: 'a, 'tcx: 'b> { impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.index.tcx.map) + NestedVisitorMap::OnlyBodies(&self.index.tcx.hir) } fn visit_expr(&mut self, ex: &'tcx hir::Expr) { intravisit::walk_expr(self, ex); @@ -965,7 +965,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { } fn visit_item(&mut self, item: &'tcx hir::Item) { intravisit::walk_item(self, item); - let def_id = self.index.tcx.map.local_def_id(item.id); + let def_id = self.index.tcx.hir.local_def_id(item.id); match item.node { hir::ItemExternCrate(_) | hir::ItemUse(..) => (), // ignore these @@ -975,7 +975,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { } fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) { intravisit::walk_foreign_item(self, ni); - let def_id = self.index.tcx.map.local_def_id(ni.id); + let def_id = self.index.tcx.hir.local_def_id(ni.id); self.index.record(def_id, EncodeContext::encode_info_for_foreign_item, (def_id, ni)); @@ -985,7 +985,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { self.index.encode_info_for_ty(ty); } fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef) { - let def_id = self.index.tcx.map.local_def_id(macro_def.id); + let def_id = self.index.tcx.hir.local_def_id(macro_def.id); self.index.record(def_id, EncodeContext::encode_info_for_macro_def, macro_def); } } @@ -993,7 +993,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { fn encode_info_for_ty(&mut self, ty: &hir::Ty) { if let hir::TyImplTrait(_) = ty.node { - let def_id = self.tcx.map.local_def_id(ty.id); + let def_id = self.tcx.hir.local_def_id(ty.id); self.record(def_id, EncodeContext::encode_info_for_anon_ty, def_id); } } @@ -1001,7 +1001,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { fn encode_info_for_expr(&mut self, expr: &hir::Expr) { match expr.node { hir::ExprClosure(..) => { - let def_id = self.tcx.map.local_def_id(expr.id); + let def_id = self.tcx.hir.local_def_id(expr.id); self.record(def_id, EncodeContext::encode_info_for_closure, def_id); } _ => {} @@ -1061,7 +1061,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_info_for_items(&mut self) -> Index { - let krate = self.tcx.map.krate(); + let krate = self.tcx.hir.krate(); let mut index = IndexBuilder::new(self); index.record(DefId::local(CRATE_DEF_INDEX), EncodeContext::encode_info_for_mod, @@ -1145,7 +1145,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_def_path_table(&mut self) -> Lazy { - let definitions = self.tcx.map.definitions(); + let definitions = self.tcx.hir.definitions(); self.lazy(definitions.def_path_table()) } } @@ -1158,7 +1158,7 @@ struct ImplVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { if let hir::ItemImpl(..) = item.node { - let impl_id = self.tcx.map.local_def_id(item.id); + let impl_id = self.tcx.hir.local_def_id(item.id); if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) { self.impls .entry(trait_ref.def_id) @@ -1182,7 +1182,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { tcx: self.tcx, impls: FxHashMap(), }; - self.tcx.map.krate().visit_all_item_likes(&mut visitor); + self.tcx.hir.krate().visit_all_item_likes(&mut visitor); let all_impls: Vec<_> = visitor.impls .into_iter() @@ -1206,7 +1206,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { fn encode_exported_symbols(&mut self) -> LazySeq { let exported_symbols = self.exported_symbols; let tcx = self.tcx; - self.lazy_seq(exported_symbols.iter().map(|&id| tcx.map.local_def_id(id).index)) + self.lazy_seq(exported_symbols.iter().map(|&id| tcx.hir.local_def_id(id).index)) } fn encode_dylib_dependency_formats(&mut self) -> LazySeq> { @@ -1283,10 +1283,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { plugin_registrar_fn: tcx.sess .plugin_registrar_fn .get() - .map(|id| tcx.map.local_def_id(id).index), + .map(|id| tcx.hir.local_def_id(id).index), macro_derive_registrar: if is_proc_macro { let id = tcx.sess.derive_registrar_fn.get().unwrap(); - Some(tcx.map.local_def_id(id).index) + Some(tcx.hir.local_def_id(id).index) } else { None }, diff --git a/src/librustc_metadata/index_builder.rs b/src/librustc_metadata/index_builder.rs index 1a74a92545477..2359c747d888d 100644 --- a/src/librustc_metadata/index_builder.rs +++ b/src/librustc_metadata/index_builder.rs @@ -90,7 +90,7 @@ impl<'a, 'b, 'tcx> DerefMut for IndexBuilder<'a, 'b, 'tcx> { impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { pub fn new(ecx: &'a mut EncodeContext<'b, 'tcx>) -> Self { IndexBuilder { - items: Index::new(ecx.tcx.map.num_local_def_ids()), + items: Index::new(ecx.tcx.hir.num_local_def_ids()), ecx: ecx, } } @@ -186,7 +186,7 @@ macro_rules! read_hir { ($t:ty) => { impl<'tcx> DepGraphRead for &'tcx $t { fn read(&self, tcx: TyCtxt) { - tcx.map.read(self.id); + tcx.hir.read(self.id); } } } @@ -220,6 +220,6 @@ pub struct FromId(pub ast::NodeId, pub T); impl DepGraphRead for FromId { fn read(&self, tcx: TyCtxt) { - tcx.map.read(self.0); + tcx.hir.read(self.0); } } diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index 2c7b47c766999..73d3875ba2384 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -58,7 +58,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let_extent_stack.push(remainder_scope); // Declare the bindings, which may create a visibility scope. - let remainder_span = remainder_scope.span(&tcx.region_maps, &tcx.map); + let remainder_span = remainder_scope.span(&tcx.region_maps, &tcx.hir); let remainder_span = remainder_span.unwrap_or(span); let scope = this.declare_bindings(None, remainder_span, &pattern); diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 7347841a5f1ef..ecdc58ba55d6c 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -133,7 +133,7 @@ pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, let arguments: Vec<_> = arguments.collect(); let tcx = hir.tcx(); - let span = tcx.map.span(fn_id); + let span = tcx.hir.span(fn_id); let mut builder = Builder::new(hir, span, arguments.len(), return_ty); let call_site_extent = @@ -168,7 +168,7 @@ pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, // Gather the upvars of a closure, if any. let upvar_decls: Vec<_> = tcx.with_freevars(fn_id, |freevars| { freevars.iter().map(|fv| { - let var_id = tcx.map.as_local_node_id(fv.def.def_id()).unwrap(); + let var_id = tcx.hir.as_local_node_id(fv.def.def_id()).unwrap(); let by_ref = hir.tables().upvar_capture(ty::UpvarId { var_id: var_id, closure_expr_id: fn_id @@ -180,7 +180,7 @@ pub fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, debug_name: keywords::Invalid.name(), by_ref: by_ref }; - if let Some(hir::map::NodeLocal(pat)) = tcx.map.find(var_id) { + if let Some(hir::map::NodeLocal(pat)) = tcx.hir.find(var_id) { if let hir::PatKind::Binding(_, _, ref ident, _) = pat.node { decl.debug_name = ident.node; } @@ -198,9 +198,9 @@ pub fn construct_const<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>, body_id: hir::BodyId) -> Mir<'tcx> { let tcx = hir.tcx(); - let ast_expr = &tcx.map.body(body_id).value; + let ast_expr = &tcx.hir.body(body_id).value; let ty = hir.tables().expr_ty_adjusted(ast_expr); - let span = tcx.map.span(tcx.map.body_owner(body_id)); + let span = tcx.hir.span(tcx.hir.body_owner(body_id)); let mut builder = Builder::new(hir, span, 0, ty); let extent = tcx.region_maps.temporary_scope(ast_expr.id) diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 59a11782e0856..c702a142fab34 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -499,7 +499,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { scope.needs_cleanup = true; } let tcx = self.hir.tcx(); - let extent_span = extent.span(&tcx.region_maps, &tcx.map).unwrap(); + let extent_span = extent.span(&tcx.region_maps, &tcx.hir).unwrap(); // Attribute scope exit drops to scope's closing brace let scope_end = Span { lo: extent_span.hi, .. extent_span}; scope.drops.push(DropData { diff --git a/src/librustc_mir/graphviz.rs b/src/librustc_mir/graphviz.rs index dd4dd4699d858..91600b947c610 100644 --- a/src/librustc_mir/graphviz.rs +++ b/src/librustc_mir/graphviz.rs @@ -26,7 +26,7 @@ pub fn write_mir_graphviz<'a, 'b, 'tcx, W, I>(tcx: TyCtxt<'b, 'tcx, 'tcx>, where W: Write, I: Iterator { for def_id in iter { - let nodeid = tcx.map.as_local_node_id(def_id).unwrap(); + let nodeid = tcx.hir.as_local_node_id(def_id).unwrap(); let mir = &tcx.item_mir(def_id); writeln!(w, "digraph Mir_{} {{", nodeid)?; diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index cdf7cae3020c8..c4c6ec6b8f400 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -574,7 +574,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, // Now comes the rote stuff: hir::ExprRepeat(ref v, count) => { let tcx = cx.tcx.global_tcx(); - let c = &cx.tcx.map.body(count).value; + let c = &cx.tcx.hir.body(count).value; let count = match ConstContext::new(tcx, count).eval(c, EvalHint::ExprTypeChecked) { Ok(ConstVal::Integral(ConstInt::Usize(u))) => u, Ok(other) => bug!("constant evaluation of repeat count yielded {:?}", other), @@ -765,19 +765,19 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, match def { Def::Local(def_id) => { - let node_id = cx.tcx.map.as_local_node_id(def_id).unwrap(); + let node_id = cx.tcx.hir.as_local_node_id(def_id).unwrap(); ExprKind::VarRef { id: node_id } } Def::Upvar(def_id, index, closure_expr_id) => { - let id_var = cx.tcx.map.as_local_node_id(def_id).unwrap(); + let id_var = cx.tcx.hir.as_local_node_id(def_id).unwrap(); debug!("convert_var(upvar({:?}, {:?}, {:?}))", id_var, index, closure_expr_id); let var_ty = cx.tables().node_id_to_type(id_var); - let body_id = match cx.tcx.map.find(closure_expr_id) { + let body_id = match cx.tcx.hir.find(closure_expr_id) { Some(map::NodeExpr(expr)) => { match expr.node { hir::ExprClosure(.., body, _) => body.node_id, @@ -803,7 +803,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, }); let region = cx.tcx.mk_region(region); - let self_expr = match cx.tcx.closure_kind(cx.tcx.map.local_def_id(closure_expr_id)) { + let self_expr = match cx.tcx.closure_kind(cx.tcx.hir.local_def_id(closure_expr_id)) { ty::ClosureKind::Fn => { let ref_closure_ty = cx.tcx.mk_ref(region, ty::TypeAndMut { @@ -1013,7 +1013,7 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, freevar: &hir::Freevar, freevar_ty: Ty<'tcx>) -> ExprRef<'tcx> { - let id_var = cx.tcx.map.as_local_node_id(freevar.def.def_id()).unwrap(); + let id_var = cx.tcx.hir.as_local_node_id(freevar.def.def_id()).unwrap(); let upvar_id = ty::UpvarId { var_id: id_var, closure_expr_id: closure_expr.id, diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 533d804a23651..5b3297cb694e8 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -45,13 +45,13 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { MirSource::Const(_) | MirSource::Static(..) => hir::Constness::Const, MirSource::Fn(id) => { - let fn_like = FnLikeNode::from_node(infcx.tcx.map.get(id)); + let fn_like = FnLikeNode::from_node(infcx.tcx.hir.get(id)); fn_like.map_or(hir::Constness::NotConst, |f| f.constness()) } MirSource::Promoted(..) => bug!(), }; - let attrs = infcx.tcx.map.attrs(src.item_id()); + let attrs = infcx.tcx.hir.attrs(src.item_id()); // Some functions always have overflow checks enabled, // however, they may not get codegen'd, depending on diff --git a/src/librustc_mir/mir_map.rs b/src/librustc_mir/mir_map.rs index 453c3e43b6b86..c71255dcc7c61 100644 --- a/src/librustc_mir/mir_map.rs +++ b/src/librustc_mir/mir_map.rs @@ -84,7 +84,7 @@ fn build<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, -> (Mir<'tcx>, MirSource) { let tcx = infcx.tcx.global_tcx(); - let item_id = tcx.map.body_owner(body_id); + let item_id = tcx.hir.body_owner(body_id); let src = MirSource::from_node(tcx, item_id); let cx = Cx::new(infcx, src); if let MirSource::Fn(id) = src { @@ -92,14 +92,14 @@ fn build<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, // types/lifetimes replaced) let fn_sig = cx.tables().liberated_fn_sigs[&id].clone(); - let ty = tcx.item_type(tcx.map.local_def_id(id)); + let ty = tcx.item_type(tcx.hir.local_def_id(id)); let (abi, implicit_argument) = if let ty::TyClosure(..) = ty.sty { (Abi::Rust, Some((closure_self_ty(tcx, id, body_id), None))) } else { (ty.fn_abi(), None) }; - let body = tcx.map.body(body_id); + let body = tcx.hir.body(body_id); let explicit_arguments = body.arguments .iter() @@ -138,11 +138,11 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> { pretty::dump_mir(tcx, "mir_map", &0, src, &mir); let mir = tcx.alloc_mir(mir); - let def_id = tcx.map.local_def_id(src.item_id()); + let def_id = tcx.hir.local_def_id(src.item_id()); assert!(tcx.mir_map.borrow_mut().insert(def_id, mir).is_none()); }); - let body = self.tcx.map.body(body_id); + let body = self.tcx.hir.body(body_id); self.visit_body(body); } } @@ -162,7 +162,7 @@ fn closure_self_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }); let region = tcx.mk_region(region); - match tcx.closure_kind(tcx.map.local_def_id(closure_expr_id)) { + match tcx.closure_kind(tcx.hir.local_def_id(closure_expr_id)) { ty::ClosureKind::Fn => tcx.mk_ref(region, ty::TypeAndMut { ty: closure_ty, diff --git a/src/librustc_mir/pretty.rs b/src/librustc_mir/pretty.rs index e7188d536980f..bfe3e143e7c50 100644 --- a/src/librustc_mir/pretty.rs +++ b/src/librustc_mir/pretty.rs @@ -48,7 +48,7 @@ pub fn dump_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Some(ref filters) => filters, }; let node_id = src.item_id(); - let node_path = tcx.item_path_str(tcx.map.local_def_id(node_id)); + let node_path = tcx.item_path_str(tcx.hir.local_def_id(node_id)); let is_matched = filters.split("&") .any(|filter| { @@ -102,7 +102,7 @@ pub fn write_mir_pretty<'a, 'b, 'tcx, I>(tcx: TyCtxt<'b, 'tcx, 'tcx>, writeln!(w, "")?; } - let id = tcx.map.as_local_node_id(def_id).unwrap(); + let id = tcx.hir.as_local_node_id(def_id).unwrap(); let src = MirSource::from_node(tcx, id); write_mir_fn(tcx, src, mir, w)?; diff --git a/src/librustc_mir/transform/copy_prop.rs b/src/librustc_mir/transform/copy_prop.rs index 3cbf8573ba97f..2194c20c2f442 100644 --- a/src/librustc_mir/transform/copy_prop.rs +++ b/src/librustc_mir/transform/copy_prop.rs @@ -57,7 +57,7 @@ impl<'tcx> MirPass<'tcx> for CopyPropagation { return } MirSource::Fn(function_node_id) => { - if qualify_consts::is_const_fn(tcx, tcx.map.local_def_id(function_node_id)) { + if qualify_consts::is_const_fn(tcx, tcx.hir.local_def_id(function_node_id)) { // Don't run on const functions, as, again, trans might not be able to evaluate // the optimized IR. return diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs index 771f05f7bccfe..3a93bef36c5f7 100644 --- a/src/librustc_mir/transform/deaggregator.rs +++ b/src/librustc_mir/transform/deaggregator.rs @@ -21,7 +21,7 @@ impl<'tcx> MirPass<'tcx> for Deaggregator { fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, source: MirSource, mir: &mut Mir<'tcx>) { let node_id = source.item_id(); - let node_path = tcx.item_path_str(tcx.map.local_def_id(node_id)); + let node_path = tcx.item_path_str(tcx.hir.local_def_id(node_id)); debug!("running on: {:?}", node_path); // we only run when mir_opt_level > 2 if tcx.sess.opts.debugging_opts.mir_opt_level <= 2 { diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index fea27ee5c5483..af9f7fb578138 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -115,8 +115,8 @@ impl fmt::Display for Mode { } pub fn is_const_fn(tcx: TyCtxt, def_id: DefId) -> bool { - if let Some(node_id) = tcx.map.as_local_node_id(def_id) { - if let Some(fn_like) = FnLikeNode::from_node(tcx.map.get(node_id)) { + if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { + if let Some(fn_like) = FnLikeNode::from_node(tcx.hir.get(node_id)) { fn_like.constness() == hir::Constness::Const } else { false @@ -267,15 +267,15 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { self.tcx .lookup_trait_def(drop_trait_id) .for_each_relevant_impl(self.tcx, self.mir.return_ty, |impl_did| { - self.tcx.map + self.tcx.hir .as_local_node_id(impl_did) - .and_then(|impl_node_id| self.tcx.map.find(impl_node_id)) + .and_then(|impl_node_id| self.tcx.hir.find(impl_node_id)) .map(|node| { if let hir_map::NodeItem(item) = node { if let hir::ItemImpl(.., ref impl_item_refs) = item.node { span = impl_item_refs.first() .map(|iiref| { - self.tcx.map.impl_item(iiref.id) + self.tcx.hir.impl_item(iiref.id) .span }); } @@ -953,7 +953,7 @@ fn qualify_const_item_cached<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let param_env = if def_id.is_local() { - let node_id = tcx.map.as_local_node_id(def_id).unwrap(); + let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); ty::ParameterEnvironment::for_item(tcx, node_id) } else { // These should only be monomorphic constants. @@ -978,7 +978,7 @@ impl<'tcx> MirPass<'tcx> for QualifyAndPromoteConstants { fn run_pass<'a>(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, src: MirSource, mir: &mut Mir<'tcx>) { let id = src.item_id(); - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); let mode = match src { MirSource::Fn(_) => { if is_const_fn(tcx, def_id) { diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index fa148da2e3996..b6241c618df2f 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -98,8 +98,8 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> { fn handle_const_fn_call(&mut self, def_id: DefId, ret_ty: Ty<'gcx>) { self.add_type(ret_ty); - self.promotable &= if let Some(fn_id) = self.tcx.map.as_local_node_id(def_id) { - FnLikeNode::from_node(self.tcx.map.get(fn_id)).map_or(false, |fn_like| { + self.promotable &= if let Some(fn_id) = self.tcx.hir.as_local_node_id(def_id) { + FnLikeNode::from_node(self.tcx.hir.get(fn_id)).map_or(false, |fn_like| { fn_like.constness() == hir::Constness::Const }) } else { @@ -122,7 +122,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> { } } - let item_id = self.tcx.map.body_owner(body_id); + let item_id = self.tcx.hir.body_owner(body_id); let outer_in_fn = self.in_fn; self.in_fn = match MirSource::from_node(self.tcx, item_id) { @@ -131,9 +131,9 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> { }; let outer_tables = self.tables; - self.tables = self.tcx.item_tables(self.tcx.map.local_def_id(item_id)); + self.tables = self.tcx.item_tables(self.tcx.hir.local_def_id(item_id)); - let body = self.tcx.map.body(body_id); + let body = self.tcx.hir.body(body_id); if !self.in_fn { self.check_const_eval(&body.value); } @@ -329,8 +329,8 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node Def::Fn(..) | Def::Method(..) => {} Def::AssociatedConst(_) => v.add_type(node_ty), Def::Const(did) => { - v.promotable &= if let Some(node_id) = v.tcx.map.as_local_node_id(did) { - match v.tcx.map.expect_item(node_id).node { + v.promotable &= if let Some(node_id) = v.tcx.hir.as_local_node_id(did) { + match v.tcx.hir.expect_item(node_id).node { hir::ItemConst(_, body) => { v.visit_nested_body(body); v.tcx.rvalue_promotable_to_static.borrow()[&body.node_id] diff --git a/src/librustc_passes/rvalues.rs b/src/librustc_passes/rvalues.rs index 78b591a48cca5..9de5ff541a52c 100644 --- a/src/librustc_passes/rvalues.rs +++ b/src/librustc_passes/rvalues.rs @@ -37,7 +37,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RvalueContext<'a, 'tcx> { } fn visit_nested_body(&mut self, body_id: hir::BodyId) { - let body = self.tcx.map.body(body_id); + let body = self.tcx.hir.body(body_id); self.tcx.infer_ctxt(body_id, Reveal::NotSpecializable).enter(|infcx| { let mut delegate = RvalueContextDelegate { tcx: infcx.tcx, diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 445da5a8c3f4e..7357d6f38b651 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -75,7 +75,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { ty::TyProjection(ref proj) => proj.trait_ref.def_id, _ => return Some(AccessLevel::Public) }; - if let Some(node_id) = self.tcx.map.as_local_node_id(ty_def_id) { + if let Some(node_id) = self.tcx.hir.as_local_node_id(ty_def_id) { self.get(node_id) } else { Some(AccessLevel::Public) @@ -84,7 +84,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { fn impl_trait_level(&self, impl_def_id: DefId) -> Option { if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_def_id) { - if let Some(node_id) = self.tcx.map.as_local_node_id(trait_ref.def_id) { + if let Some(node_id) = self.tcx.hir.as_local_node_id(trait_ref.def_id) { return self.get(node_id); } } @@ -111,7 +111,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { fn reach<'b>(&'b mut self, item_id: ast::NodeId) -> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> { ReachEverythingInTheInterfaceVisitor { - item_def_id: self.tcx.map.local_def_id(item_id), + item_def_id: self.tcx.hir.local_def_id(item_id), ev: self, } } @@ -121,18 +121,18 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { /// We want to visit items in the context of their containing /// module and so forth, so supply a crate for doing a deep walk. fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::All(&self.tcx.map) + NestedVisitorMap::All(&self.tcx.hir) } fn visit_item(&mut self, item: &'tcx hir::Item) { let inherited_item_level = match item.node { // Impls inherit level from their types and traits hir::ItemImpl(..) => { - let def_id = self.tcx.map.local_def_id(item.id); + let def_id = self.tcx.hir.local_def_id(item.id); cmp::min(self.item_ty_level(def_id), self.impl_trait_level(def_id)) } hir::ItemDefaultImpl(..) => { - let def_id = self.tcx.map.local_def_id(item.id); + let def_id = self.tcx.hir.local_def_id(item.id); self.impl_trait_level(def_id) } // Foreign mods inherit level from parents @@ -306,7 +306,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { if self.prev_level.is_some() { if let Some(exports) = self.export_map.get(&id) { for export in exports { - if let Some(node_id) = self.tcx.map.as_local_node_id(export.def.def_id()) { + if let Some(node_id) = self.tcx.hir.as_local_node_id(export.def.def_id()) { self.update(node_id, Some(AccessLevel::Exported)); } } @@ -366,7 +366,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b }; if let Some(def_id) = ty_def_id { - if let Some(node_id) = self.ev.tcx.map.as_local_node_id(def_id) { + if let Some(node_id) = self.ev.tcx.hir.as_local_node_id(def_id) { self.ev.update(node_id, Some(AccessLevel::Reachable)); } } @@ -375,8 +375,8 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b } fn visit_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>) -> bool { - if let Some(node_id) = self.ev.tcx.map.as_local_node_id(trait_ref.def_id) { - let item = self.ev.tcx.map.expect_item(node_id); + if let Some(node_id) = self.ev.tcx.hir.as_local_node_id(trait_ref.def_id) { + let item = self.ev.tcx.hir.expect_item(node_id); self.ev.update(item.id, Some(AccessLevel::Reachable)); } @@ -397,9 +397,9 @@ struct PrivacyVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { fn item_is_accessible(&self, did: DefId) -> bool { - match self.tcx.map.as_local_node_id(did) { + match self.tcx.hir.as_local_node_id(did) { Some(node_id) => - ty::Visibility::from_hir(&self.tcx.map.expect_item(node_id).vis, node_id, self.tcx), + ty::Visibility::from_hir(&self.tcx.hir.expect_item(node_id).vis, node_id, self.tcx), None => self.tcx.sess.cstore.visibility(did), }.is_accessible_from(self.curitem, self.tcx) } @@ -433,19 +433,19 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivacyVisitor<'a, 'tcx> { /// We want to visit items in the context of their containing /// module and so forth, so supply a crate for doing a deep walk. fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::All(&self.tcx.map) + NestedVisitorMap::All(&self.tcx.hir) } fn visit_nested_body(&mut self, body: hir::BodyId) { let old_tables = self.tables; self.tables = self.tcx.body_tables(body); - let body = self.tcx.map.body(body); + let body = self.tcx.hir.body(body); self.visit_body(body); self.tables = old_tables; } fn visit_item(&mut self, item: &'tcx hir::Item) { - let orig_curitem = replace(&mut self.curitem, self.tcx.map.local_def_id(item.id)); + let orig_curitem = replace(&mut self.curitem, self.tcx.hir.local_def_id(item.id)); intravisit::walk_item(self, item); self.curitem = orig_curitem; } @@ -492,8 +492,8 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivacyVisitor<'a, 'tcx> { error.span_label(expr.span, &format!("cannot construct with a private field")); - if let Some(node_id) = self.tcx.map.as_local_node_id(adt_def.did) { - let node = self.tcx.map.find(node_id); + if let Some(node_id) = self.tcx.hir.as_local_node_id(adt_def.did) { + let node = self.tcx.hir.find(node_id); if let Some(hir::map::NodeStructCtor(vdata)) = node { for i in private_indexes { error.span_label(vdata.fields()[i].span, @@ -590,10 +590,10 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // A path can only be private if: // it's in this crate... - if let Some(node_id) = self.tcx.map.as_local_node_id(did) { + if let Some(node_id) = self.tcx.hir.as_local_node_id(did) { // .. and it corresponds to a private type in the AST (this returns // None for type parameters) - match self.tcx.map.find(node_id) { + match self.tcx.hir.find(node_id) { Some(hir::map::NodeItem(ref item)) => item.vis != hir::Public, Some(_) | None => false, } @@ -653,7 +653,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { /// We want to visit items in the context of their containing /// module and so forth, so supply a crate for doing a deep walk. fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::All(&self.tcx.map) + NestedVisitorMap::All(&self.tcx.hir) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -709,7 +709,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { |tr| { let did = tr.path.def.def_id(); - if let Some(node_id) = self.tcx.map.as_local_node_id(did) { + if let Some(node_id) = self.tcx.hir.as_local_node_id(did) { self.trait_is_public(node_id) } else { true // external traits must be public @@ -728,7 +728,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { trait_ref.is_some() || impl_item_refs.iter() .any(|impl_item_ref| { - let impl_item = self.tcx.map.impl_item(impl_item_ref.id); + let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); match impl_item.node { hir::ImplItemKind::Const(..) | hir::ImplItemKind::Method(..) => { @@ -752,7 +752,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // should only walk into public items so that we // don't erroneously report errors for private // types in private items. - let impl_item = self.tcx.map.impl_item(impl_item_ref.id); + let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); match impl_item.node { hir::ImplItemKind::Const(..) | hir::ImplItemKind::Method(..) @@ -785,7 +785,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { // Those in 3. are warned with this call. for impl_item_ref in impl_item_refs { - let impl_item = self.tcx.map.impl_item(impl_item_ref.id); + let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); if let hir::ImplItemKind::Type(ref ty) = impl_item.node { self.visit_ty(ty); } @@ -798,7 +798,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { let mut found_pub_static = false; for impl_item_ref in impl_item_refs { if self.item_is_public(&impl_item_ref.id.node_id, &impl_item_ref.vis) { - let impl_item = self.tcx.map.impl_item(impl_item_ref.id); + let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); match impl_item_ref.kind { hir::AssociatedItemKind::Const => { found_pub_static = true; @@ -962,8 +962,8 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<' if let Some(def_id) = ty_def_id { // Non-local means public (private items can't leave their crate, modulo bugs) - if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) { - let item = self.tcx.map.expect_item(node_id); + if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { + let item = self.tcx.hir.expect_item(node_id); let vis = ty::Visibility::from_hir(&item.vis, node_id, self.tcx); if !vis.is_at_least(self.min_visibility, self.tcx) { @@ -997,8 +997,8 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<' fn visit_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>) -> bool { // Non-local means public (private items can't leave their crate, modulo bugs) - if let Some(node_id) = self.tcx.map.as_local_node_id(trait_ref.def_id) { - let item = self.tcx.map.expect_item(node_id); + if let Some(node_id) = self.tcx.hir.as_local_node_id(trait_ref.def_id) { + let item = self.tcx.hir.expect_item(node_id); let vis = ty::Visibility::from_hir(&item.vis, node_id, self.tcx); if !vis.is_at_least(self.min_visibility, self.tcx) { @@ -1045,7 +1045,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { has_old_errors = true; break; } - let parent = self.tcx.map.get_parent_node(id); + let parent = self.tcx.hir.get_parent_node(id); if parent == id { break; } @@ -1059,8 +1059,8 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { SearchInterfaceForPrivateItemsVisitor { tcx: self.tcx, - item_def_id: self.tcx.map.local_def_id(item_id), - span: self.tcx.map.span(item_id), + item_def_id: self.tcx.hir.local_def_id(item_id), + span: self.tcx.hir.span(item_id), min_visibility: ty::Visibility::Public, required_visibility: required_visibility, has_old_errors: has_old_errors, @@ -1070,7 +1070,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.map) + NestedVisitorMap::OnlyBodies(&self.tcx.hir) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -1148,7 +1148,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> self.check(item.id, ty_vis).generics().predicates(); for impl_item_ref in impl_item_refs { - let impl_item = self.tcx.map.impl_item(impl_item_ref.id); + let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); let impl_item_vis = ty::Visibility::from_hir(&impl_item.vis, item.id, tcx); self.check(impl_item.id, min(impl_item_vis, ty_vis)) @@ -1166,7 +1166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> .item_type().impl_trait_ref().min_visibility; self.check(item.id, vis).generics().predicates(); for impl_item_ref in impl_item_refs { - let impl_item = self.tcx.map.impl_item(impl_item_ref.id); + let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); self.check(impl_item.id, vis).generics().predicates().item_type(); // Recurse for e.g. `impl Trait` (see `visit_ty`). @@ -1205,7 +1205,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> AccessLevels { let _task = tcx.dep_graph.in_task(DepNode::Privacy); - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); // Use the parent map to check the privacy of everything let mut visitor = PrivacyVisitor { diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index e5c41d08e1f67..74521fe465bcd 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -112,7 +112,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>) { let old_tables = self.save_ctxt.tables; - let item_def_id = self.tcx.map.local_def_id(item_id); + let item_def_id = self.tcx.hir.local_def_id(item_id); self.save_ctxt.tables = self.tcx.item_tables(item_def_id); f(self); self.save_ctxt.tables = old_tables; @@ -399,7 +399,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { // with the right name. if !self.span.filter_generated(Some(method_data.span), span) { let container = - self.tcx.associated_item(self.tcx.map.local_def_id(id)).container; + self.tcx.associated_item(self.tcx.hir.local_def_id(id)).container; let mut trait_id; let mut decl_id = None; match container { @@ -418,7 +418,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { } } None => { - if let Some(NodeItem(item)) = self.tcx.map.get_if_local(id) { + if let Some(NodeItem(item)) = self.tcx.hir.get_if_local(id) { if let hir::ItemImpl(_, _, _, _, ref ty, _) = item.node { trait_id = self.lookup_def_id(ty.id); } @@ -693,7 +693,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { type_value: enum_data.qualname.clone(), value: val, scope: enum_data.scope, - parent: Some(make_def_id(item.id, &self.tcx.map)), + parent: Some(make_def_id(item.id, &self.tcx.hir)), docs: docs_for_attrs(&variant.node.attrs), sig: sig, }.lower(self.tcx)); @@ -719,7 +719,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { type_value: enum_data.qualname.clone(), value: val, scope: enum_data.scope, - parent: Some(make_def_id(item.id, &self.tcx.map)), + parent: Some(make_def_id(item.id, &self.tcx.hir)), docs: docs_for_attrs(&variant.node.attrs), sig: sig, }.lower(self.tcx)); @@ -775,7 +775,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { } self.process_generic_params(type_parameters, item.span, "", item.id); for impl_item in impl_items { - let map = &self.tcx.map; + let map = &self.tcx.hir; self.process_impl_item(impl_item, make_def_id(item.id, map)); } } @@ -848,7 +848,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { // walk generics and methods self.process_generic_params(generics, item.span, &qualname, item.id); for method in methods { - let map = &self.tcx.map; + let map = &self.tcx.hir; self.process_trait_item(method, make_def_id(item.id, map)) } } @@ -1383,7 +1383,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, visit::walk_expr(self, ex); } ast::ExprKind::Struct(ref path, ref fields, ref base) => { - let hir_expr = self.save_ctxt.tcx.map.expect_expr(ex.id); + let hir_expr = self.save_ctxt.tcx.hir.expect_expr(ex.id); let adt = match self.save_ctxt.tables.expr_ty_opt(&hir_expr) { Some(ty) => ty.ty_adt_def().unwrap(), None => { @@ -1408,7 +1408,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, ast::ExprKind::TupField(ref sub_ex, idx) => { self.visit_expr(&sub_ex); - let hir_node = match self.save_ctxt.tcx.map.find(sub_ex.id) { + let hir_node = match self.save_ctxt.tcx.hir.find(sub_ex.id) { Some(Node::NodeExpr(expr)) => expr, _ => { debug!("Missing or weird node for sub-expression {} in {:?}", @@ -1510,7 +1510,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, for &(id, ref p, immut, ref_kind) in &collector.collected_paths { match self.save_ctxt.get_path_def(id) { Def::Local(def_id) => { - let id = self.tcx.map.as_local_node_id(def_id).unwrap(); + let id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let mut value = if immut == ast::Mutability::Immutable { self.span.snippet(p.span).to_string() } else { diff --git a/src/librustc_save_analysis/external_data.rs b/src/librustc_save_analysis/external_data.rs index 18ae3a7fa9ea8..fccb56e88b3de 100644 --- a/src/librustc_save_analysis/external_data.rs +++ b/src/librustc_save_analysis/external_data.rs @@ -105,13 +105,13 @@ impl Lower for data::EnumData { fn lower(self, tcx: TyCtxt) -> EnumData { EnumData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), name: self.name, value: self.value, qualname: self.qualname, span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), - variants: self.variants.into_iter().map(|id| make_def_id(id, &tcx.map)).collect(), + scope: make_def_id(self.scope, &tcx.hir), + variants: self.variants.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(), visibility: self.visibility, docs: self.docs, sig: self.sig.lower(tcx), @@ -135,12 +135,12 @@ impl Lower for data::ExternCrateData { fn lower(self, tcx: TyCtxt) -> ExternCrateData { ExternCrateData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), name: self.name, crate_num: self.crate_num, location: self.location, span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), } } } @@ -159,7 +159,7 @@ impl Lower for data::FunctionCallData { fn lower(self, tcx: TyCtxt) -> FunctionCallData { FunctionCallData { span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), ref_id: self.ref_id, } } @@ -186,12 +186,12 @@ impl Lower for data::FunctionData { fn lower(self, tcx: TyCtxt) -> FunctionData { FunctionData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), name: self.name, qualname: self.qualname, declaration: self.declaration, span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), value: self.value, visibility: self.visibility, parent: self.parent, @@ -215,7 +215,7 @@ impl Lower for data::FunctionRefData { fn lower(self, tcx: TyCtxt) -> FunctionRefData { FunctionRefData { span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), ref_id: self.ref_id, } } @@ -234,9 +234,9 @@ impl Lower for data::ImplData { fn lower(self, tcx: TyCtxt) -> ImplData { ImplData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), trait_ref: self.trait_ref, self_ref: self.self_ref, } @@ -257,7 +257,7 @@ impl Lower for data::InheritanceData { InheritanceData { span: SpanData::from_span(self.span, tcx.sess.codemap()), base_id: self.base_id, - deriv_id: make_def_id(self.deriv_id, &tcx.map) + deriv_id: make_def_id(self.deriv_id, &tcx.hir) } } } @@ -305,7 +305,7 @@ impl Lower for data::MacroUseData { name: self.name, qualname: self.qualname, callee_span: SpanData::from_span(self.callee_span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), } } } @@ -325,7 +325,7 @@ impl Lower for data::MethodCallData { fn lower(self, tcx: TyCtxt) -> MethodCallData { MethodCallData { span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), ref_id: self.ref_id, decl_id: self.decl_id, } @@ -355,8 +355,8 @@ impl Lower for data::MethodData { MethodData { span: SpanData::from_span(self.span, tcx.sess.codemap()), name: self.name, - scope: make_def_id(self.scope, &tcx.map), - id: make_def_id(self.id, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), + id: make_def_id(self.id, &tcx.hir), qualname: self.qualname, value: self.value, decl_id: self.decl_id, @@ -388,13 +388,13 @@ impl Lower for data::ModData { fn lower(self, tcx: TyCtxt) -> ModData { ModData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), name: self.name, qualname: self.qualname, span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), filename: self.filename, - items: self.items.into_iter().map(|id| make_def_id(id, &tcx.map)).collect(), + items: self.items.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(), visibility: self.visibility, docs: self.docs, sig: self.sig.lower(tcx), @@ -417,7 +417,7 @@ impl Lower for data::ModRefData { fn lower(self, tcx: TyCtxt) -> ModRefData { ModRefData { span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), ref_id: self.ref_id, qualname: self.qualname, } @@ -446,12 +446,12 @@ impl Lower for data::StructData { StructData { span: SpanData::from_span(self.span, tcx.sess.codemap()), name: self.name, - id: make_def_id(self.id, &tcx.map), - ctor_id: make_def_id(self.ctor_id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), + ctor_id: make_def_id(self.ctor_id, &tcx.hir), qualname: self.qualname, - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), value: self.value, - fields: self.fields.into_iter().map(|id| make_def_id(id, &tcx.map)).collect(), + fields: self.fields.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(), visibility: self.visibility, docs: self.docs, sig: self.sig.lower(tcx), @@ -480,11 +480,11 @@ impl Lower for data::StructVariantData { StructVariantData { span: SpanData::from_span(self.span, tcx.sess.codemap()), name: self.name, - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), qualname: self.qualname, type_value: self.type_value, value: self.value, - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), parent: self.parent, docs: self.docs, sig: self.sig.lower(tcx), @@ -513,11 +513,11 @@ impl Lower for data::TraitData { TraitData { span: SpanData::from_span(self.span, tcx.sess.codemap()), name: self.name, - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), qualname: self.qualname, - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), value: self.value, - items: self.items.into_iter().map(|id| make_def_id(id, &tcx.map)).collect(), + items: self.items.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(), visibility: self.visibility, docs: self.docs, sig: self.sig.lower(tcx), @@ -545,12 +545,12 @@ impl Lower for data::TupleVariantData { fn lower(self, tcx: TyCtxt) -> TupleVariantData { TupleVariantData { span: SpanData::from_span(self.span, tcx.sess.codemap()), - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), name: self.name, qualname: self.qualname, type_value: self.type_value, value: self.value, - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), parent: self.parent, docs: self.docs, sig: self.sig.lower(tcx), @@ -577,7 +577,7 @@ impl Lower for data::TypeDefData { fn lower(self, tcx: TyCtxt) -> TypeDefData { TypeDefData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), name: self.name, span: SpanData::from_span(self.span, tcx.sess.codemap()), qualname: self.qualname, @@ -605,7 +605,7 @@ impl Lower for data::TypeRefData { fn lower(self, tcx: TyCtxt) -> TypeRefData { TypeRefData { span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), ref_id: self.ref_id, qualname: self.qualname, } @@ -627,11 +627,11 @@ impl Lower for data::UseData { fn lower(self, tcx: TyCtxt) -> UseData { UseData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), span: SpanData::from_span(self.span, tcx.sess.codemap()), name: self.name, mod_id: self.mod_id, - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), visibility: self.visibility, } } @@ -651,10 +651,10 @@ impl Lower for data::UseGlobData { fn lower(self, tcx: TyCtxt) -> UseGlobData { UseGlobData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), span: SpanData::from_span(self.span, tcx.sess.codemap()), names: self.names, - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), visibility: self.visibility, } } @@ -682,12 +682,12 @@ impl Lower for data::VariableData { fn lower(self, tcx: TyCtxt) -> VariableData { VariableData { - id: make_def_id(self.id, &tcx.map), + id: make_def_id(self.id, &tcx.hir), kind: self.kind, name: self.name, qualname: self.qualname, span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), value: self.value, type_value: self.type_value, parent: self.parent, @@ -715,7 +715,7 @@ impl Lower for data::VariableRefData { VariableRefData { name: self.name, span: SpanData::from_span(self.span, tcx.sess.codemap()), - scope: make_def_id(self.scope, &tcx.map), + scope: make_def_id(self.scope, &tcx.hir), ref_id: self.ref_id, } } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index ded59cfccf134..8d0cdd1678c73 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -285,7 +285,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident); let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); filter!(self.span_utils, sub_span, field.span, None); - let def_id = self.tcx.map.local_def_id(field.id); + let def_id = self.tcx.hir.local_def_id(field.id); let typ = self.tcx.item_type(def_id).to_string(); let span = field.span; @@ -307,7 +307,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { qualname: qualname, span: sub_span.unwrap(), scope: scope, - parent: Some(make_def_id(scope, &self.tcx.map)), + parent: Some(make_def_id(scope, &self.tcx.hir)), value: "".to_owned(), type_value: typ, visibility: From::from(&field.vis), @@ -326,13 +326,13 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { // The qualname for a method is the trait name or name of the struct in an impl in // which the method is declared in, followed by the method's name. let (qualname, parent_scope, decl_id, vis, docs) = - match self.tcx.impl_of_method(self.tcx.map.local_def_id(id)) { - Some(impl_id) => match self.tcx.map.get_if_local(impl_id) { + match self.tcx.impl_of_method(self.tcx.hir.local_def_id(id)) { + Some(impl_id) => match self.tcx.hir.get_if_local(impl_id) { Some(Node::NodeItem(item)) => { match item.node { hir::ItemImpl(.., ref ty, _) => { let mut result = String::from("<"); - result.push_str(&self.tcx.map.node_to_pretty_string(ty.id)); + result.push_str(&self.tcx.hir.node_to_pretty_string(ty.id)); let trait_id = self.tcx.trait_id_of_impl(impl_id); let mut decl_id = None; @@ -365,9 +365,9 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { r); } }, - None => match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) { + None => match self.tcx.trait_of_item(self.tcx.hir.local_def_id(id)) { Some(def_id) => { - match self.tcx.map.get_if_local(def_id) { + match self.tcx.hir.get_if_local(def_id) { Some(Node::NodeItem(item)) => { (format!("::{}", self.tcx.item_path_str(def_id)), Some(def_id), None, @@ -442,14 +442,14 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } pub fn get_expr_data(&self, expr: &ast::Expr) -> Option { - let hir_node = self.tcx.map.expect_expr(expr.id); + let hir_node = self.tcx.hir.expect_expr(expr.id); let ty = self.tables.expr_ty_adjusted_opt(&hir_node); if ty.is_none() || ty.unwrap().sty == ty::TyError { return None; } match expr.node { ast::ExprKind::Field(ref sub_ex, ident) => { - let hir_node = match self.tcx.map.find(sub_ex.id) { + let hir_node = match self.tcx.hir.find(sub_ex.id) { Some(Node::NodeExpr(expr)) => expr, _ => { debug!("Missing or weird node for sub-expression {} in {:?}", @@ -523,7 +523,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } pub fn get_path_def(&self, id: NodeId) -> Def { - match self.tcx.map.get(id) { + match self.tcx.hir.get(id) { Node::NodeTraitRef(tr) => tr.path.def, Node::NodeItem(&hir::Item { node: hir::ItemUse(ref path, _), .. }) | @@ -733,7 +733,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { #[inline] pub fn enclosing_scope(&self, id: NodeId) -> NodeId { - self.tcx.map.get_enclosing_scope(id).unwrap_or(CRATE_NODE_ID) + self.tcx.hir.get_enclosing_scope(id).unwrap_or(CRATE_NODE_ID) } } diff --git a/src/librustc_trans/assert_module_sources.rs b/src/librustc_trans/assert_module_sources.rs index 898e65ce391e6..7a41f8341099b 100644 --- a/src/librustc_trans/assert_module_sources.rs +++ b/src/librustc_trans/assert_module_sources.rs @@ -50,7 +50,7 @@ pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let ams = AssertModuleSource { tcx: tcx, modules: modules }; - for attr in &tcx.map.krate().attrs { + for attr in &tcx.hir.krate().attrs { ams.check_attr(attr); } } diff --git a/src/librustc_trans/back/symbol_export.rs b/src/librustc_trans/back/symbol_export.rs index 5f16291892387..81be2d02f125b 100644 --- a/src/librustc_trans/back/symbol_export.rs +++ b/src/librustc_trans/back/symbol_export.rs @@ -48,7 +48,7 @@ impl ExportedSymbols { .exported_symbols() .iter() .map(|&node_id| { - scx.tcx().map.local_def_id(node_id) + scx.tcx().hir.local_def_id(node_id) }) .map(|def_id| { let name = symbol_for_def_id(scx, def_id, symbol_map); @@ -64,7 +64,7 @@ impl ExportedSymbols { if let Some(id) = scx.sess().derive_registrar_fn.get() { let svh = &scx.link_meta().crate_hash; - let def_id = scx.tcx().map.local_def_id(id); + let def_id = scx.tcx().hir.local_def_id(id); let idx = def_id.index; let registrar = scx.sess().generate_derive_registrar_symbol(svh, idx); local_crate.push((registrar, SymbolExportLevel::C)); @@ -181,7 +181,7 @@ fn symbol_for_def_id<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>, -> String { // Just try to look things up in the symbol map. If nothing's there, we // recompute. - if let Some(node_id) = scx.tcx().map.as_local_node_id(def_id) { + if let Some(node_id) = scx.tcx().hir.as_local_node_id(def_id) { if let Some(sym) = symbol_map.get(TransItem::Static(node_id)) { return sym.to_owned(); } diff --git a/src/librustc_trans/back/symbol_names.rs b/src/librustc_trans/back/symbol_names.rs index 8f8c48a06b2c0..20338e4f6afb0 100644 --- a/src/librustc_trans/back/symbol_names.rs +++ b/src/librustc_trans/back/symbol_names.rs @@ -175,7 +175,7 @@ impl<'a, 'tcx> Instance<'tcx> { debug!("symbol_name(def_id={:?}, substs={:?})", def_id, substs); - let node_id = scx.tcx().map.as_local_node_id(def_id); + let node_id = scx.tcx().hir.as_local_node_id(def_id); if let Some(id) = node_id { if scx.sess().plugin_registrar_fn.get() == Some(id) { @@ -193,7 +193,7 @@ impl<'a, 'tcx> Instance<'tcx> { // FIXME(eddyb) Precompute a custom symbol name based on attributes. let attrs = scx.tcx().get_attrs(def_id); let is_foreign = if let Some(id) = node_id { - match scx.tcx().map.get(id) { + match scx.tcx().hir.get(id) { hir_map::NodeForeignItem(_) => true, _ => false } diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index d006dccbccc58..32fe3effcc9f8 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -710,7 +710,7 @@ pub fn set_link_section(ccx: &CrateContext, pub fn maybe_create_entry_wrapper(ccx: &CrateContext) { let (main_def_id, span) = match *ccx.sess().entry_fn.borrow() { Some((id, span)) => { - (ccx.tcx().map.local_def_id(id), span) + (ccx.tcx().hir.local_def_id(id), span) } None => return, }; @@ -1075,9 +1075,9 @@ pub fn find_exported_symbols(tcx: TyCtxt, reachable: NodeSet) -> NodeSet { // // As a result, if this id is an FFI item (foreign item) then we only // let it through if it's included statically. - match tcx.map.get(id) { + match tcx.hir.get(id) { hir_map::NodeForeignItem(..) => { - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); tcx.sess.cstore.is_statically_included_foreign_item(def_id) } @@ -1088,7 +1088,7 @@ pub fn find_exported_symbols(tcx: TyCtxt, reachable: NodeSet) -> NodeSet { node: hir::ItemFn(..), .. }) | hir_map::NodeImplItem(&hir::ImplItem { node: hir::ImplItemKind::Method(..), .. }) => { - let def_id = tcx.map.local_def_id(id); + let def_id = tcx.hir.local_def_id(id); let generics = tcx.item_generics(def_id); let attributes = tcx.get_attrs(def_id); (generics.parent_types == 0 && generics.types.is_empty()) && @@ -1112,7 +1112,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // entire contents of the krate. So if you push any subtasks of // `TransCrate`, you need to be careful to register "reads" of the // particular items that will be processed. - let krate = tcx.map.krate(); + let krate = tcx.hir.krate(); let ty::CrateAnalysis { export_map, reachable, name, .. } = analysis; let exported_symbols = find_exported_symbols(tcx, reachable); diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 5e409a2aa5520..d30766dc5392a 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -309,7 +309,7 @@ fn collect_roots<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>, output: &mut roots, }; - scx.tcx().map.krate().visit_all_item_likes(&mut visitor); + scx.tcx().hir.krate().visit_all_item_likes(&mut visitor); } roots @@ -336,7 +336,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(scx: &SharedCrateContext<'a, 'tcx>, recursion_depth_reset = None; } TransItem::Static(node_id) => { - let def_id = scx.tcx().map.local_def_id(node_id); + let def_id = scx.tcx().hir.local_def_id(node_id); // Sanity check whether this ended up being collected accidentally debug_assert!(should_trans_locally(scx.tcx(), def_id)); @@ -406,8 +406,8 @@ fn check_recursion_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if recursion_depth > tcx.sess.recursion_limit.get() { let error = format!("reached the recursion limit while instantiating `{}`", instance); - if let Some(node_id) = tcx.map.as_local_node_id(instance.def) { - tcx.sess.span_fatal(tcx.map.span(node_id), &error); + if let Some(node_id) = tcx.hir.as_local_node_id(instance.def) { + tcx.sess.span_fatal(tcx.hir.span(node_id), &error); } else { tcx.sess.fatal(&error); } @@ -438,8 +438,8 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let instance_name = instance.to_string(); let msg = format!("reached the type-length limit while instantiating `{:.64}...`", instance_name); - let mut diag = if let Some(node_id) = tcx.map.as_local_node_id(instance.def) { - tcx.sess.struct_span_fatal(tcx.map.span(node_id), &msg) + let mut diag = if let Some(node_id) = tcx.hir.as_local_node_id(instance.def) { + tcx.sess.struct_span_fatal(tcx.hir.span(node_id), &msg) } else { tcx.sess.struct_fatal(&msg) }; @@ -619,7 +619,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { // Some constructors also have type TyFnDef but they are // always instantiated inline and don't result in a // translation item. Same for FFI functions. - if let Some(hir_map::NodeForeignItem(_)) = tcx.map.get_if_local(def_id) { + if let Some(hir_map::NodeForeignItem(_)) = tcx.hir.get_if_local(def_id) { return false; } @@ -1152,7 +1152,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { hir::ItemUnion(_, ref generics) => { if !generics.is_parameterized() { if self.mode == TransItemCollectionMode::Eager { - let def_id = self.scx.tcx().map.local_def_id(item.id); + let def_id = self.scx.tcx().hir.local_def_id(item.id); debug!("RootCollector: ADT drop-glue for {}", def_id_to_string(self.scx.tcx(), def_id)); @@ -1165,7 +1165,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { hir::ItemStatic(..) => { debug!("RootCollector: ItemStatic({})", def_id_to_string(self.scx.tcx(), - self.scx.tcx().map.local_def_id(item.id))); + self.scx.tcx().hir.local_def_id(item.id))); self.output.push(TransItem::Static(item.id)); } hir::ItemConst(..) => { @@ -1174,7 +1174,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { } hir::ItemFn(.., ref generics, _) => { if !generics.is_type_parameterized() { - let def_id = self.scx.tcx().map.local_def_id(item.id); + let def_id = self.scx.tcx().hir.local_def_id(item.id); debug!("RootCollector: ItemFn({})", def_id_to_string(self.scx.tcx(), def_id)); @@ -1197,7 +1197,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { ref generics, .. }, _) => { - let hir_map = &self.scx.tcx().map; + let hir_map = &self.scx.tcx().hir; let parent_node_id = hir_map.get_parent_node(ii.id); let is_impl_generic = match hir_map.expect_item(parent_node_id) { &hir::Item { @@ -1212,7 +1212,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { }; if !generics.is_type_parameterized() && !is_impl_generic { - let def_id = self.scx.tcx().map.local_def_id(ii.id); + let def_id = self.scx.tcx().hir.local_def_id(ii.id); debug!("RootCollector: MethodImplItem({})", def_id_to_string(self.scx.tcx(), def_id)); @@ -1240,7 +1240,7 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(scx: &SharedCrateContext<'a, ' return } - let impl_def_id = tcx.map.local_def_id(item.id); + let impl_def_id = tcx.hir.local_def_id(item.id); debug!("create_trans_items_for_default_impls(item={})", def_id_to_string(tcx, impl_def_id)); diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index a9c1edfdc66cc..b68de7b46c82e 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -85,10 +85,10 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef { } let ty = ccx.tcx().item_type(def_id); - let g = if let Some(id) = ccx.tcx().map.as_local_node_id(def_id) { + let g = if let Some(id) = ccx.tcx().hir.as_local_node_id(def_id) { let llty = type_of::type_of(ccx, ty); - let (g, attrs) = match ccx.tcx().map.get(id) { + let (g, attrs) = match ccx.tcx().hir.get(id) { hir_map::NodeItem(&hir::Item { ref attrs, span, node: hir::ItemStatic(..), .. }) => { @@ -219,7 +219,7 @@ pub fn trans_static(ccx: &CrateContext, attrs: &[ast::Attribute]) -> Result { unsafe { - let def_id = ccx.tcx().map.local_def_id(id); + let def_id = ccx.tcx().hir.local_def_id(id); let g = get_static(ccx, def_id); let v = ::mir::trans_static_initializer(ccx, def_id)?; diff --git a/src/librustc_trans/debuginfo/gdb.rs b/src/librustc_trans/debuginfo/gdb.rs index e8728a3999308..4567ec8b452df 100644 --- a/src/librustc_trans/debuginfo/gdb.rs +++ b/src/librustc_trans/debuginfo/gdb.rs @@ -79,7 +79,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext) pub fn needs_gdb_debug_scripts_section(ccx: &CrateContext) -> bool { let omit_gdb_pretty_printer_section = - attr::contains_name(&ccx.tcx().map.krate_attrs(), + attr::contains_name(&ccx.tcx().hir.krate_attrs(), "omit_gdb_pretty_printer_section"); !omit_gdb_pretty_printer_section && diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index 1473e55b2643c..0de3c13dc21a9 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -1738,7 +1738,7 @@ pub fn create_global_var_metadata(cx: &CrateContext, let tcx = cx.tcx(); - let node_def_id = tcx.map.local_def_id(node_id); + let node_def_id = tcx.hir.local_def_id(node_id); let (var_scope, span) = get_namespace_and_span_for_item(cx, node_def_id); let (file_metadata, line_number) = if span != syntax_pos::DUMMY_SP { diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 9117f49cf3ea5..f05d48566daae 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -251,7 +251,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let scope_line = span_start(cx, span).line; - let local_id = cx.tcx().map.as_local_node_id(instance.def); + let local_id = cx.tcx().hir.as_local_node_id(instance.def); let is_local_to_unit = local_id.map_or(false, |id| is_node_local_to_unit(cx, id)); let function_name = CString::new(name).unwrap(); diff --git a/src/librustc_trans/declare.rs b/src/librustc_trans/declare.rs index 9bf023fc18936..bf7a02eb0f196 100644 --- a/src/librustc_trans/declare.rs +++ b/src/librustc_trans/declare.rs @@ -76,7 +76,7 @@ fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty: // compiler-rt, then we want to implicitly compile everything with hidden // visibility as we're going to link this object all over the place but // don't want the symbols to get exported. - if attr::contains_name(ccx.tcx().map.krate_attrs(), "compiler_builtins") { + if attr::contains_name(ccx.tcx().hir.krate_attrs(), "compiler_builtins") { unsafe { llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden); } diff --git a/src/librustc_trans/partitioning.rs b/src/librustc_trans/partitioning.rs index d1d167306c1fd..706f131ed627f 100644 --- a/src/librustc_trans/partitioning.rs +++ b/src/librustc_trans/partitioning.rs @@ -186,7 +186,7 @@ impl<'tcx> CodegenUnit<'tcx> { symbol_name.hash(&mut state); let exported = match item { TransItem::Fn(ref instance) => { - let node_id = scx.tcx().map.as_local_node_id(instance.def); + let node_id = scx.tcx().hir.as_local_node_id(instance.def); node_id.map(|node_id| exported_symbols.contains(&node_id)) .unwrap_or(false) } @@ -241,7 +241,7 @@ impl<'tcx> CodegenUnit<'tcx> { fn local_node_id(tcx: TyCtxt, trans_item: TransItem) -> Option { match trans_item { TransItem::Fn(instance) => { - tcx.map.as_local_node_id(instance.def) + tcx.hir.as_local_node_id(instance.def) } TransItem::Static(node_id) => Some(node_id), TransItem::DropGlue(_) => None, @@ -482,7 +482,7 @@ fn characteristic_def_id_of_trans_item<'a, 'tcx>(scx: &SharedCrateContext<'a, 't Some(instance.def) } TransItem::DropGlue(dg) => characteristic_def_id_of_type(dg.ty()), - TransItem::Static(node_id) => Some(tcx.map.local_def_id(node_id)), + TransItem::Static(node_id) => Some(tcx.hir.local_def_id(node_id)), } } diff --git a/src/librustc_trans/symbol_map.rs b/src/librustc_trans/symbol_map.rs index c3e0ac1fee515..880c65937e308 100644 --- a/src/librustc_trans/symbol_map.rs +++ b/src/librustc_trans/symbol_map.rs @@ -97,12 +97,12 @@ impl<'tcx> SymbolMap<'tcx> { trans_item: TransItem<'tcx>) -> Option { match trans_item { TransItem::Fn(Instance { def, .. }) => { - tcx.map.as_local_node_id(def) + tcx.hir.as_local_node_id(def) } TransItem::Static(node_id) => Some(node_id), TransItem::DropGlue(_) => None, }.map(|node_id| { - tcx.map.span(node_id) + tcx.hir.span(node_id) }) } diff --git a/src/librustc_trans/symbol_names_test.rs b/src/librustc_trans/symbol_names_test.rs index 9ed5a5d148cd6..02e1290b57783 100644 --- a/src/librustc_trans/symbol_names_test.rs +++ b/src/librustc_trans/symbol_names_test.rs @@ -36,7 +36,7 @@ pub fn report_symbol_names(scx: &SharedCrateContext) { let _ignore = tcx.dep_graph.in_ignore(); let mut visitor = SymbolNamesTest { scx: scx }; // FIXME(#37712) could use ItemLikeVisitor if trait items were item-like - tcx.map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); } struct SymbolNamesTest<'a, 'tcx:'a> { @@ -47,7 +47,7 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> { fn process_attrs(&mut self, node_id: ast::NodeId) { let tcx = self.scx.tcx(); - let def_id = tcx.map.local_def_id(node_id); + let def_id = tcx.hir.local_def_id(node_id); for attr in tcx.get_attrs(def_id).iter() { if attr.check_name(SYMBOL_NAME) { // for now, can only use on monomorphic names diff --git a/src/librustc_trans/trans_item.rs b/src/librustc_trans/trans_item.rs index 816c344254371..43ea1e56a5a4d 100644 --- a/src/librustc_trans/trans_item.rs +++ b/src/librustc_trans/trans_item.rs @@ -77,9 +77,9 @@ impl<'a, 'tcx> TransItem<'tcx> { match *self { TransItem::Static(node_id) => { - let def_id = ccx.tcx().map.local_def_id(node_id); + let def_id = ccx.tcx().hir.local_def_id(node_id); let _task = ccx.tcx().dep_graph.in_task(DepNode::TransCrateItem(def_id)); // (*) - let item = ccx.tcx().map.expect_item(node_id); + let item = ccx.tcx().hir.expect_item(node_id); if let hir::ItemStatic(_, m, _) = item.node { match consts::trans_static(&ccx, m, item.id, &item.attrs) { Ok(_) => { /* Cool, everything's alright. */ }, @@ -145,12 +145,12 @@ impl<'a, 'tcx> TransItem<'tcx> { node_id: ast::NodeId, linkage: llvm::Linkage, symbol_name: &str) { - let def_id = ccx.tcx().map.local_def_id(node_id); + let def_id = ccx.tcx().hir.local_def_id(node_id); let ty = ccx.tcx().item_type(def_id); let llty = type_of::type_of(ccx, ty); let g = declare::define_global(ccx, symbol_name, llty).unwrap_or_else(|| { - ccx.sess().span_fatal(ccx.tcx().map.span(node_id), + ccx.sess().span_fatal(ccx.tcx().hir.span(node_id), &format!("symbol `{}` is already defined", symbol_name)) }); @@ -222,7 +222,7 @@ impl<'a, 'tcx> TransItem<'tcx> { match *self { TransItem::Fn(instance) => instance.symbol_name(scx), TransItem::Static(node_id) => { - let def_id = scx.tcx().map.local_def_id(node_id); + let def_id = scx.tcx().hir.local_def_id(node_id); Instance::mono(scx, def_id).symbol_name(scx) } TransItem::DropGlue(dg) => { @@ -274,7 +274,7 @@ impl<'a, 'tcx> TransItem<'tcx> { pub fn explicit_linkage(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option { let def_id = match *self { TransItem::Fn(ref instance) => instance.def, - TransItem::Static(node_id) => tcx.map.local_def_id(node_id), + TransItem::Static(node_id) => tcx.hir.local_def_id(node_id), TransItem::DropGlue(..) => return None, }; @@ -283,7 +283,7 @@ impl<'a, 'tcx> TransItem<'tcx> { if let Some(linkage) = base::llvm_linkage_by_name(&name.as_str()) { Some(linkage) } else { - let span = tcx.map.span_if_local(def_id); + let span = tcx.hir.span_if_local(def_id); if let Some(span) = span { tcx.sess.span_fatal(span, "invalid linkage specified") } else { @@ -296,7 +296,7 @@ impl<'a, 'tcx> TransItem<'tcx> { } pub fn to_string(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> String { - let hir_map = &tcx.map; + let hir_map = &tcx.hir; return match *self { TransItem::DropGlue(dg) => { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 838dbef8ecf1b..1af8b59cdfa7d 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -186,7 +186,7 @@ pub fn ast_region_to_region<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, .get(&id) .cloned() .unwrap_or(ty::Issue32330::WontChange); - ty::ReLateBound(debruijn, ty::BrNamed(tcx.map.local_def_id(id), + ty::ReLateBound(debruijn, ty::BrNamed(tcx.hir.local_def_id(id), lifetime.name, issue_32330)) } @@ -208,7 +208,7 @@ pub fn ast_region_to_region<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, .unwrap_or(ty::Issue32330::WontChange); ty::ReFree(ty::FreeRegion { scope: scope.to_code_extent(&tcx.region_maps), - bound_region: ty::BrNamed(tcx.map.local_def_id(id), + bound_region: ty::BrNamed(tcx.hir.local_def_id(id), lifetime.name, issue_32330) }) @@ -245,8 +245,8 @@ fn report_elision_failure( } = info; let help_name = if let Some(body) = parent { - let arg = &tcx.map.body(body).arguments[index]; - format!("`{}`", tcx.map.node_to_pretty_string(arg.pat.id)) + let arg = &tcx.hir.body(body).arguments[index]; + format!("`{}`", tcx.hir.node_to_pretty_string(arg.pat.id)) } else { format!("argument {}", index + 1) }; @@ -684,7 +684,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { } _ => { span_fatal!(self.tcx().sess, path.span, E0245, "`{}` is not a trait", - self.tcx().map.node_to_pretty_string(trait_ref.ref_id)); + self.tcx().hir.node_to_pretty_string(trait_ref.ref_id)); } } } @@ -1152,7 +1152,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { let bound_span = self.tcx().associated_items(bound.def_id()).find(|item| { item.kind == ty::AssociatedKind::Type && item.name == assoc_name }) - .and_then(|item| self.tcx().map.span_if_local(item.def_id)); + .and_then(|item| self.tcx().hir.span_if_local(item.def_id)); if let Some(span) = bound_span { err.span_label(span, &format!("ambiguous `{}` from `{}`", @@ -1223,7 +1223,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { } } (&ty::TyParam(_), Def::SelfTy(Some(trait_did), None)) => { - let trait_node_id = tcx.map.as_local_node_id(trait_did).unwrap(); + let trait_node_id = tcx.hir.as_local_node_id(trait_did).unwrap(); match self.find_bound_for_assoc_item(trait_node_id, keywords::SelfType.name(), assoc_name, @@ -1233,7 +1233,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { } } (&ty::TyParam(_), Def::TyParam(param_did)) => { - let param_node_id = tcx.map.as_local_node_id(param_did).unwrap(); + let param_node_id = tcx.hir.as_local_node_id(param_did).unwrap(); let param_name = tcx.type_parameter_def(param_node_id).name; match self.find_bound_for_assoc_item(param_node_id, param_name, @@ -1379,7 +1379,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { assert_eq!(opt_self_ty, None); tcx.prohibit_type_params(&path.segments); - let node_id = tcx.map.as_local_node_id(did).unwrap(); + let node_id = tcx.hir.as_local_node_id(did).unwrap(); let param = tcx.ty_param_defs.borrow().get(&node_id) .map(ty::ParamTy::for_def); if let Some(p) = param { @@ -1544,10 +1544,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { use collect::{compute_bounds, SizedByDefault}; // Create the anonymized type. - let def_id = tcx.map.local_def_id(ast_ty.id); + let def_id = tcx.hir.local_def_id(ast_ty.id); if let Some(anon_scope) = rscope.anon_type_scope() { let substs = anon_scope.fresh_substs(self, ast_ty.span); - let ty = tcx.mk_anon(tcx.map.local_def_id(ast_ty.id), substs); + let ty = tcx.mk_anon(tcx.hir.local_def_id(ast_ty.id), substs); // Collect the bounds, i.e. the `A+B+'c` in `impl A+B+'c`. let bounds = compute_bounds(self, ty, bounds, diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 3b3c0257c4a41..932e7ae1dd426 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -139,7 +139,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // if there are multiple arms, make sure they all agree on // what the type of the binding `x` ought to be - let var_id = tcx.map.as_local_node_id(def_id).unwrap(); + let var_id = tcx.hir.as_local_node_id(def_id).unwrap(); if var_id != pat.id { let vt = self.local_ty(pat.span, var_id); self.demand_eqtype(pat.span, vt, typ); @@ -561,7 +561,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { span_err!(tcx.sess, pat.span, E0533, "expected unit struct/variant or constant, found {} `{}`", def.kind_name(), - hir::print::to_string(&tcx.map, |s| s.print_qpath(qpath, false))); + hir::print::to_string(&tcx.hir, |s| s.print_qpath(qpath, false))); }; // Resolve the path and check the definition for errors. @@ -603,7 +603,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let report_unexpected_def = |def: Def| { let msg = format!("expected tuple struct/variant, found {} `{}`", def.kind_name(), - hir::print::to_string(&tcx.map, |s| s.print_qpath(qpath, false))); + hir::print::to_string(&tcx.hir, |s| s.print_qpath(qpath, false))); struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg) .span_label(pat.span, &format!("not a tuple variant or struct")).emit(); on_error(); diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 0b9cf38fa0733..3a980c8e7642b 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -194,7 +194,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let (fn_sig, def_span) = match callee_ty.sty { ty::TyFnDef(def_id, .., &ty::BareFnTy {ref sig, ..}) => { - (sig, self.tcx.map.span_if_local(def_id)) + (sig, self.tcx.hir.span_if_local(def_id)) } ty::TyFnPtr(&ty::BareFnTy {ref sig, ..}) => (sig, None), ref t => { @@ -202,7 +202,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let &ty::TyAdt(adt_def, ..) = t { if adt_def.is_enum() { if let hir::ExprCall(ref expr, _) = call_expr.node { - unit_variant = Some(self.tcx.map.node_to_pretty_string(expr.id)) + unit_variant = Some(self.tcx.hir.node_to_pretty_string(expr.id)) } } } @@ -225,7 +225,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Def::Err }; if def != Def::Err { - if let Some(span) = self.tcx.map.span_if_local(def.def_id()) { + if let Some(span) = self.tcx.hir.span_if_local(def.def_id()) { err.span_note(span, "defined here"); } } diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 0551887e2e8a0..2e6592b550179 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -39,7 +39,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Some(ty) => self.deduce_expectations_from_expected_type(ty), None => (None, None), }; - let body = self.tcx.map.body(body_id); + let body = self.tcx.hir.body(body_id); self.check_closure(expr, expected_kind, decl, body, expected_sig) } @@ -54,7 +54,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { opt_kind, expected_sig); - let expr_def_id = self.tcx.map.local_def_id(expr.id); + let expr_def_id = self.tcx.hir.local_def_id(expr.id); let mut fn_ty = AstConv::ty_of_closure(self, hir::Unsafety::Normal, decl, diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 3960dc9edbd27..d110c16cf3313 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -170,7 +170,7 @@ fn compare_predicate_entailment<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // Create a parameter environment that represents the implementation's // method. - let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap(); + let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap(); let impl_param_env = ty::ParameterEnvironment::for_item(tcx, impl_m_node_id); // Create mapping from impl to skolemized. @@ -437,8 +437,8 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a trait_sig: ty::FnSig<'tcx>) -> (Span, Option) { let tcx = infcx.tcx; - let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap(); - let (impl_m_output, impl_m_iter) = match tcx.map.expect_impl_item(impl_m_node_id).node { + let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap(); + let (impl_m_output, impl_m_iter) = match tcx.hir.expect_impl_item(impl_m_node_id).node { ImplItemKind::Method(ref impl_m_sig, _) => { (&impl_m_sig.decl.output, impl_m_sig.decl.inputs.iter()) } @@ -447,8 +447,8 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a match *terr { TypeError::Mutability => { - if let Some(trait_m_node_id) = tcx.map.as_local_node_id(trait_m.def_id) { - let trait_m_iter = match tcx.map.expect_trait_item(trait_m_node_id).node { + if let Some(trait_m_node_id) = tcx.hir.as_local_node_id(trait_m.def_id) { + let trait_m_iter = match tcx.hir.expect_trait_item(trait_m_node_id).node { TraitItemKind::Method(ref trait_m_sig, _) => { trait_m_sig.decl.inputs.iter() } @@ -466,15 +466,15 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a }).map(|(ref impl_arg, ref trait_arg)| { (impl_arg.span, Some(trait_arg.span)) }) - .unwrap_or_else(|| (cause.span, tcx.map.span_if_local(trait_m.def_id))) + .unwrap_or_else(|| (cause.span, tcx.hir.span_if_local(trait_m.def_id))) } else { - (cause.span, tcx.map.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } } TypeError::Sorts(ExpectedFound { .. }) => { - if let Some(trait_m_node_id) = tcx.map.as_local_node_id(trait_m.def_id) { + if let Some(trait_m_node_id) = tcx.hir.as_local_node_id(trait_m.def_id) { let (trait_m_output, trait_m_iter) = - match tcx.map.expect_trait_item(trait_m_node_id).node { + match tcx.hir.expect_trait_item(trait_m_node_id).node { TraitItemKind::Method(ref trait_m_sig, _) => { (&trait_m_sig.decl.output, trait_m_sig.decl.inputs.iter()) } @@ -499,14 +499,14 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a .is_err() { (impl_m_output.span(), Some(trait_m_output.span())) } else { - (cause.span, tcx.map.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } }) } else { - (cause.span, tcx.map.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } } - _ => (cause.span, tcx.map.span_if_local(trait_m.def_id)), + _ => (cause.span, tcx.hir.span_if_local(trait_m.def_id)), } } @@ -554,7 +554,7 @@ fn compare_self_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, trait_m.name, self_descr); err.span_label(impl_m_span, &format!("`{}` used in impl", self_descr)); - if let Some(span) = tcx.map.span_if_local(trait_m.def_id) { + if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) { err.span_label(span, &format!("trait declared without `{}`", self_descr)); } err.emit(); @@ -572,7 +572,7 @@ fn compare_self_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, self_descr); err.span_label(impl_m_span, &format!("expected `{}` in impl", self_descr)); - if let Some(span) = tcx.map.span_if_local(trait_m.def_id) { + if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) { err.span_label(span, &format!("`{}` used in trait", self_descr)); } err.emit(); @@ -595,8 +595,8 @@ fn compare_number_of_generics<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let num_impl_m_type_params = impl_m_generics.types.len(); let num_trait_m_type_params = trait_m_generics.types.len(); if num_impl_m_type_params != num_trait_m_type_params { - let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap(); - let span = match tcx.map.expect_impl_item(impl_m_node_id).node { + let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap(); + let span = match tcx.hir.expect_impl_item(impl_m_node_id).node { ImplItemKind::Method(ref impl_m_sig, _) => { if impl_m_sig.generics.is_parameterized() { impl_m_sig.generics.span @@ -671,9 +671,9 @@ fn compare_number_of_method_arguments<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let trait_number_args = trait_m_fty.sig.inputs().skip_binder().len(); let impl_number_args = impl_m_fty.sig.inputs().skip_binder().len(); if trait_number_args != impl_number_args { - let trait_m_node_id = tcx.map.as_local_node_id(trait_m.def_id); + let trait_m_node_id = tcx.hir.as_local_node_id(trait_m.def_id); let trait_span = if let Some(trait_id) = trait_m_node_id { - match tcx.map.expect_trait_item(trait_id).node { + match tcx.hir.expect_trait_item(trait_id).node { TraitItemKind::Method(ref trait_m_sig, _) => { if let Some(arg) = trait_m_sig.decl.inputs.get(if trait_number_args > 0 { trait_number_args - 1 @@ -690,8 +690,8 @@ fn compare_number_of_method_arguments<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, } else { trait_item_span }; - let impl_m_node_id = tcx.map.as_local_node_id(impl_m.def_id).unwrap(); - let impl_span = match tcx.map.expect_impl_item(impl_m_node_id).node { + let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap(); + let impl_span = match tcx.hir.expect_impl_item(impl_m_node_id).node { ImplItemKind::Method(ref impl_m_sig, _) => { if let Some(arg) = impl_m_sig.decl.inputs.get(if impl_number_args > 0 { impl_number_args - 1 @@ -759,7 +759,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // Create a parameter environment that represents the implementation's // method. - let impl_c_node_id = tcx.map.as_local_node_id(impl_c.def_id).unwrap(); + let impl_c_node_id = tcx.hir.as_local_node_id(impl_c.def_id).unwrap(); let impl_param_env = ty::ParameterEnvironment::for_item(tcx, impl_c_node_id); // Create mapping from impl to skolemized. @@ -810,7 +810,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, trait_ty); // Locate the Span containing just the type of the offending impl - match tcx.map.expect_impl_item(impl_c_node_id).node { + match tcx.hir.expect_impl_item(impl_c_node_id).node { ImplItemKind::Const(ref ty, _) => cause.span = ty.span, _ => bug!("{:?} is not a impl const", impl_c), } @@ -823,8 +823,8 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, trait_c.name); // Add a label to the Span containing just the type of the item - let trait_c_node_id = tcx.map.as_local_node_id(trait_c.def_id).unwrap(); - let trait_c_span = match tcx.map.expect_trait_item(trait_c_node_id).node { + let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id).unwrap(); + let trait_c_span = match tcx.hir.expect_trait_item(trait_c_node_id).node { TraitItemKind::Const(ref ty, _) => ty.span, _ => bug!("{:?} is not a trait const", trait_c), }; diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 9cd54bd94c817..91b772a748c72 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -75,8 +75,8 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>( -> Result<(), ()> { let tcx = ccx.tcx; - let drop_impl_node_id = tcx.map.as_local_node_id(drop_impl_did).unwrap(); - let self_type_node_id = tcx.map.as_local_node_id(self_type_did).unwrap(); + let drop_impl_node_id = tcx.hir.as_local_node_id(drop_impl_did).unwrap(); + let self_type_node_id = tcx.hir.as_local_node_id(self_type_did).unwrap(); // check that the impl type can be made to match the trait type. @@ -100,7 +100,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>( assert!(obligations.is_empty()); } Err(_) => { - let item_span = tcx.map.span(self_type_node_id); + let item_span = tcx.hir.span(self_type_node_id); struct_span_err!(tcx.sess, drop_impl_span, E0366, "Implementations of Drop cannot be specialized") .span_note(item_span, @@ -171,7 +171,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>( let tcx = ccx.tcx; - let self_type_node_id = tcx.map.as_local_node_id(self_type_did).unwrap(); + let self_type_node_id = tcx.hir.as_local_node_id(self_type_did).unwrap(); let drop_impl_span = tcx.def_span(drop_impl_did); @@ -203,7 +203,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>( // repeated `contains` calls. if !assumptions_in_impl_context.contains(&predicate) { - let item_span = tcx.map.span(self_type_node_id); + let item_span = tcx.hir.span(self_type_node_id); struct_span_err!(tcx.sess, drop_impl_span, E0367, "The requirement `{}` is added only by the Drop impl.", predicate) .span_note(item_span, diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 4f41bbe9924b0..7ead7ada893d7 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -34,7 +34,7 @@ fn equate_intrinsic_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, inputs: Vec>, output: Ty<'tcx>) { let tcx = ccx.tcx; - let def_id = tcx.map.local_def_id(it.id); + let def_id = tcx.hir.local_def_id(it.id); let substs = Substs::for_item(tcx, def_id, |_, _| tcx.mk_region(ty::ReErased), @@ -324,7 +324,7 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt, }; let tcx = ccx.tcx; - let def_id = tcx.map.local_def_id(it.id); + let def_id = tcx.hir.local_def_id(it.id); let i_n_tps = tcx.item_generics(def_id).types.len(); let name = it.name.as_str(); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index aa8f3bef92ed2..e2d7d31a8a890 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -803,7 +803,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { for step in steps.iter() { let closure_id = match step.self_ty.sty { ty::TyClosure(def_id, _) => { - if let Some(id) = self.tcx.map.as_local_node_id(def_id) { + if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { id } else { continue; diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index b1705425e6eb0..f6345e6e262db 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -99,8 +99,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { item_name ) }).unwrap(); - let note_span = self.tcx.map.span_if_local(item.def_id).or_else(|| { - self.tcx.map.span_if_local(impl_did) + let note_span = self.tcx.hir.span_if_local(item.def_id).or_else(|| { + self.tcx.hir.span_if_local(impl_did) }); let impl_ty = self.impl_self_ty(span, impl_did).ty; @@ -285,7 +285,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let msg = if let Some(callee) = rcvr_expr { format!("{}; use overloaded call notation instead (e.g., `{}()`)", msg, - self.tcx.map.node_to_pretty_string(callee.id)) + self.tcx.hir.node_to_pretty_string(callee.id)) } else { msg }; @@ -488,8 +488,8 @@ pub fn all_traits<'a>(ccx: &'a CrateCtxt) -> AllTraits<'a> { fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) { } } - ccx.tcx.map.krate().visit_all_item_likes(&mut Visitor { - map: &ccx.tcx.map, + ccx.tcx.hir.krate().visit_all_item_likes(&mut Visitor { + map: &ccx.tcx.hir, traits: &mut traits, }); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 7a9df90c1a613..7b87ec5dd5d2f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -538,7 +538,7 @@ struct CheckItemBodiesVisitor<'a, 'tcx: 'a> { ccx: &'a CrateCtxt<'a, 'tcx> } impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.ccx.tcx.map) + NestedVisitorMap::OnlyBodies(&self.ccx.tcx.hir) } fn visit_item(&mut self, i: &'tcx hir::Item) { @@ -634,7 +634,7 @@ pub fn check_item_bodies(ccx: &CrateCtxt) -> CompileResult { // bodies have been fully inferred. for (&item_id, obligations) in ccx.deferred_obligations.borrow().iter() { // Use the same DepNode as for the body of the original function/item. - let def_id = ccx.tcx.map.local_def_id(item_id); + let def_id = ccx.tcx.hir.local_def_id(item_id); let _task = ccx.tcx.dep_graph.in_task(DepNode::TypeckTables(def_id)); let param_env = ParameterEnvironment::for_item(ccx.tcx, item_id); @@ -677,9 +677,9 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, body_id: hir::BodyId, fn_id: ast::NodeId, span: Span) { - let body = ccx.tcx.map.body(body_id); + let body = ccx.tcx.hir.body(body_id); - let raw_fty = ccx.tcx.item_type(ccx.tcx.map.local_def_id(fn_id)); + let raw_fty = ccx.tcx.item_type(ccx.tcx.hir.local_def_id(fn_id)); let fn_ty = match raw_fty.sty { ty::TyFnDef(.., f) => f, _ => span_bug!(body.value.span, "check_bare_fn: function type expected") @@ -835,7 +835,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } fn check_struct(ccx: &CrateCtxt, id: ast::NodeId, span: Span) { - let def_id = ccx.tcx.map.local_def_id(id); + let def_id = ccx.tcx.hir.local_def_id(id); check_representable(ccx.tcx, span, def_id); if ccx.tcx.lookup_simd(def_id) { @@ -844,13 +844,13 @@ fn check_struct(ccx: &CrateCtxt, id: ast::NodeId, span: Span) { } fn check_union(ccx: &CrateCtxt, id: ast::NodeId, span: Span) { - check_representable(ccx.tcx, span, ccx.tcx.map.local_def_id(id)); + check_representable(ccx.tcx, span, ccx.tcx.hir.local_def_id(id)); } pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { debug!("check_item_type(it.id={}, it.name={})", it.id, - ccx.tcx.item_path_str(ccx.tcx.map.local_def_id(it.id))); + ccx.tcx.item_path_str(ccx.tcx.hir.local_def_id(it.id))); let _indenter = indenter(); match it.node { // Consts can play a role in type-checking, so they are included here. @@ -865,7 +865,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { hir::ItemFn(..) => {} // entirely within check_item_body hir::ItemImpl(.., ref impl_item_refs) => { debug!("ItemImpl {} with id {}", it.name, it.id); - let impl_def_id = ccx.tcx.map.local_def_id(it.id); + let impl_def_id = ccx.tcx.hir.local_def_id(it.id); if let Some(impl_trait_ref) = ccx.tcx.impl_trait_ref(impl_def_id) { check_impl_items_against_trait(ccx, it.span, @@ -877,7 +877,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { } } hir::ItemTrait(..) => { - let def_id = ccx.tcx.map.local_def_id(it.id); + let def_id = ccx.tcx.hir.local_def_id(it.id); check_on_unimplemented(ccx, def_id, it); } hir::ItemStruct(..) => { @@ -887,7 +887,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { check_union(ccx, it.id, it.span); } hir::ItemTy(_, ref generics) => { - let def_id = ccx.tcx.map.local_def_id(it.id); + let def_id = ccx.tcx.hir.local_def_id(it.id); let pty_ty = ccx.tcx.item_type(def_id); check_bounds_are_used(ccx, generics, pty_ty); } @@ -904,7 +904,7 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { } } else { for item in &m.items { - let generics = ccx.tcx.item_generics(ccx.tcx.map.local_def_id(item.id)); + let generics = ccx.tcx.item_generics(ccx.tcx.hir.local_def_id(item.id)); if !generics.types.is_empty() { let mut err = struct_span_err!(ccx.tcx.sess, item.span, E0044, "foreign items may not have type parameters"); @@ -1038,12 +1038,12 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let trait_def = tcx.lookup_trait_def(impl_trait_ref.def_id); let mut overridden_associated_type = None; - let impl_items = || impl_item_refs.iter().map(|iiref| ccx.tcx.map.impl_item(iiref.id)); + let impl_items = || impl_item_refs.iter().map(|iiref| ccx.tcx.hir.impl_item(iiref.id)); // Check existing impl methods to see if they are both present in trait // and compatible with trait signature for impl_item in impl_items() { - let ty_impl_item = tcx.associated_item(tcx.map.local_def_id(impl_item.id)); + let ty_impl_item = tcx.associated_item(tcx.hir.local_def_id(impl_item.id)); let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id) .find(|ac| ac.name == ty_impl_item.name); @@ -1067,14 +1067,14 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, err.span_label(impl_item.span, &format!("does not match trait")); // We can only get the spans from local trait definition // Same for E0324 and E0325 - if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id) { + if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) { err.span_label(trait_span, &format!("item in trait")); } err.emit() } } hir::ImplItemKind::Method(_, body_id) => { - let trait_span = tcx.map.span_if_local(ty_trait_item.def_id); + let trait_span = tcx.hir.span_if_local(ty_trait_item.def_id); if ty_trait_item.kind == ty::AssociatedKind::Method { let err_count = tcx.sess.err_count(); compare_impl_method(ccx, @@ -1103,7 +1103,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, ty_impl_item.name, impl_trait_ref); err.span_label(impl_item.span, &format!("does not match trait")); - if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id) { + if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) { err.span_label(trait_span, &format!("item in trait")); } err.emit() @@ -1121,7 +1121,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, ty_impl_item.name, impl_trait_ref); err.span_label(impl_item.span, &format!("does not match trait")); - if let Some(trait_span) = tcx.map.span_if_local(ty_trait_item.def_id) { + if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) { err.span_label(trait_span, &format!("item in trait")); } err.emit() @@ -1176,7 +1176,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, .map(|trait_item| trait_item.name.to_string()) .collect::>().join("`, `"))); for trait_item in missing_items { - if let Some(span) = tcx.map.span_if_local(trait_item.def_id) { + if let Some(span) = tcx.hir.span_if_local(trait_item.def_id) { err.span_label(span, &format!("`{}` from trait", trait_item.name)); } else { err.note(&format!("`{}` from trait: `{}`", @@ -1204,7 +1204,7 @@ fn check_const_with_type<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>, body: hir::BodyId, expected_type: Ty<'tcx>, id: ast::NodeId) { - let body = ccx.tcx.map.body(body); + let body = ccx.tcx.hir.body(body); ccx.inherited(id).enter(|inh| { let fcx = FnCtxt::new(&inh, None, body.value.id); fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized); @@ -1231,7 +1231,7 @@ fn check_const_with_type<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>, fn check_const<'a, 'tcx>(ccx: &CrateCtxt<'a,'tcx>, body: hir::BodyId, id: ast::NodeId) { - let decl_ty = ccx.tcx.item_type(ccx.tcx.map.local_def_id(id)); + let decl_ty = ccx.tcx.item_type(ccx.tcx.hir.local_def_id(id)); check_const_with_type(ccx, body, decl_ty, id); } @@ -1294,7 +1294,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, sp: Span, vs: &'tcx [hir::Variant], id: ast::NodeId) { - let def_id = ccx.tcx.map.local_def_id(id); + let def_id = ccx.tcx.hir.local_def_id(id); let hint = *ccx.tcx.lookup_repr_hints(def_id).get(0).unwrap_or(&attr::ReprAny); if hint != attr::ReprAny && vs.is_empty() { @@ -1319,7 +1319,7 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, } } - let def_id = ccx.tcx.map.local_def_id(id); + let def_id = ccx.tcx.hir.local_def_id(id); let variants = &ccx.tcx.lookup_adt_def(def_id).variants; let mut disr_vals: Vec = Vec::new(); @@ -1328,14 +1328,14 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, // Check for duplicate discriminant values if let Some(i) = disr_vals.iter().position(|&x| x == current_disr_val) { - let variant_i_node_id = ccx.tcx.map.as_local_node_id(variants[i].did).unwrap(); - let variant_i = ccx.tcx.map.expect_variant(variant_i_node_id); + let variant_i_node_id = ccx.tcx.hir.as_local_node_id(variants[i].did).unwrap(); + let variant_i = ccx.tcx.hir.expect_variant(variant_i_node_id); let i_span = match variant_i.node.disr_expr { - Some(expr) => ccx.tcx.map.span(expr.node_id), - None => ccx.tcx.map.span(variant_i_node_id) + Some(expr) => ccx.tcx.hir.span(expr.node_id), + None => ccx.tcx.hir.span(variant_i_node_id) }; let span = match v.node.disr_expr { - Some(expr) => ccx.tcx.map.span(expr.node_id), + Some(expr) => ccx.tcx.hir.span(expr.node_id), None => v.span }; struct_span_err!(ccx.tcx.sess, span, E0081, @@ -1610,7 +1610,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Some(&t) => t, None => { span_bug!(span, "no type for local variable {}", - self.tcx.map.node_to_string(nid)); + self.tcx.hir.node_to_string(nid)); } } } @@ -1841,7 +1841,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None if self.err_count_since_creation() != 0 => self.tcx.types.err, None => { bug!("no type for node {}: {} in fcx {}", - id, self.tcx.map.node_to_string(id), + id, self.tcx.hir.node_to_string(id), self.tag()); } } @@ -2159,7 +2159,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { TypeVariableOrigin::MiscVariable(syntax_pos::DUMMY_SP)), origin_span: syntax_pos::DUMMY_SP, // what do I put here? - def_id: self.tcx.map.local_def_id(ast::CRATE_NODE_ID) + def_id: self.tcx.hir.local_def_id(ast::CRATE_NODE_ID) }); // This is to ensure that we elimnate any non-determinism from the error @@ -2435,7 +2435,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ); self.check_argument_types(sp, &fty.sig.0.inputs()[1..], &expected_arg_tys[..], args_no_rcvr, fty.sig.0.variadic, tuple_arguments, - self.tcx.map.span_if_local(def_id)); + self.tcx.hir.span_if_local(def_id)); fty.sig.0.output() } _ => { @@ -3021,7 +3021,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ty::TyRawPtr(..) => { err.note(&format!("`{0}` is a native pointer; perhaps you need to deref with \ `(*{0}).{1}`", - self.tcx.map.node_to_pretty_string(base.id), + self.tcx.hir.node_to_pretty_string(base.id), field.node)); } _ => {} @@ -3436,12 +3436,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.diverges.set(self.diverges.get() | old_diverges); self.has_errors.set(self.has_errors.get() | old_has_errors); - debug!("type of {} is...", self.tcx.map.node_to_string(expr.id)); + debug!("type of {} is...", self.tcx.hir.node_to_string(expr.id)); debug!("... {:?}, expected is {:?}", ty, expected); // Add adjustments to !-expressions if ty.is_never() { - if let Some(hir::map::NodeExpr(node_expr)) = self.tcx.map.find(expr.id) { + if let Some(hir::map::NodeExpr(node_expr)) = self.tcx.hir.find(expr.id) { let adj_ty = self.next_diverging_ty_var( TypeVariableOrigin::AdjustmentType(node_expr.span)); self.write_adjustment(expr.id, adjustment::Adjustment { @@ -4370,7 +4370,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { match def { Def::Local(def_id) | Def::Upvar(def_id, ..) => { - let nid = self.tcx.map.as_local_node_id(def_id).unwrap(); + let nid = self.tcx.hir.as_local_node_id(def_id).unwrap(); let ty = self.local_ty(span, nid); let ty = self.normalize_associated_types_in(span, &ty); self.write_ty(node_id, ty); diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index bd63eb6ad25ef..9a5d402ef0adf 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -148,7 +148,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if self.err_count_since_creation() == 0 { // regionck assumes typeck succeeded - rcx.visit_fn_body(fn_id, body, self.tcx.map.span(fn_id)); + rcx.visit_fn_body(fn_id, body, self.tcx.hir.span(fn_id)); } rcx.free_region_map.relate_free_regions_from_predicates( @@ -482,7 +482,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { fn visit_fn(&mut self, _fk: intravisit::FnKind<'gcx>, _: &'gcx hir::FnDecl, b: hir::BodyId, span: Span, id: ast::NodeId) { - let body = self.tcx.map.body(b); + let body = self.tcx.hir.body(b); self.visit_fn_body(id, body, span) } diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 95da5a97f6750..d511d57c3780d 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -85,7 +85,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for SeedBorrowKind<'a, 'gcx, 'tcx> { fn visit_expr(&mut self, expr: &'gcx hir::Expr) { match expr.node { hir::ExprClosure(cc, _, body_id, _) => { - let body = self.fcx.tcx.map.body(body_id); + let body = self.fcx.tcx.hir.body(body_id); self.visit_body(body); self.check_closure(expr, cc); } @@ -114,7 +114,7 @@ impl<'a, 'gcx, 'tcx> SeedBorrowKind<'a, 'gcx, 'tcx> { self.fcx.tcx.with_freevars(expr.id, |freevars| { for freevar in freevars { let def_id = freevar.def.def_id(); - let var_node_id = self.fcx.tcx.map.as_local_node_id(def_id).unwrap(); + let var_node_id = self.fcx.tcx.hir.as_local_node_id(def_id).unwrap(); let upvar_id = ty::UpvarId { var_id: var_node_id, closure_expr_id: expr.id }; debug!("seed upvar_id {:?}", upvar_id); @@ -208,7 +208,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> { // If we are also inferred the closure kind here, update the // main table and process any deferred resolutions. - let closure_def_id = self.fcx.tcx.map.local_def_id(id); + let closure_def_id = self.fcx.tcx.hir.local_def_id(id); if let Some(&kind) = self.temp_closure_kinds.get(&id) { self.fcx.tables.borrow_mut().closure_kinds.insert(id, kind); debug!("closure_kind({:?}) = {:?}", closure_def_id, kind); @@ -232,7 +232,7 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> { tcx.with_freevars(closure_id, |freevars| { freevars.iter().map(|freevar| { let def_id = freevar.def.def_id(); - let var_id = tcx.map.as_local_node_id(def_id).unwrap(); + let var_id = tcx.hir.as_local_node_id(def_id).unwrap(); let freevar_ty = self.fcx.node_ty(var_id); let upvar_id = ty::UpvarId { var_id: var_id, @@ -500,7 +500,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for AdjustBorrowKind<'a, 'gcx, 'tcx> { { intravisit::walk_fn(self, fn_kind, decl, body, span, id); - let body = self.fcx.tcx.map.body(body); + let body = self.fcx.tcx.hir.body(body); self.visit_body(body); self.analyze_closure(id, span, body); } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 4c124cdd60c0f..cef6a75e58dc9 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -90,7 +90,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { let ccx = self.ccx; debug!("check_item_well_formed(it.id={}, it.name={})", item.id, - ccx.tcx.item_path_str(ccx.tcx.map.local_def_id(item.id))); + ccx.tcx.item_path_str(ccx.tcx.hir.local_def_id(item.id))); match item.node { /// Right now we check that every default trait implementation @@ -117,7 +117,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { hir::ItemImpl(_, hir::ImplPolarity::Negative, _, Some(_), ..) => { // FIXME(#27579) what amount of WF checking do we need for neg impls? - let trait_ref = ccx.tcx.impl_trait_ref(ccx.tcx.map.local_def_id(item.id)).unwrap(); + let trait_ref = ccx.tcx.impl_trait_ref(ccx.tcx.hir.local_def_id(item.id)).unwrap(); if !ccx.tcx.trait_has_default_impl(trait_ref.def_id) { error_192(ccx, item.span); } @@ -168,7 +168,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { let free_substs = &fcx.parameter_environment.free_substs; let free_id_outlive = fcx.parameter_environment.free_id_outlive; - let item = fcx.tcx.associated_item(fcx.tcx.map.local_def_id(item_id)); + let item = fcx.tcx.associated_item(fcx.tcx.hir.local_def_id(item_id)); let (mut implied_bounds, self_ty) = match item.container { ty::TraitContainer(_) => (vec![], fcx.tcx.mk_self_type()), @@ -251,7 +251,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { } let free_substs = &fcx.parameter_environment.free_substs; - let def_id = fcx.tcx.map.local_def_id(item.id); + let def_id = fcx.tcx.hir.local_def_id(item.id); let predicates = fcx.instantiate_bounds(item.span, def_id, free_substs); this.check_where_clauses(fcx, item.span, &predicates); @@ -321,7 +321,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { } fn check_trait(&mut self, item: &hir::Item) { - let trait_def_id = self.tcx().map.local_def_id(item.id); + let trait_def_id = self.tcx().hir.local_def_id(item.id); if self.tcx().trait_has_default_impl(trait_def_id) { self.check_auto_trait(trait_def_id, item.span); @@ -341,7 +341,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { { self.for_item(item).with_fcx(|fcx, this| { let free_substs = &fcx.parameter_environment.free_substs; - let def_id = fcx.tcx.map.local_def_id(item.id); + let def_id = fcx.tcx.hir.local_def_id(item.id); let ty = fcx.tcx.item_type(def_id); let item_ty = fcx.instantiate_type_scheme(item.span, free_substs, &ty); let bare_fn_ty = match item_ty.sty { @@ -367,7 +367,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { debug!("check_item_type: {:?}", item); self.for_item(item).with_fcx(|fcx, this| { - let ty = fcx.tcx.item_type(fcx.tcx.map.local_def_id(item.id)); + let ty = fcx.tcx.item_type(fcx.tcx.hir.local_def_id(item.id)); let item_ty = fcx.instantiate_type_scheme(item.span, &fcx.parameter_environment .free_substs, @@ -388,7 +388,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { self.for_item(item).with_fcx(|fcx, this| { let free_substs = &fcx.parameter_environment.free_substs; - let item_def_id = fcx.tcx.map.local_def_id(item.id); + let item_def_id = fcx.tcx.hir.local_def_id(item.id); match *ast_trait_ref { Some(ref ast_trait_ref) => { @@ -514,7 +514,7 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> { item: &hir::Item, ast_generics: &hir::Generics) { - let item_def_id = self.tcx().map.local_def_id(item.id); + let item_def_id = self.tcx().hir.local_def_id(item.id); let ty = self.tcx().item_type(item_def_id); if self.tcx().has_error_field(ty) { return; @@ -644,7 +644,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let fields = struct_def.fields().iter() .map(|field| { - let field_ty = self.tcx.item_type(self.tcx.map.local_def_id(field.id)); + let field_ty = self.tcx.item_type(self.tcx.hir.local_def_id(field.id)); let field_ty = self.instantiate_type_scheme(field.span, &self.parameter_environment .free_substs, diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 172c1dfe35eae..b95126af56aa7 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -36,8 +36,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) { assert_eq!(self.writeback_errors.get(), false); - let item_id = self.tcx.map.body_owner(body.id()); - let item_def_id = self.tcx.map.local_def_id(item_id); + let item_id = self.tcx.hir.body_owner(body.id()); + let item_def_id = self.tcx.hir.local_def_id(item_id); let mut wbcx = WritebackCx::new(self); for arg in &body.arguments { @@ -209,7 +209,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { MethodCall::expr(e.id)); if let hir::ExprClosure(_, _, body, _) = e.node { - let body = self.fcx.tcx.map.body(body); + let body = self.fcx.tcx.hir.body(body); for arg in &body.arguments { self.visit_node_id(ResolvingExpr(e.span), arg.id); } @@ -281,12 +281,12 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { for (&id, closure_ty) in self.fcx.tables.borrow().closure_tys.iter() { let closure_ty = self.resolve(closure_ty, ResolvingClosure(id)); - let def_id = self.tcx().map.local_def_id(id); + let def_id = self.tcx().hir.local_def_id(id); self.tcx().closure_tys.borrow_mut().insert(def_id, closure_ty); } for (&id, &closure_kind) in self.fcx.tables.borrow().closure_kinds.iter() { - let def_id = self.tcx().map.local_def_id(id); + let def_id = self.tcx().hir.local_def_id(id); self.tcx().closure_kinds.borrow_mut().insert(def_id, closure_kind); } } @@ -517,7 +517,7 @@ impl<'a, 'gcx, 'tcx> ResolveReason { ResolvingFnSig(id) | ResolvingFieldTypes(id) | ResolvingTyNode(id) => { - tcx.map.span(id) + tcx.hir.span(id) } ResolvingAnonTy(did) => { tcx.def_span(did) diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index cd9453770a6ab..bdda538db160e 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -60,5 +60,5 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for UnusedTraitImportVisitor<'a, 'tcx> { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let _task = tcx.dep_graph.in_task(DepNode::UnusedTraitCheck); let mut visitor = UnusedTraitImportVisitor { tcx: tcx }; - tcx.map.krate().visit_all_item_likes(&mut visitor); + tcx.hir.krate().visit_all_item_likes(&mut visitor); } diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index 57df0fb2cee93..086484c643ad1 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -69,8 +69,8 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } _ => { // Destructors only work on nominal types. - if let Some(impl_node_id) = tcx.map.as_local_node_id(impl_did) { - match tcx.map.find(impl_node_id) { + if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_did) { + match tcx.hir.find(impl_node_id) { Some(hir_map::NodeItem(item)) => { let span = match item.node { ItemImpl(.., ref ty, _) => ty.span, @@ -101,7 +101,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: DefId) { debug!("visit_implementation_of_copy: impl_did={:?}", impl_did); - let impl_node_id = if let Some(n) = tcx.map.as_local_node_id(impl_did) { + let impl_node_id = if let Some(n) = tcx.hir.as_local_node_id(impl_did) { n } else { debug!("visit_implementation_of_copy(): impl not in this \ @@ -113,7 +113,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, debug!("visit_implementation_of_copy: self_type={:?} (bound)", self_type); - let span = tcx.map.span(impl_node_id); + let span = tcx.hir.span(impl_node_id); let param_env = ParameterEnvironment::for_item(tcx, impl_node_id); let self_type = self_type.subst(tcx, ¶m_env.free_substs); assert!(!self_type.has_escaping_regions()); @@ -124,7 +124,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match param_env.can_type_implement_copy(tcx, self_type, span) { Ok(()) => {} Err(CopyImplementationError::InfrigingField(field)) => { - let item = tcx.map.expect_item(impl_node_id); + let item = tcx.hir.expect_item(impl_node_id); let span = if let ItemImpl(.., Some(ref tr), _, _) = item.node { tr.path.span } else { @@ -141,7 +141,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .emit() } Err(CopyImplementationError::NotAnAdt) => { - let item = tcx.map.expect_item(impl_node_id); + let item = tcx.hir.expect_item(impl_node_id); let span = if let ItemImpl(.., ref ty, _) = item.node { ty.span } else { @@ -180,7 +180,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } }; - let impl_node_id = if let Some(n) = tcx.map.as_local_node_id(impl_did) { + let impl_node_id = if let Some(n) = tcx.hir.as_local_node_id(impl_did) { n } else { debug!("visit_implementation_of_coerce_unsized(): impl not \ @@ -195,7 +195,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, source, target); - let span = tcx.map.span(impl_node_id); + let span = tcx.hir.span(impl_node_id); let param_env = ParameterEnvironment::for_item(tcx, impl_node_id); let source = source.subst(tcx, ¶m_env.free_substs); let target = target.subst(tcx, ¶m_env.free_substs); @@ -281,11 +281,11 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, being coerced, none found"); return; } else if diff_fields.len() > 1 { - let item = tcx.map.expect_item(impl_node_id); + let item = tcx.hir.expect_item(impl_node_id); let span = if let ItemImpl(.., Some(ref t), _, _) = item.node { t.path.span } else { - tcx.map.span(impl_node_id) + tcx.hir.span(impl_node_id) }; let mut err = struct_span_err!(tcx.sess, diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 6cf752dd69fca..5af9ea29fafa7 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -86,7 +86,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { fn check_implementation(&self, item: &Item) { let tcx = self.tcx; - let impl_did = tcx.map.local_def_id(item.id); + let impl_did = tcx.hir.local_def_id(item.id); let self_type = tcx.item_type(impl_did); // If there are no traits, then this implementation must have a diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 2b5a4515cd0d8..c3417ab08d7fa 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -76,13 +76,13 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { /// to prevent inundating the user with a bunch of similar error /// reports. fn visit_item(&mut self, item: &hir::Item) { - let def_id = self.tcx.map.local_def_id(item.id); + let def_id = self.tcx.hir.local_def_id(item.id); match item.node { hir::ItemImpl(.., None, ref ty, _) => { // For inherent impls, self type must be a nominal type // defined in this crate. debug!("coherence2::orphan check: inherent impl {}", - self.tcx.map.node_to_string(item.id)); + self.tcx.hir.node_to_string(item.id)); let self_ty = self.tcx.item_type(def_id); match self_ty.sty { ty::TyAdt(def, _) => { @@ -249,7 +249,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { hir::ItemImpl(.., Some(_), _, _) => { // "Trait" impl debug!("coherence2::orphan check: trait impl {}", - self.tcx.map.node_to_string(item.id)); + self.tcx.hir.node_to_string(item.id)); let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); let trait_def_id = trait_ref.def_id; match traits::orphan_check(self.tcx, def_id) { @@ -374,7 +374,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { hir::ItemDefaultImpl(_, ref item_trait_ref) => { // "Trait" impl debug!("coherence2::orphan check: default trait impl {}", - self.tcx.map.node_to_string(item.id)); + self.tcx.hir.node_to_string(item.id)); let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); if trait_ref.def_id.krate != LOCAL_CRATE { struct_span_err!(self.tcx.sess, @@ -384,7 +384,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { the crate they're defined in; define a new trait instead") .span_label(item_trait_ref.path.span, &format!("`{}` trait not defined in this crate", - self.tcx.map.node_to_pretty_string(item_trait_ref.ref_id))) + self.tcx.hir.node_to_pretty_string(item_trait_ref.ref_id))) .emit(); return; } diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 7890ae20ec26c..56c17dc2f6efd 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -66,7 +66,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> { for &item2 in &impl_items2[..] { if (name, namespace) == name_and_namespace(item2) { let msg = format!("duplicate definitions with name `{}`", name); - let node_id = self.tcx.map.as_local_node_id(item1).unwrap(); + let node_id = self.tcx.hir.as_local_node_id(item1).unwrap(); self.tcx.sess.add_lint(lint::builtin::OVERLAPPING_INHERENT_IMPLS, node_id, self.tcx.span_of_impl(item1).unwrap(), @@ -104,7 +104,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> { hir::ItemStruct(..) | hir::ItemTrait(..) | hir::ItemUnion(..) => { - let type_def_id = self.tcx.map.local_def_id(item.id); + let type_def_id = self.tcx.hir.local_def_id(item.id); self.check_for_overlapping_inherent_impls(type_def_id); } @@ -112,7 +112,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> { // look for another default impl; note that due to the // general orphan/coherence rules, it must always be // in this crate. - let impl_def_id = self.tcx.map.local_def_id(item.id); + let impl_def_id = self.tcx.hir.local_def_id(item.id); let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap(); let prev_default_impl = self.default_impls.insert(trait_ref.def_id, item.id); @@ -124,14 +124,14 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> { `{}`:", trait_ref); err.span_note(self.tcx - .span_of_impl(self.tcx.map.local_def_id(prev_id)) + .span_of_impl(self.tcx.hir.local_def_id(prev_id)) .unwrap(), "redundant implementation is here:"); err.emit(); } } hir::ItemImpl(.., Some(_), _, _) => { - let impl_def_id = self.tcx.map.local_def_id(item.id); + let impl_def_id = self.tcx.hir.local_def_id(item.id); let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap(); let trait_def_id = trait_ref.def_id; diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index c4c7c699f65f6..8c98e2952ebe9 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -17,7 +17,7 @@ use rustc::hir::{self, Unsafety}; pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut unsafety = UnsafetyChecker { tcx: tcx }; - tcx.map.krate().visit_all_item_likes(&mut unsafety); + tcx.hir.krate().visit_all_item_likes(&mut unsafety); } struct UnsafetyChecker<'cx, 'tcx: 'cx> { @@ -30,7 +30,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> { impl_generics: Option<&hir::Generics>, unsafety: hir::Unsafety, polarity: hir::ImplPolarity) { - match self.tcx.impl_trait_ref(self.tcx.map.local_def_id(item.id)) { + match self.tcx.impl_trait_ref(self.tcx.hir.local_def_id(item.id)) { None => { // Inherent impl. match unsafety { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index d403ac4343531..841b4516a18f3 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -169,9 +169,9 @@ impl<'a, 'tcx> CollectItemTypesVisitor<'a, 'tcx> { fn with_collect_item_sig(&self, id: ast::NodeId, op: OP) where OP: FnOnce() { - let def_id = self.ccx.tcx.map.local_def_id(id); + let def_id = self.ccx.tcx.hir.local_def_id(id); self.ccx.tcx.dep_graph.with_task(DepNode::CollectItemSig(def_id), || { - self.ccx.tcx.map.read(id); + self.ccx.tcx.hir.read(id); op(); }); } @@ -179,7 +179,7 @@ impl<'a, 'tcx> CollectItemTypesVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.ccx.tcx.map) + NestedVisitorMap::OnlyBodies(&self.ccx.tcx.hir) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -189,7 +189,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { if let hir::ExprClosure(..) = expr.node { - let def_id = self.ccx.tcx.map.local_def_id(expr.id); + let def_id = self.ccx.tcx.hir.local_def_id(expr.id); generics_of_def_id(self.ccx, def_id); type_of_def_id(self.ccx, def_id); } @@ -198,7 +198,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { fn visit_ty(&mut self, ty: &'tcx hir::Ty) { if let hir::TyImplTrait(..) = ty.node { - let def_id = self.ccx.tcx.map.local_def_id(ty.id); + let def_id = self.ccx.tcx.hir.local_def_id(ty.id); generics_of_def_id(self.ccx, def_id); } intravisit::walk_ty(self, ty); @@ -341,8 +341,8 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { { let tcx = self.tcx; - if let Some(trait_id) = tcx.map.as_local_node_id(def_id) { - let item = match tcx.map.get(trait_id) { + if let Some(trait_id) = tcx.hir.as_local_node_id(def_id) { + let item = match tcx.hir.get(trait_id) { hir_map::NodeItem(item) => item, _ => bug!("get_trait_def({:?}): not an item", trait_id) }; @@ -611,7 +611,7 @@ fn is_param<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match path.def { Def::SelfTy(Some(def_id), None) | Def::TyParam(def_id) => { - def_id == tcx.map.local_def_id(param_id) + def_id == tcx.hir.local_def_id(param_id) } _ => false } @@ -629,7 +629,7 @@ fn convert_field<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let tt = ccx.icx(struct_predicates).to_ty(&ExplicitRscope, &field.ty); ccx.tcx.item_types.borrow_mut().insert(ty_f.did, tt); - let def_id = ccx.tcx.map.local_def_id(field.id); + let def_id = ccx.tcx.hir.local_def_id(field.id); ccx.tcx.item_types.borrow_mut().insert(def_id, tt); ccx.tcx.generics.borrow_mut().insert(def_id, struct_generics); ccx.tcx.predicates.borrow_mut().insert(def_id, struct_predicates.clone()); @@ -642,7 +642,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, untransformed_rcvr_ty: Ty<'tcx>, body: Option, rcvr_ty_predicates: &ty::GenericPredicates<'tcx>,) { - let def_id = ccx.tcx.map.local_def_id(id); + let def_id = ccx.tcx.hir.local_def_id(id); let ty_generics = generics_of_def_id(ccx, def_id); let ty_generic_predicates = @@ -662,7 +662,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, sig, self_value_ty, body, anon_scope); let substs = mk_item_substs(&ccx.icx(&(rcvr_ty_predicates, &sig.generics)), - ccx.tcx.map.span(id), def_id); + ccx.tcx.hir.span(id), def_id); let fty = ccx.tcx.mk_fn_def(def_id, substs, fty); ccx.tcx.item_types.borrow_mut().insert(def_id, fty); ccx.tcx.predicates.borrow_mut().insert(def_id, ty_generic_predicates); @@ -677,7 +677,7 @@ fn convert_associated_const<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, parent: Some(container.id()), predicates: vec![] }; - let def_id = ccx.tcx.map.local_def_id(id); + let def_id = ccx.tcx.hir.local_def_id(id); ccx.tcx.predicates.borrow_mut().insert(def_id, predicates); ccx.tcx.item_types.borrow_mut().insert(def_id, ty); } @@ -691,7 +691,7 @@ fn convert_associated_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, parent: Some(container.id()), predicates: vec![] }; - let def_id = ccx.tcx.map.local_def_id(id); + let def_id = ccx.tcx.hir.local_def_id(id); ccx.tcx.predicates.borrow_mut().insert(def_id, predicates); if let Some(ty) = ty { @@ -741,7 +741,7 @@ fn ensure_no_ty_param_bounds(ccx: &CrateCtxt, fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { let tcx = ccx.tcx; debug!("convert: item {} with id {}", it.name, it.id); - let def_id = ccx.tcx.map.local_def_id(it.id); + let def_id = ccx.tcx.hir.local_def_id(it.id); match it.node { // These don't define types. hir::ItemExternCrate(_) | hir::ItemUse(..) | hir::ItemMod(_) => { @@ -756,7 +756,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { let generics = generics_of_def_id(ccx, def_id); let predicates = predicates_of_item(ccx, it); convert_enum_variant_types(ccx, - tcx.lookup_adt_def(ccx.tcx.map.local_def_id(it.id)), + tcx.lookup_adt_def(ccx.tcx.hir.local_def_id(it.id)), ty, generics, predicates, @@ -771,7 +771,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { tcx.record_trait_has_default_impl(trait_ref.def_id); - tcx.impl_trait_refs.borrow_mut().insert(ccx.tcx.map.local_def_id(it.id), + tcx.impl_trait_refs.borrow_mut().insert(ccx.tcx.hir.local_def_id(it.id), Some(trait_ref)); } hir::ItemImpl(.., @@ -851,12 +851,12 @@ fn convert_trait_item(ccx: &CrateCtxt, trait_item: &hir::TraitItem) { // we can lookup details about the trait because items are visited // before trait-items - let trait_def_id = tcx.map.get_parent_did(trait_item.id); + let trait_def_id = tcx.hir.get_parent_did(trait_item.id); let trait_predicates = tcx.item_predicates(trait_def_id); match trait_item.node { hir::TraitItemKind::Const(ref ty, _) => { - let const_def_id = ccx.tcx.map.local_def_id(trait_item.id); + let const_def_id = ccx.tcx.hir.local_def_id(trait_item.id); generics_of_def_id(ccx, const_def_id); let ty = ccx.icx(&trait_predicates) .to_ty(&ExplicitRscope, &ty); @@ -866,7 +866,7 @@ fn convert_trait_item(ccx: &CrateCtxt, trait_item: &hir::TraitItem) { } hir::TraitItemKind::Type(_, ref opt_ty) => { - let type_def_id = ccx.tcx.map.local_def_id(trait_item.id); + let type_def_id = ccx.tcx.hir.local_def_id(trait_item.id); generics_of_def_id(ccx, type_def_id); let typ = opt_ty.as_ref().map({ @@ -893,14 +893,14 @@ fn convert_impl_item(ccx: &CrateCtxt, impl_item: &hir::ImplItem) { // we can lookup details about the impl because items are visited // before impl-items - let impl_def_id = tcx.map.get_parent_did(impl_item.id); + let impl_def_id = tcx.hir.get_parent_did(impl_item.id); let impl_predicates = tcx.item_predicates(impl_def_id); let impl_trait_ref = tcx.impl_trait_ref(impl_def_id); let impl_self_ty = tcx.item_type(impl_def_id); match impl_item.node { hir::ImplItemKind::Const(ref ty, _) => { - let const_def_id = ccx.tcx.map.local_def_id(impl_item.id); + let const_def_id = ccx.tcx.hir.local_def_id(impl_item.id); generics_of_def_id(ccx, const_def_id); let ty = ccx.icx(&impl_predicates) .to_ty(&ExplicitRscope, &ty); @@ -910,7 +910,7 @@ fn convert_impl_item(ccx: &CrateCtxt, impl_item: &hir::ImplItem) { } hir::ImplItemKind::Type(ref ty) => { - let type_def_id = ccx.tcx.map.local_def_id(impl_item.id); + let type_def_id = ccx.tcx.hir.local_def_id(impl_item.id); generics_of_def_id(ccx, type_def_id); if impl_trait_ref.is_none() { @@ -937,13 +937,13 @@ fn convert_variant_ctor<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, ty: Ty<'tcx>, predicates: ty::GenericPredicates<'tcx>) { let tcx = ccx.tcx; - let def_id = tcx.map.local_def_id(ctor_id); + let def_id = tcx.hir.local_def_id(ctor_id); generics_of_def_id(ccx, def_id); let ctor_ty = match variant.ctor_kind { CtorKind::Fictive | CtorKind::Const => ty, CtorKind::Fn => { let inputs = variant.fields.iter().map(|field| tcx.item_type(field.did)); - let substs = mk_item_substs(&ccx.icx(&predicates), ccx.tcx.map.span(ctor_id), def_id); + let substs = mk_item_substs(&ccx.icx(&predicates), ccx.tcx.hir.span(ctor_id), def_id); tcx.mk_fn_def(def_id, substs, tcx.mk_bare_fn(ty::BareFnTy { unsafety: hir::Unsafety::Normal, abi: abi::Abi::Rust, @@ -952,7 +952,7 @@ fn convert_variant_ctor<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, } }; tcx.item_types.borrow_mut().insert(def_id, ctor_ty); - tcx.predicates.borrow_mut().insert(tcx.map.local_def_id(ctor_id), predicates); + tcx.predicates.borrow_mut().insert(tcx.hir.local_def_id(ctor_id), predicates); } fn convert_enum_variant_types<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, @@ -986,9 +986,9 @@ fn convert_struct_variant<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, def: &hir::VariantData) -> ty::VariantDef { let mut seen_fields: FxHashMap = FxHashMap(); - let node_id = ccx.tcx.map.as_local_node_id(did).unwrap(); + let node_id = ccx.tcx.hir.as_local_node_id(did).unwrap(); let fields = def.fields().iter().map(|f| { - let fid = ccx.tcx.map.local_def_id(f.id); + let fid = ccx.tcx.hir.local_def_id(f.id); let dup_span = seen_fields.get(&f.name).cloned(); if let Some(prev_span) = dup_span { struct_span_err!(ccx.tcx.sess, f.span, E0124, @@ -1021,9 +1021,9 @@ fn convert_struct_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, def: &hir::VariantData) -> &'tcx ty::AdtDef { - let did = ccx.tcx.map.local_def_id(it.id); + let did = ccx.tcx.hir.local_def_id(it.id); // Use separate constructor id for unit/tuple structs and reuse did for braced structs. - let ctor_id = if !def.is_struct() { Some(ccx.tcx.map.local_def_id(def.id())) } else { None }; + let ctor_id = if !def.is_struct() { Some(ccx.tcx.hir.local_def_id(def.id())) } else { None }; let variants = vec![convert_struct_variant(ccx, ctor_id.unwrap_or(did), it.name, ConstInt::Infer(0), def)]; let adt = ccx.tcx.alloc_adt_def(did, AdtKind::Struct, variants); @@ -1041,7 +1041,7 @@ fn convert_union_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, def: &hir::VariantData) -> &'tcx ty::AdtDef { - let did = ccx.tcx.map.local_def_id(it.id); + let did = ccx.tcx.hir.local_def_id(it.id); let variants = vec![convert_struct_variant(ccx, did, it.name, ConstInt::Infer(0), def)]; let adt = ccx.tcx.alloc_adt_def(did, AdtKind::Union, variants); @@ -1051,8 +1051,8 @@ fn convert_union_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, fn evaluate_disr_expr(ccx: &CrateCtxt, repr_ty: attr::IntType, body: hir::BodyId) -> Option { - let e = &ccx.tcx.map.body(body).value; - debug!("disr expr, checking {}", ccx.tcx.map.node_to_pretty_string(e.id)); + let e = &ccx.tcx.hir.body(body).value; + debug!("disr expr, checking {}", ccx.tcx.hir.node_to_pretty_string(e.id)); let ty_hint = repr_ty.to_ty(ccx.tcx); let print_err = |cv: ConstVal| { @@ -1106,7 +1106,7 @@ fn convert_enum_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, -> &'tcx ty::AdtDef { let tcx = ccx.tcx; - let did = tcx.map.local_def_id(it.id); + let did = tcx.hir.local_def_id(it.id); let repr_hints = tcx.lookup_repr_hints(did); let repr_type = tcx.enum_repr_type(repr_hints.get(0)); let initial = repr_type.initial_discriminant(tcx); @@ -1128,7 +1128,7 @@ fn convert_enum_def<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, }.unwrap_or(wrapped_disr); prev_disr = Some(disr); - let did = tcx.map.local_def_id(v.node.data.id()); + let did = tcx.hir.local_def_id(v.node.data.id()); convert_struct_variant(ccx, did, v.node.name, disr, &v.node.data) }).collect(); @@ -1152,7 +1152,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, debug!("ensure_super_predicates_step(trait_def_id={:?})", trait_def_id); - let trait_node_id = if let Some(n) = tcx.map.as_local_node_id(trait_def_id) { + let trait_node_id = if let Some(n) = tcx.hir.as_local_node_id(trait_def_id) { n } else { // If this trait comes from an external crate, then all of the @@ -1165,7 +1165,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, let superpredicates = tcx.super_predicates.borrow().get(&trait_def_id).cloned(); let superpredicates = superpredicates.unwrap_or_else(|| { - let item = match ccx.tcx.map.get(trait_node_id) { + let item = match ccx.tcx.hir.get(trait_node_id) { hir_map::NodeItem(item) => item, _ => bug!("trait_node_id {} is not an item", trait_node_id) }; @@ -1213,7 +1213,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, predicates: superbounds }; debug!("superpredicates for trait {:?} = {:?}", - tcx.map.local_def_id(item.id), + tcx.hir.local_def_id(item.id), superpredicates); tcx.super_predicates.borrow_mut().insert(trait_def_id, superpredicates.clone()); @@ -1233,7 +1233,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, } fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &hir::Item) -> &'tcx ty::TraitDef { - let def_id = ccx.tcx.map.local_def_id(it.id); + let def_id = ccx.tcx.hir.local_def_id(it.id); let tcx = ccx.tcx; tcx.trait_defs.memoize(def_id, || { @@ -1262,7 +1262,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &hir::Item) -> &'t fn convert_trait_predicates<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &hir::Item) { let tcx = ccx.tcx; - let def_id = ccx.tcx.map.local_def_id(it.id); + let def_id = ccx.tcx.hir.local_def_id(it.id); generics_of_def_id(ccx, def_id); trait_def_of_item(ccx, it); @@ -1319,7 +1319,7 @@ fn convert_trait_predicates<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &hir::Item) -> Vec> { trait_item_refs.iter().flat_map(|trait_item_ref| { - let trait_item = ccx.tcx.map.trait_item(trait_item_ref.id); + let trait_item = ccx.tcx.hir.trait_item(trait_item_ref.id); let bounds = match trait_item.node { hir::TraitItemKind::Type(ref bounds, _) => bounds, _ => { @@ -1346,7 +1346,7 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, def_id: DefId) -> &'tcx ty::Generics<'tcx> { let tcx = ccx.tcx; - let node_id = if let Some(id) = tcx.map.as_local_node_id(def_id) { + let node_id = if let Some(id) = tcx.hir.as_local_node_id(def_id) { id } else { return tcx.item_generics(def_id); @@ -1355,14 +1355,14 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, use rustc::hir::map::*; use rustc::hir::*; - let node = tcx.map.get(node_id); + let node = tcx.hir.get(node_id); let parent_def_id = match node { NodeImplItem(_) | NodeTraitItem(_) | NodeVariant(_) | NodeStructCtor(_) => { - let parent_id = tcx.map.get_parent(node_id); - Some(tcx.map.local_def_id(parent_id)) + let parent_id = tcx.hir.get_parent(node_id); + Some(tcx.hir.local_def_id(parent_id)) } NodeExpr(&hir::Expr { node: hir::ExprClosure(..), .. }) => { Some(tcx.closure_base_def_id(def_id)) @@ -1370,14 +1370,14 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, NodeTy(&hir::Ty { node: hir::TyImplTrait(..), .. }) => { let mut parent_id = node_id; loop { - match tcx.map.get(parent_id) { + match tcx.hir.get(parent_id) { NodeItem(_) | NodeImplItem(_) | NodeTraitItem(_) => break, _ => { - parent_id = tcx.map.get_parent_node(parent_id); + parent_id = tcx.hir.get_parent_node(parent_id); } } } - Some(tcx.map.local_def_id(parent_id)) + Some(tcx.hir.local_def_id(parent_id)) } _ => None }; @@ -1421,13 +1421,13 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // the node id for the Self type parameter. let param_id = item.id; - let parent = ccx.tcx.map.get_parent(param_id); + let parent = ccx.tcx.hir.get_parent(param_id); let def = ty::TypeParameterDef { index: 0, name: keywords::SelfType.name(), - def_id: tcx.map.local_def_id(param_id), - default_def_id: tcx.map.local_def_id(parent), + def_id: tcx.hir.local_def_id(param_id), + default_def_id: tcx.hir.local_def_id(parent), default: None, object_lifetime_default: ty::ObjectLifetimeDefault::BaseDefault, pure_wrt_drop: false, @@ -1470,7 +1470,7 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, ty::RegionParameterDef { name: l.lifetime.name, index: own_start + i as u32, - def_id: tcx.map.local_def_id(l.lifetime.id), + def_id: tcx.hir.local_def_id(l.lifetime.id), bounds: l.bounds.iter().map(|l| { ast_region_to_region(tcx, l) }).collect(), @@ -1512,7 +1512,7 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, d => format!("{:?}", d), } }).collect::>().join(","); - tcx.sess.span_err(tcx.map.span(node_id), &object_lifetime_default_reprs); + tcx.sess.span_err(tcx.hir.span(node_id), &object_lifetime_default_reprs); } tcx.alloc_generics(ty::Generics { @@ -1529,7 +1529,7 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, fn type_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, def_id: DefId) -> Ty<'tcx> { - let node_id = if let Some(id) = ccx.tcx.map.as_local_node_id(def_id) { + let node_id = if let Some(id) = ccx.tcx.hir.as_local_node_id(def_id) { id } else { return ccx.tcx.item_type(def_id); @@ -1541,7 +1541,7 @@ fn type_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // Alway bring in generics, as computing the type needs them. generics_of_def_id(ccx, def_id); - let ty = match ccx.tcx.map.get(node_id) { + let ty = match ccx.tcx.hir.get(node_id) { NodeItem(item) => { match item.node { ItemStatic(ref t, ..) | ItemConst(ref t, _) => { @@ -1586,12 +1586,12 @@ fn type_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, } } NodeForeignItem(foreign_item) => { - let abi = ccx.tcx.map.get_foreign_abi(node_id); + let abi = ccx.tcx.hir.get_foreign_abi(node_id); match foreign_item.node { ForeignItemFn(ref fn_decl, _, ref generics) => { compute_type_of_foreign_fn_decl( - ccx, ccx.tcx.map.local_def_id(foreign_item.id), + ccx, ccx.tcx.hir.local_def_id(foreign_item.id), fn_decl, generics, abi) } ForeignItemStatic(ref t, _) => { @@ -1621,7 +1621,7 @@ fn type_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, fn predicates_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &hir::Item) -> ty::GenericPredicates<'tcx> { - let def_id = ccx.tcx.map.local_def_id(it.id); + let def_id = ccx.tcx.hir.local_def_id(it.id); let no_generics = hir::Generics::empty(); let generics = match it.node { @@ -1648,7 +1648,7 @@ fn convert_foreign_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // map, and I regard each time that I use it as a personal and // moral failing, but at the moment it seems like the only // convenient way to extract the ABI. - ndm - let def_id = ccx.tcx.map.local_def_id(it.id); + let def_id = ccx.tcx.hir.local_def_id(it.id); type_of_def_id(ccx, def_id); generics_of_def_id(ccx, def_id); @@ -1868,7 +1868,7 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, compute_object_lifetime_default(ccx, param.id, ¶m.bounds, &ast_generics.where_clause); - let parent = tcx.map.get_parent(param.id); + let parent = tcx.hir.get_parent(param.id); if !allow_defaults && default.is_some() { if !tcx.sess.features.borrow().default_type_parameter_fallback { @@ -1884,8 +1884,8 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, let def = ty::TypeParameterDef { index: index, name: param.name, - def_id: ccx.tcx.map.local_def_id(param.id), - default_def_id: ccx.tcx.map.local_def_id(parent), + def_id: ccx.tcx.hir.local_def_id(param.id), + default_def_id: ccx.tcx.hir.local_def_id(parent), default: default, object_lifetime_default: object_lifetime_default, pure_wrt_drop: param.pure_wrt_drop, @@ -2083,7 +2083,7 @@ fn compute_type_of_foreign_fn_decl<'a, 'tcx>( ccx.tcx.sess.struct_span_err(ast_ty.span, &format!("use of SIMD type `{}` in FFI is highly experimental and \ may result in invalid code", - ccx.tcx.map.node_to_pretty_string(ast_ty.id))) + ccx.tcx.hir.node_to_pretty_string(ast_ty.id))) .help("add #![feature(simd_ffi)] to the crate attributes to enable") .emit(); } @@ -2096,8 +2096,8 @@ fn compute_type_of_foreign_fn_decl<'a, 'tcx>( } } - let id = ccx.tcx.map.as_local_node_id(def_id).unwrap(); - let substs = mk_item_substs(&ccx.icx(ast_generics), ccx.tcx.map.span(id), def_id); + let id = ccx.tcx.hir.as_local_node_id(def_id).unwrap(); + let substs = mk_item_substs(&ccx.icx(ast_generics), ccx.tcx.hir.span(id), def_id); ccx.tcx.mk_fn_def(def_id, substs, ccx.tcx.mk_bare_fn(ty::BareFnTy { abi: abi, unsafety: hir::Unsafety::Unsafe, diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index ce495e6fb4cd8..3a19b3579d559 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -76,7 +76,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.node { hir::ItemImpl(.., ref generics, _, _, ref impl_item_refs) => { - let impl_def_id = self.ccx.tcx.map.local_def_id(item.id); + let impl_def_id = self.ccx.tcx.hir.local_def_id(item.id); enforce_impl_params_are_constrained(self.ccx, generics, impl_def_id, @@ -117,7 +117,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // Disallow unconstrained lifetimes, but only if they appear in assoc types. let lifetimes_in_associated_types: FxHashSet<_> = impl_item_refs.iter() - .map(|item_ref| ccx.tcx.map.local_def_id(item_ref.id.node_id)) + .map(|item_ref| ccx.tcx.hir.local_def_id(item_ref.id.node_id)) .filter(|&def_id| { let item = ccx.tcx.associated_item(def_id); item.kind == ty::AssociatedKind::Type && item.defaultness.has_value() @@ -181,7 +181,7 @@ fn enforce_impl_items_are_distinct<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let mut seen_type_items = FxHashMap(); let mut seen_value_items = FxHashMap(); for impl_item_ref in impl_item_refs { - let impl_item = tcx.map.impl_item(impl_item_ref.id); + let impl_item = tcx.hir.impl_item(impl_item_ref.id); let seen_items = match impl_item.node { hir::ImplItemKind::Type(_) => &mut seen_type_items, _ => &mut seen_value_items, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 6d30a85b58291..0e7daa03404c5 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -196,11 +196,11 @@ fn check_main_fn_ty(ccx: &CrateCtxt, main_id: ast::NodeId, main_span: Span) { let tcx = ccx.tcx; - let main_def_id = tcx.map.local_def_id(main_id); + let main_def_id = tcx.hir.local_def_id(main_id); let main_t = tcx.item_type(main_def_id); match main_t.sty { ty::TyFnDef(..) => { - match tcx.map.find(main_id) { + match tcx.hir.find(main_id) { Some(hir_map::NodeItem(it)) => { match it.node { hir::ItemFn(.., ref generics, _) => { @@ -244,11 +244,11 @@ fn check_start_fn_ty(ccx: &CrateCtxt, start_id: ast::NodeId, start_span: Span) { let tcx = ccx.tcx; - let start_def_id = ccx.tcx.map.local_def_id(start_id); + let start_def_id = ccx.tcx.hir.local_def_id(start_id); let start_t = tcx.item_type(start_def_id); match start_t.sty { ty::TyFnDef(..) => { - match tcx.map.find(start_id) { + match tcx.hir.find(start_id) { Some(hir_map::NodeItem(it)) => { match it.node { hir::ItemFn(..,ref ps,_) diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 507079a4f874c..55033330a4490 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -74,9 +74,9 @@ pub fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>) impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { let tcx = self.terms_cx.tcx; - let did = tcx.map.local_def_id(item.id); + let did = tcx.hir.local_def_id(item.id); - debug!("visit_item item={}", tcx.map.node_to_string(item.id)); + debug!("visit_item item={}", tcx.hir.node_to_string(item.id)); match item.node { hir::ItemEnum(..) | @@ -145,14 +145,14 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { Some(&index) => index, None => { bug!("no inferred index entry for {}", - self.tcx().map.node_to_string(param_id)); + self.tcx().hir.node_to_string(param_id)); } } } fn find_binding_for_lifetime(&self, param_id: ast::NodeId) -> ast::NodeId { let tcx = self.terms_cx.tcx; - assert!(is_lifetime(&tcx.map, param_id)); + assert!(is_lifetime(&tcx.hir, param_id)); match tcx.named_region_map.defs.get(¶m_id) { Some(&rl::DefEarlyBoundRegion(_, lifetime_decl_id)) => lifetime_decl_id, Some(_) => bug!("should not encounter non early-bound cases"), @@ -177,17 +177,17 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { let tcx = this.terms_cx.tcx; let decl_id = this.find_binding_for_lifetime(param_id); // Currently only called on lifetimes; double-checking that. - assert!(is_lifetime(&tcx.map, param_id)); - let parent_id = tcx.map.get_parent(decl_id); - let parent = tcx.map + assert!(is_lifetime(&tcx.hir, param_id)); + let parent_id = tcx.hir.get_parent(decl_id); + let parent = tcx.hir .find(parent_id) - .unwrap_or_else(|| bug!("tcx.map missing entry for id: {}", parent_id)); + .unwrap_or_else(|| bug!("tcx.hir missing entry for id: {}", parent_id)); let is_inferred; macro_rules! cannot_happen { () => { { bug!("invalid parent: {} for {}", - tcx.map.node_to_string(parent_id), - tcx.map.node_to_string(param_id)); + tcx.hir.node_to_string(parent_id), + tcx.hir.node_to_string(param_id)); } } } match parent { @@ -224,7 +224,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { -> VarianceTermPtr<'a> { assert_eq!(param_def_id.krate, item_def_id.krate); - if let Some(param_node_id) = self.tcx().map.as_local_node_id(param_def_id) { + if let Some(param_node_id) = self.tcx().hir.as_local_node_id(param_def_id) { // Parameter on an item defined within current crate: // variance not yet inferred, so return a symbolic // variance. @@ -400,7 +400,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { i -= generics.regions.len(); } let def_id = generics.types[i].def_id; - let node_id = self.tcx().map.as_local_node_id(def_id).unwrap(); + let node_id = self.tcx().hir.as_local_node_id(def_id).unwrap(); match self.terms_cx.inferred_map.get(&node_id) { Some(&index) => { self.add_constraint(index, variance); @@ -487,7 +487,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { assert_eq!(generics.parent, None); let i = data.index as usize - generics.has_self as usize; let def_id = generics.regions[i].def_id; - let node_id = self.tcx().map.as_local_node_id(def_id).unwrap(); + let node_id = self.tcx().hir.as_local_node_id(def_id).unwrap(); if self.is_to_be_inferred(node_id) { let index = self.inferred_index(node_id); self.add_constraint(index, variance); diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index a5c53b4c6291c..bdf1d0590bcc7 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -125,13 +125,13 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { debug!("item_id={} item_variances={:?}", item_id, item_variances); - let item_def_id = tcx.map.local_def_id(item_id); + let item_def_id = tcx.hir.local_def_id(item_id); // For unit testing: check for a special "rustc_variance" // attribute and report an error with various results if found. if tcx.has_attr(item_def_id, "rustc_variance") { span_err!(tcx.sess, - tcx.map.span(item_id), + tcx.hir.span(item_id), E0208, "{:?}", item_variances); diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index d4d3edbcb126e..0e09d34cc9bd3 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -132,7 +132,7 @@ fn lang_items(tcx: TyCtxt) -> Vec<(ast::NodeId, Vec)> { all.into_iter() // iterating over (Option, Variance) .filter(|&(ref d,_)| d.is_some()) .map(|(d, v)| (d.unwrap(), v)) // (DefId, Variance) - .filter_map(|(d, v)| tcx.map.as_local_node_id(d).map(|n| (n, v))) // (NodeId, Variance) + .filter_map(|(d, v)| tcx.hir.as_local_node_id(d).map(|n| (n, v))) // (NodeId, Variance) .collect() } @@ -177,7 +177,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> { // "invalid item id" from "item id with no // parameters". if self.num_inferred() == inferreds_on_entry { - let item_def_id = self.tcx.map.local_def_id(item_id); + let item_def_id = self.tcx.hir.local_def_id(item_id); let newly_added = self.tcx .item_variance_map .borrow_mut() @@ -207,7 +207,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> { param_id={}, \ inf_index={:?}, \ initial_variance={:?})", - self.tcx.item_path_str(self.tcx.map.local_def_id(item_id)), + self.tcx.item_path_str(self.tcx.hir.local_def_id(item_id)), item_id, index, param_id, @@ -230,7 +230,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { debug!("add_inferreds for item {}", - self.tcx.map.node_to_string(item.id)); + self.tcx.hir.node_to_string(item.id)); match item.node { hir::ItemEnum(_, ref generics) | diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a77485477b159..eedca0ffb6327 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -223,17 +223,17 @@ impl Clean for CrateNum { None }; let primitives = if root.is_local() { - cx.tcx.map.krate().module.item_ids.iter().filter_map(|&id| { - let item = cx.tcx.map.expect_item(id.id); + cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| { + let item = cx.tcx.hir.expect_item(id.id); match item.node { hir::ItemMod(_) => { - as_primitive(Def::Mod(cx.tcx.map.local_def_id(id.id))) + as_primitive(Def::Mod(cx.tcx.hir.local_def_id(id.id))) } hir::ItemUse(ref path, hir::UseKind::Single) if item.vis == hir::Visibility::Public => { as_primitive(path.def).map(|(_, prim, attrs)| { // Pretend the primitive is local. - (cx.tcx.map.local_def_id(id.id), prim, attrs) + (cx.tcx.hir.local_def_id(id.id), prim, attrs) }) } _ => None @@ -454,7 +454,7 @@ impl Clean for doctree::Module { visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), inner: ModuleItem(Module { is_crate: self.is_crate, items: items @@ -576,7 +576,7 @@ impl Clean for hir::TyParam { fn clean(&self, cx: &DocContext) -> TyParam { TyParam { name: self.name.clean(cx), - did: cx.tcx.map.local_def_id(self.id), + did: cx.tcx.hir.local_def_id(self.id), bounds: self.bounds.clean(cx), default: self.default.clean(cx), } @@ -1067,7 +1067,7 @@ impl Clean for doctree::Function { visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), inner: FunctionItem(Function { decl: (&self.decl, self.body).clean(cx), generics: self.generics.clean(cx), @@ -1122,7 +1122,7 @@ impl<'a> Clean for (&'a [P], &'a [Spanned]) { impl<'a> Clean for (&'a [P], hir::BodyId) { fn clean(&self, cx: &DocContext) -> Arguments { - let body = cx.tcx.map.body(self.1); + let body = cx.tcx.hir.body(self.1); Arguments { values: self.0.iter().enumerate().map(|(i, ty)| { @@ -1151,7 +1151,7 @@ impl<'a, A: Copy> Clean for (&'a hir::FnDecl, A) impl<'a, 'tcx> Clean for (DefId, &'a ty::PolyFnSig<'tcx>) { fn clean(&self, cx: &DocContext) -> FnDecl { let (did, sig) = *self; - let mut names = if cx.tcx.map.as_local_node_id(did).is_some() { + let mut names = if cx.tcx.hir.as_local_node_id(did).is_some() { vec![].into_iter() } else { cx.tcx.sess.cstore.fn_arg_names(did).into_iter() @@ -1231,7 +1231,7 @@ impl Clean for doctree::Trait { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), @@ -1286,10 +1286,10 @@ impl Clean for hir::TraitItem { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.span.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: None, - stability: get_stability(cx, cx.tcx.map.local_def_id(self.id)), - deprecation: get_deprecation(cx, cx.tcx.map.local_def_id(self.id)), + stability: get_stability(cx, cx.tcx.hir.local_def_id(self.id)), + deprecation: get_deprecation(cx, cx.tcx.hir.local_def_id(self.id)), inner: inner } } @@ -1318,10 +1318,10 @@ impl Clean for hir::ImplItem { name: Some(self.name.clean(cx)), source: self.span.clean(cx), attrs: self.attrs.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), - stability: get_stability(cx, cx.tcx.map.local_def_id(self.id)), - deprecation: get_deprecation(cx, cx.tcx.map.local_def_id(self.id)), + stability: get_stability(cx, cx.tcx.hir.local_def_id(self.id)), + deprecation: get_deprecation(cx, cx.tcx.hir.local_def_id(self.id)), inner: inner } } @@ -1703,9 +1703,9 @@ impl Clean for hir::Ty { let mut alias = None; if let Def::TyAlias(def_id) = path.def { // Substitute private type aliases - if let Some(node_id) = cx.tcx.map.as_local_node_id(def_id) { + if let Some(node_id) = cx.tcx.hir.as_local_node_id(def_id) { if !cx.access_levels.borrow().is_exported(def_id) { - alias = Some(&cx.tcx.map.expect_item(node_id).node); + alias = Some(&cx.tcx.hir.expect_item(node_id).node); } } }; @@ -1715,7 +1715,7 @@ impl Clean for hir::Ty { let mut ty_substs = FxHashMap(); let mut lt_substs = FxHashMap(); for (i, ty_param) in generics.ty_params.iter().enumerate() { - let ty_param_def = Def::TyParam(cx.tcx.map.local_def_id(ty_param.id)); + let ty_param_def = Def::TyParam(cx.tcx.hir.local_def_id(ty_param.id)); if let Some(ty) = provided_params.types().get(i).cloned() .cloned() { ty_substs.insert(ty_param_def, ty.unwrap().clean(cx)); @@ -1823,7 +1823,7 @@ impl<'tcx> Clean for ty::Ty<'tcx> { type_params: Vec::new(), where_predicates: Vec::new() }, - decl: (cx.tcx.map.local_def_id(ast::CRATE_NODE_ID), &fty.sig).clean(cx), + decl: (cx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), &fty.sig).clean(cx), abi: fty.abi, }), ty::TyAdt(def, substs) => { @@ -1919,9 +1919,9 @@ impl Clean for hir::StructField { attrs: self.attrs.clean(cx), source: self.span.clean(cx), visibility: self.vis.clean(cx), - stability: get_stability(cx, cx.tcx.map.local_def_id(self.id)), - deprecation: get_deprecation(cx, cx.tcx.map.local_def_id(self.id)), - def_id: cx.tcx.map.local_def_id(self.id), + stability: get_stability(cx, cx.tcx.hir.local_def_id(self.id)), + deprecation: get_deprecation(cx, cx.tcx.hir.local_def_id(self.id)), + def_id: cx.tcx.hir.local_def_id(self.id), inner: StructFieldItem(self.ty.clean(cx)), } } @@ -1982,7 +1982,7 @@ impl Clean for doctree::Struct { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), @@ -2002,7 +2002,7 @@ impl Clean for doctree::Union { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), @@ -2049,7 +2049,7 @@ impl Clean for doctree::Enum { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), @@ -2076,7 +2076,7 @@ impl Clean for doctree::Variant { visibility: None, stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), - def_id: cx.tcx.map.local_def_id(self.def.id()), + def_id: cx.tcx.hir.local_def_id(self.def.id()), inner: VariantItem(Variant { kind: self.def.clean(cx), }), @@ -2306,7 +2306,7 @@ impl Clean for doctree::Typedef { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id.clone()), + def_id: cx.tcx.hir.local_def_id(self.id.clone()), visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), @@ -2358,7 +2358,7 @@ impl Clean for doctree::Static { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), @@ -2383,7 +2383,7 @@ impl Clean for doctree::Constant { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), @@ -2459,7 +2459,7 @@ impl Clean> for doctree::Impl { name: None, attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), @@ -2542,7 +2542,7 @@ impl Clean for doctree::DefaultImpl { name: None, attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: Some(Public), stability: None, deprecation: None, @@ -2598,7 +2598,7 @@ impl Clean> for doctree::Import { name: None, attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.map.local_def_id(ast::CRATE_NODE_ID), + def_id: cx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), visibility: self.vis.clean(cx), stability: None, deprecation: None, @@ -2657,10 +2657,10 @@ impl Clean for hir::ForeignItem { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.span.clean(cx), - def_id: cx.tcx.map.local_def_id(self.id), + def_id: cx.tcx.hir.local_def_id(self.id), visibility: self.vis.clean(cx), - stability: get_stability(cx, cx.tcx.map.local_def_id(self.id)), - deprecation: get_deprecation(cx, cx.tcx.map.local_def_id(self.id)), + stability: get_stability(cx, cx.tcx.hir.local_def_id(self.id)), + deprecation: get_deprecation(cx, cx.tcx.hir.local_def_id(self.id)), inner: inner, } } @@ -2721,7 +2721,7 @@ fn name_from_pat(p: &hir::Pat) -> String { } fn print_const_expr(cx: &DocContext, body: hir::BodyId) -> String { - cx.tcx.map.node_to_pretty_string(body.node_id) + cx.tcx.hir.node_to_pretty_string(body.node_id) } /// Given a type Path, resolve it to a Type using the TyCtxt diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 514eb6ea843de..5393e395bbe43 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -189,7 +189,7 @@ pub fn run_core(search_paths: SearchPaths, // to the map from defid -> nodeid let access_levels = AccessLevels { map: access_levels.map.into_iter() - .map(|(k, v)| (tcx.map.local_def_id(k), v)) + .map(|(k, v)| (tcx.hir.local_def_id(k), v)) .collect() }; @@ -204,11 +204,11 @@ pub fn run_core(search_paths: SearchPaths, export_map: export_map, hir_ty_to_ty: hir_ty_to_ty, }; - debug!("crate: {:?}", tcx.map.krate()); + debug!("crate: {:?}", tcx.hir.krate()); let krate = { let mut v = RustdocVisitor::new(&ctxt); - v.visit(tcx.map.krate()); + v.visit(tcx.hir.krate()); v.clean(&ctxt) }; diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index b0afc3d63f479..394eb4779898c 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -65,12 +65,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { } fn stability(&self, id: ast::NodeId) -> Option { - self.cx.tcx.map.opt_local_def_id(id) + self.cx.tcx.hir.opt_local_def_id(id) .and_then(|def_id| self.cx.tcx.lookup_stability(def_id)).cloned() } fn deprecation(&self, id: ast::NodeId) -> Option { - self.cx.tcx.map.opt_local_def_id(id) + self.cx.tcx.hir.opt_local_def_id(id) .and_then(|def_id| self.cx.tcx.lookup_deprecation(def_id)) } @@ -193,7 +193,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { let orig_inside_public_path = self.inside_public_path; self.inside_public_path &= vis == hir::Public; for i in &m.item_ids { - let item = self.cx.tcx.map.expect_item(i.id); + let item = self.cx.tcx.hir.expect_item(i.id); self.visit_item(item, None, &mut om); } self.inside_public_path = orig_inside_public_path; @@ -246,9 +246,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { please_inline: bool) -> bool { fn inherits_doc_hidden(cx: &core::DocContext, mut node: ast::NodeId) -> bool { - while let Some(id) = cx.tcx.map.get_enclosing_scope(node) { + while let Some(id) = cx.tcx.hir.get_enclosing_scope(node) { node = id; - if cx.tcx.map.attrs(node).lists("doc").has_word("hidden") { + if cx.tcx.hir.attrs(node).lists("doc").has_word("hidden") { return true; } if node == ast::CRATE_NODE_ID { @@ -264,7 +264,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { } let def_did = def.def_id(); - let use_attrs = tcx.map.attrs(id); + let use_attrs = tcx.hir.attrs(id); // Don't inline doc(hidden) imports so they can be stripped at a later stage. let is_no_inline = use_attrs.lists("doc").has_word("no_inline") || use_attrs.lists("doc").has_word("hidden"); @@ -292,7 +292,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { return false } - let def_node_id = match tcx.map.as_local_node_id(def_did) { + let def_node_id = match tcx.hir.as_local_node_id(def_did) { Some(n) => n, None => return false }; @@ -306,14 +306,14 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { if !self.view_item_stack.insert(def_node_id) { return false } - let ret = match tcx.map.get(def_node_id) { + let ret = match tcx.hir.get(def_node_id) { hir_map::NodeItem(it) => { let prev = mem::replace(&mut self.inlining, true); if glob { match it.node { hir::ItemMod(ref m) => { for i in &m.item_ids { - let i = self.cx.tcx.map.expect_item(i.id); + let i = self.cx.tcx.hir.expect_item(i.id); self.visit_item(i, None, om); } } @@ -460,7 +460,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { }, hir::ItemTrait(unsafety, ref gen, ref b, ref item_ids) => { let items = item_ids.iter() - .map(|ti| self.cx.tcx.map.trait_item(ti.id).clone()) + .map(|ti| self.cx.tcx.hir.trait_item(ti.id).clone()) .collect(); let t = Trait { unsafety: unsafety, @@ -483,7 +483,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { // regardless of where they're located. if !self.inlining { let items = item_ids.iter() - .map(|ii| self.cx.tcx.map.impl_item(ii.id).clone()) + .map(|ii| self.cx.tcx.hir.impl_item(ii.id).clone()) .collect(); let i = Impl { unsafety: unsafety, @@ -524,7 +524,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { let matchers = def.body.chunks(4).map(|arm| arm[0].get_span()).collect(); Macro { - def_id: self.cx.tcx.map.local_def_id(def.id), + def_id: self.cx.tcx.hir.local_def_id(def.id), attrs: def.attrs.clone(), name: def.name, whence: def.span, diff --git a/src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs b/src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs index e1b1b441894b7..778c49d144c02 100644 --- a/src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs +++ b/src/test/run-pass-fulldeps/issue-37290/auxiliary/lint.rs @@ -53,8 +53,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { if let Some(other) = self.map.insert(extent, node) { cx.span_lint(REGION_HIERARCHY, span, &format!( "different fns {:?}, {:?} with the same root extent {:?}", - cx.tcx.map.local_def_id(other), - cx.tcx.map.local_def_id(node), + cx.tcx.hir.local_def_id(other), + cx.tcx.hir.local_def_id(node), extent)); } } From 1ff3641623ce5f83cba30c2d2f039dbd49c4b4b8 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 26 Jan 2017 03:21:50 +0200 Subject: [PATCH 2/2] rustc: don't call the HIR AST. --- src/librustc/cfg/graphviz.rs | 14 +- src/librustc/hir/intravisit.rs | 12 +- src/librustc/hir/map/collector.rs | 54 +++---- src/librustc/hir/map/mod.rs | 152 ++++++++++---------- src/librustc/infer/error_reporting.rs | 44 +++--- src/librustc/middle/dead.rs | 20 +-- src/librustc/middle/entry.rs | 14 +- src/librustc/middle/lang_items.rs | 14 +- src/librustc/middle/mem_categorization.rs | 6 +- src/librustc/middle/reachable.rs | 30 ++-- src/librustc/middle/region.rs | 46 +++--- src/librustc/ty/context.rs | 6 +- src/librustc/ty/mod.rs | 22 +-- src/librustc/ty/util.rs | 4 +- src/librustc_borrowck/borrowck/move_data.rs | 2 +- src/librustc_const_eval/eval.rs | 10 +- src/librustc_driver/driver.rs | 6 +- src/librustc_driver/lib.rs | 2 +- src/librustc_driver/pretty.rs | 136 ++++++++---------- src/librustc_driver/test.rs | 12 +- src/librustc_passes/loops.rs | 18 +-- src/librustc_passes/static_recursion.rs | 84 +++++------ 22 files changed, 345 insertions(+), 363 deletions(-) diff --git a/src/librustc/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs index c651baae28224..944b77dbf01fd 100644 --- a/src/librustc/cfg/graphviz.rs +++ b/src/librustc/cfg/graphviz.rs @@ -17,14 +17,14 @@ use graphviz::IntoCow; use syntax::ast; -use hir::map as ast_map; +use hir::map as hir_map; use cfg; pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode); pub type Edge<'a> = &'a cfg::CFGEdge; -pub struct LabelledCFG<'a, 'ast: 'a> { - pub ast_map: &'a ast_map::Map<'ast>, +pub struct LabelledCFG<'a, 'hir: 'a> { + pub hir_map: &'a hir_map::Map<'hir>, pub cfg: &'a cfg::CFG, pub name: String, /// `labelled_edges` controls whether we emit labels on the edges @@ -52,7 +52,7 @@ fn replace_newline_with_backslash_l(s: String) -> String { } } -impl<'a, 'ast> dot::Labeller<'a> for LabelledCFG<'a, 'ast> { +impl<'a, 'hir> dot::Labeller<'a> for LabelledCFG<'a, 'hir> { type Node = Node<'a>; type Edge = Edge<'a>; fn graph_id(&'a self) -> dot::Id<'a> { dot::Id::new(&self.name[..]).unwrap() } @@ -69,7 +69,7 @@ impl<'a, 'ast> dot::Labeller<'a> for LabelledCFG<'a, 'ast> { } else if n.data.id() == ast::DUMMY_NODE_ID { dot::LabelText::LabelStr("(dummy_node)".into_cow()) } else { - let s = self.ast_map.node_to_string(n.data.id()); + let s = self.hir_map.node_to_string(n.data.id()); // left-aligns the lines let s = replace_newline_with_backslash_l(s); dot::LabelText::EscStr(s.into_cow()) @@ -88,7 +88,7 @@ impl<'a, 'ast> dot::Labeller<'a> for LabelledCFG<'a, 'ast> { } else { put_one = true; } - let s = self.ast_map.node_to_string(node_id); + let s = self.hir_map.node_to_string(node_id); // left-aligns the lines let s = replace_newline_with_backslash_l(s); label.push_str(&format!("exiting scope_{} {}", @@ -120,7 +120,7 @@ impl<'a> dot::GraphWalk<'a> for &'a cfg::CFG { } } -impl<'a, 'ast> dot::GraphWalk<'a> for LabelledCFG<'a, 'ast> +impl<'a, 'hir> dot::GraphWalk<'a> for LabelledCFG<'a, 'hir> { type Node = Node<'a>; type Edge = Edge<'a>; diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index cc6d61c21c696..d4095c6875c1d 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -1085,13 +1085,13 @@ impl IdRange { } -pub struct IdRangeComputingVisitor<'a, 'ast: 'a> { +pub struct IdRangeComputingVisitor<'a, 'hir: 'a> { result: IdRange, - map: &'a map::Map<'ast>, + map: &'a map::Map<'hir>, } -impl<'a, 'ast> IdRangeComputingVisitor<'a, 'ast> { - pub fn new(map: &'a map::Map<'ast>) -> IdRangeComputingVisitor<'a, 'ast> { +impl<'a, 'hir> IdRangeComputingVisitor<'a, 'hir> { + pub fn new(map: &'a map::Map<'hir>) -> IdRangeComputingVisitor<'a, 'hir> { IdRangeComputingVisitor { result: IdRange::max(), map: map } } @@ -1100,8 +1100,8 @@ impl<'a, 'ast> IdRangeComputingVisitor<'a, 'ast> { } } -impl<'a, 'ast> Visitor<'ast> for IdRangeComputingVisitor<'a, 'ast> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> { +impl<'a, 'hir> Visitor<'hir> for IdRangeComputingVisitor<'a, 'hir> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { NestedVisitorMap::OnlyBodies(&self.map) } diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index bd0ff695d093a..904f74b8787fd 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -16,17 +16,17 @@ use syntax::ast::{NodeId, CRATE_NODE_ID}; use syntax_pos::Span; /// A Visitor that walks over the HIR and collects Nodes into a HIR map -pub struct NodeCollector<'ast> { +pub struct NodeCollector<'hir> { /// The crate - pub krate: &'ast Crate, + pub krate: &'hir Crate, /// The node map - pub(super) map: Vec>, + pub(super) map: Vec>, /// The parent of this node pub parent_node: NodeId, } -impl<'ast> NodeCollector<'ast> { - pub fn root(krate: &'ast Crate) -> NodeCollector<'ast> { +impl<'hir> NodeCollector<'hir> { + pub fn root(krate: &'hir Crate) -> NodeCollector<'hir> { let mut collector = NodeCollector { krate: krate, map: vec![], @@ -37,8 +37,8 @@ impl<'ast> NodeCollector<'ast> { collector } - fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'ast>) { - debug!("ast_map: {:?} => {:?}", id, entry); + fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'hir>) { + debug!("hir_map: {:?} => {:?}", id, entry); let len = self.map.len(); if id.as_usize() >= len { self.map.extend(repeat(NotPresent).take(id.as_usize() - len + 1)); @@ -46,7 +46,7 @@ impl<'ast> NodeCollector<'ast> { self.map[id.as_usize()] = entry; } - fn insert(&mut self, id: NodeId, node: Node<'ast>) { + fn insert(&mut self, id: NodeId, node: Node<'hir>) { let entry = MapEntry::from_node(self.parent_node, node); self.insert_entry(id, entry); } @@ -59,12 +59,12 @@ impl<'ast> NodeCollector<'ast> { } } -impl<'ast> Visitor<'ast> for NodeCollector<'ast> { +impl<'hir> Visitor<'hir> for NodeCollector<'hir> { /// Because we want to track parent items and so forth, enable /// deep walking so that we walk nested items in the context of /// their outer items. - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { panic!("visit_nested_xxx must be manually implemented in this visitor") } @@ -85,7 +85,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { self.visit_body(self.krate.body(id)); } - fn visit_item(&mut self, i: &'ast Item) { + fn visit_item(&mut self, i: &'hir Item) { debug!("visit_item: {:?}", i); self.insert(i.id, NodeItem(i)); @@ -104,7 +104,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) { + fn visit_foreign_item(&mut self, foreign_item: &'hir ForeignItem) { self.insert(foreign_item.id, NodeForeignItem(foreign_item)); self.with_parent(foreign_item.id, |this| { @@ -112,7 +112,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_generics(&mut self, generics: &'ast Generics) { + fn visit_generics(&mut self, generics: &'hir Generics) { for ty_param in generics.ty_params.iter() { self.insert(ty_param.id, NodeTyParam(ty_param)); } @@ -120,7 +120,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { intravisit::walk_generics(self, generics); } - fn visit_trait_item(&mut self, ti: &'ast TraitItem) { + fn visit_trait_item(&mut self, ti: &'hir TraitItem) { self.insert(ti.id, NodeTraitItem(ti)); self.with_parent(ti.id, |this| { @@ -128,7 +128,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_impl_item(&mut self, ii: &'ast ImplItem) { + fn visit_impl_item(&mut self, ii: &'hir ImplItem) { self.insert(ii.id, NodeImplItem(ii)); self.with_parent(ii.id, |this| { @@ -136,7 +136,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_pat(&mut self, pat: &'ast Pat) { + fn visit_pat(&mut self, pat: &'hir Pat) { let node = if let PatKind::Binding(..) = pat.node { NodeLocal(pat) } else { @@ -149,7 +149,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_expr(&mut self, expr: &'ast Expr) { + fn visit_expr(&mut self, expr: &'hir Expr) { self.insert(expr.id, NodeExpr(expr)); self.with_parent(expr.id, |this| { @@ -157,7 +157,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_stmt(&mut self, stmt: &'ast Stmt) { + fn visit_stmt(&mut self, stmt: &'hir Stmt) { let id = stmt.node.id(); self.insert(id, NodeStmt(stmt)); @@ -166,7 +166,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_ty(&mut self, ty: &'ast Ty) { + fn visit_ty(&mut self, ty: &'hir Ty) { self.insert(ty.id, NodeTy(ty)); self.with_parent(ty.id, |this| { @@ -174,7 +174,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_trait_ref(&mut self, tr: &'ast TraitRef) { + fn visit_trait_ref(&mut self, tr: &'hir TraitRef) { self.insert(tr.ref_id, NodeTraitRef(tr)); self.with_parent(tr.ref_id, |this| { @@ -182,24 +182,24 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_fn(&mut self, fk: intravisit::FnKind<'ast>, fd: &'ast FnDecl, + fn visit_fn(&mut self, fk: intravisit::FnKind<'hir>, fd: &'hir FnDecl, b: BodyId, s: Span, id: NodeId) { assert_eq!(self.parent_node, id); intravisit::walk_fn(self, fk, fd, b, s, id); } - fn visit_block(&mut self, block: &'ast Block) { + fn visit_block(&mut self, block: &'hir Block) { self.insert(block.id, NodeBlock(block)); self.with_parent(block.id, |this| { intravisit::walk_block(this, block); }); } - fn visit_lifetime(&mut self, lifetime: &'ast Lifetime) { + fn visit_lifetime(&mut self, lifetime: &'hir Lifetime) { self.insert(lifetime.id, NodeLifetime(lifetime)); } - fn visit_vis(&mut self, visibility: &'ast Visibility) { + fn visit_vis(&mut self, visibility: &'hir Visibility) { match *visibility { Visibility::Public | Visibility::Crate | @@ -213,11 +213,11 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { } } - fn visit_macro_def(&mut self, macro_def: &'ast MacroDef) { + fn visit_macro_def(&mut self, macro_def: &'hir MacroDef) { self.insert_entry(macro_def.id, NotPresent); } - fn visit_variant(&mut self, v: &'ast Variant, g: &'ast Generics, item_id: NodeId) { + fn visit_variant(&mut self, v: &'hir Variant, g: &'hir Generics, item_id: NodeId) { let id = v.node.data.id(); self.insert(id, NodeVariant(v)); self.with_parent(id, |this| { @@ -225,7 +225,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { }); } - fn visit_struct_field(&mut self, field: &'ast StructField) { + fn visit_struct_field(&mut self, field: &'hir StructField) { self.insert(field.id, NodeField(field)); self.with_parent(field.id, |this| { intravisit::walk_struct_field(this, field); diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 7c0621279fd6f..9f31b5b456b9f 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -38,67 +38,67 @@ mod def_collector; pub mod definitions; #[derive(Copy, Clone, Debug)] -pub enum Node<'ast> { - NodeItem(&'ast Item), - NodeForeignItem(&'ast ForeignItem), - NodeTraitItem(&'ast TraitItem), - NodeImplItem(&'ast ImplItem), - NodeVariant(&'ast Variant), - NodeField(&'ast StructField), - NodeExpr(&'ast Expr), - NodeStmt(&'ast Stmt), - NodeTy(&'ast Ty), - NodeTraitRef(&'ast TraitRef), - NodeLocal(&'ast Pat), - NodePat(&'ast Pat), - NodeBlock(&'ast Block), +pub enum Node<'hir> { + NodeItem(&'hir Item), + NodeForeignItem(&'hir ForeignItem), + NodeTraitItem(&'hir TraitItem), + NodeImplItem(&'hir ImplItem), + NodeVariant(&'hir Variant), + NodeField(&'hir StructField), + NodeExpr(&'hir Expr), + NodeStmt(&'hir Stmt), + NodeTy(&'hir Ty), + NodeTraitRef(&'hir TraitRef), + NodeLocal(&'hir Pat), + NodePat(&'hir Pat), + NodeBlock(&'hir Block), /// NodeStructCtor represents a tuple struct. - NodeStructCtor(&'ast VariantData), + NodeStructCtor(&'hir VariantData), - NodeLifetime(&'ast Lifetime), - NodeTyParam(&'ast TyParam), - NodeVisibility(&'ast Visibility), + NodeLifetime(&'hir Lifetime), + NodeTyParam(&'hir TyParam), + NodeVisibility(&'hir Visibility), } /// Represents an entry and its parent NodeID. /// The odd layout is to bring down the total size. #[derive(Copy, Debug)] -enum MapEntry<'ast> { +enum MapEntry<'hir> { /// Placeholder for holes in the map. NotPresent, /// All the node types, with a parent ID. - EntryItem(NodeId, &'ast Item), - EntryForeignItem(NodeId, &'ast ForeignItem), - EntryTraitItem(NodeId, &'ast TraitItem), - EntryImplItem(NodeId, &'ast ImplItem), - EntryVariant(NodeId, &'ast Variant), - EntryField(NodeId, &'ast StructField), - EntryExpr(NodeId, &'ast Expr), - EntryStmt(NodeId, &'ast Stmt), - EntryTy(NodeId, &'ast Ty), - EntryTraitRef(NodeId, &'ast TraitRef), - EntryLocal(NodeId, &'ast Pat), - EntryPat(NodeId, &'ast Pat), - EntryBlock(NodeId, &'ast Block), - EntryStructCtor(NodeId, &'ast VariantData), - EntryLifetime(NodeId, &'ast Lifetime), - EntryTyParam(NodeId, &'ast TyParam), - EntryVisibility(NodeId, &'ast Visibility), + EntryItem(NodeId, &'hir Item), + EntryForeignItem(NodeId, &'hir ForeignItem), + EntryTraitItem(NodeId, &'hir TraitItem), + EntryImplItem(NodeId, &'hir ImplItem), + EntryVariant(NodeId, &'hir Variant), + EntryField(NodeId, &'hir StructField), + EntryExpr(NodeId, &'hir Expr), + EntryStmt(NodeId, &'hir Stmt), + EntryTy(NodeId, &'hir Ty), + EntryTraitRef(NodeId, &'hir TraitRef), + EntryLocal(NodeId, &'hir Pat), + EntryPat(NodeId, &'hir Pat), + EntryBlock(NodeId, &'hir Block), + EntryStructCtor(NodeId, &'hir VariantData), + EntryLifetime(NodeId, &'hir Lifetime), + EntryTyParam(NodeId, &'hir TyParam), + EntryVisibility(NodeId, &'hir Visibility), /// Roots for node trees. RootCrate, } -impl<'ast> Clone for MapEntry<'ast> { - fn clone(&self) -> MapEntry<'ast> { +impl<'hir> Clone for MapEntry<'hir> { + fn clone(&self) -> MapEntry<'hir> { *self } } -impl<'ast> MapEntry<'ast> { - fn from_node(p: NodeId, node: Node<'ast>) -> MapEntry<'ast> { +impl<'hir> MapEntry<'hir> { + fn from_node(p: NodeId, node: Node<'hir>) -> MapEntry<'hir> { match node { NodeItem(n) => EntryItem(p, n), NodeForeignItem(n) => EntryForeignItem(p, n), @@ -145,7 +145,7 @@ impl<'ast> MapEntry<'ast> { }) } - fn to_node(self) -> Option> { + fn to_node(self) -> Option> { Some(match self { EntryItem(_, n) => NodeItem(n), EntryForeignItem(_, n) => NodeForeignItem(n), @@ -225,7 +225,7 @@ impl Forest { } } - pub fn krate<'ast>(&'ast self) -> &'ast Crate { + pub fn krate<'hir>(&'hir self) -> &'hir Crate { self.dep_graph.read(DepNode::Krate); &self.krate } @@ -234,9 +234,9 @@ impl Forest { /// Represents a mapping from Node IDs to AST elements and their parent /// Node IDs #[derive(Clone)] -pub struct Map<'ast> { +pub struct Map<'hir> { /// The backing storage for all the AST nodes. - pub forest: &'ast Forest, + pub forest: &'hir Forest, /// Same as the dep_graph in forest, just available with one fewer /// deref. This is a gratuitious micro-optimization. @@ -251,15 +251,15 @@ pub struct Map<'ast> { /// /// Also, indexing is pretty quick when you've got a vector and /// plain old integers. - map: Vec>, + map: Vec>, definitions: Definitions, /// Bodies inlined from other crates are cached here. - inlined_bodies: RefCell>, + inlined_bodies: RefCell>, } -impl<'ast> Map<'ast> { +impl<'hir> Map<'hir> { /// Registers a read in the dependency graph of the AST node with /// the given `id`. This needs to be called each time a public /// function returns the HIR for a node -- in other words, when it @@ -388,15 +388,15 @@ impl<'ast> Map<'ast> { self.map.len() } - fn find_entry(&self, id: NodeId) -> Option> { + fn find_entry(&self, id: NodeId) -> Option> { self.map.get(id.as_usize()).cloned() } - pub fn krate(&self) -> &'ast Crate { + pub fn krate(&self) -> &'hir Crate { self.forest.krate() } - pub fn trait_item(&self, id: TraitItemId) -> &'ast TraitItem { + pub fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem { self.read(id.node_id); // NB: intentionally bypass `self.forest.krate()` so that we @@ -404,7 +404,7 @@ impl<'ast> Map<'ast> { self.forest.krate.trait_item(id) } - pub fn impl_item(&self, id: ImplItemId) -> &'ast ImplItem { + pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem { self.read(id.node_id); // NB: intentionally bypass `self.forest.krate()` so that we @@ -412,7 +412,7 @@ impl<'ast> Map<'ast> { self.forest.krate.impl_item(id) } - pub fn body(&self, id: BodyId) -> &'ast Body { + pub fn body(&self, id: BodyId) -> &'hir Body { self.read(id.node_id); // NB: intentionally bypass `self.forest.krate()` so that we @@ -440,7 +440,7 @@ impl<'ast> Map<'ast> { /// Get the attributes on the krate. This is preferable to /// invoking `krate.attrs` because it registers a tighter /// dep-graph access. - pub fn krate_attrs(&self) -> &'ast [ast::Attribute] { + pub fn krate_attrs(&self) -> &'hir [ast::Attribute] { let crate_root_def_id = DefId::local(CRATE_DEF_INDEX); self.dep_graph.read(DepNode::Hir(crate_root_def_id)); &self.forest.krate.attrs @@ -448,20 +448,20 @@ impl<'ast> Map<'ast> { /// Retrieve the Node corresponding to `id`, panicking if it cannot /// be found. - pub fn get(&self, id: NodeId) -> Node<'ast> { + pub fn get(&self, id: NodeId) -> Node<'hir> { match self.find(id) { Some(node) => node, // read recorded by `find` None => bug!("couldn't find node id {} in the AST map", id) } } - pub fn get_if_local(&self, id: DefId) -> Option> { + pub fn get_if_local(&self, id: DefId) -> Option> { self.as_local_node_id(id).map(|id| self.get(id)) // read recorded by `get` } /// Retrieve the Node corresponding to `id`, returning None if /// cannot be found. - pub fn find(&self, id: NodeId) -> Option> { + pub fn find(&self, id: NodeId) -> Option> { let result = self.find_entry(id).and_then(|x| x.to_node()); if result.is_some() { self.read(id); @@ -508,7 +508,7 @@ impl<'ast> Map<'ast> { /// is not an error, since items in the crate module have the crate root as /// parent. fn walk_parent_nodes(&self, start_id: NodeId, found: F) -> Result - where F: Fn(&Node<'ast>) -> bool + where F: Fn(&Node<'hir>) -> bool { let mut id = start_id; loop { @@ -611,28 +611,28 @@ impl<'ast> Map<'ast> { } } - pub fn expect_item(&self, id: NodeId) -> &'ast Item { + pub fn expect_item(&self, id: NodeId) -> &'hir Item { match self.find(id) { // read recorded by `find` Some(NodeItem(item)) => item, _ => bug!("expected item, found {}", self.node_to_string(id)) } } - pub fn expect_impl_item(&self, id: NodeId) -> &'ast ImplItem { + pub fn expect_impl_item(&self, id: NodeId) -> &'hir ImplItem { match self.find(id) { Some(NodeImplItem(item)) => item, _ => bug!("expected impl item, found {}", self.node_to_string(id)) } } - pub fn expect_trait_item(&self, id: NodeId) -> &'ast TraitItem { + pub fn expect_trait_item(&self, id: NodeId) -> &'hir TraitItem { match self.find(id) { Some(NodeTraitItem(item)) => item, _ => bug!("expected trait item, found {}", self.node_to_string(id)) } } - pub fn expect_variant_data(&self, id: NodeId) -> &'ast VariantData { + pub fn expect_variant_data(&self, id: NodeId) -> &'hir VariantData { match self.find(id) { Some(NodeItem(i)) => { match i.node { @@ -653,35 +653,35 @@ impl<'ast> Map<'ast> { } } - pub fn expect_variant(&self, id: NodeId) -> &'ast Variant { + pub fn expect_variant(&self, id: NodeId) -> &'hir Variant { match self.find(id) { Some(NodeVariant(variant)) => variant, _ => bug!("expected variant, found {}", self.node_to_string(id)), } } - pub fn expect_foreign_item(&self, id: NodeId) -> &'ast ForeignItem { + pub fn expect_foreign_item(&self, id: NodeId) -> &'hir ForeignItem { match self.find(id) { Some(NodeForeignItem(item)) => item, _ => bug!("expected foreign item, found {}", self.node_to_string(id)) } } - pub fn expect_expr(&self, id: NodeId) -> &'ast Expr { + pub fn expect_expr(&self, id: NodeId) -> &'hir Expr { match self.find(id) { // read recorded by find Some(NodeExpr(expr)) => expr, _ => bug!("expected expr, found {}", self.node_to_string(id)) } } - pub fn get_inlined_body(&self, def_id: DefId) -> Option<&'ast Body> { + pub fn get_inlined_body(&self, def_id: DefId) -> Option<&'hir Body> { self.inlined_bodies.borrow().get(&def_id).map(|&body| { self.dep_graph.read(DepNode::MetaData(def_id)); body }) } - pub fn intern_inlined_body(&self, def_id: DefId, body: Body) -> &'ast Body { + pub fn intern_inlined_body(&self, def_id: DefId, body: Body) -> &'hir Body { let body = self.forest.inlined_bodies.alloc(body); self.inlined_bodies.borrow_mut().insert(def_id, body); body @@ -706,7 +706,7 @@ impl<'ast> Map<'ast> { /// Given a node ID, get a list of attributes associated with the AST /// corresponding to the Node ID - pub fn attrs(&self, id: NodeId) -> &'ast [ast::Attribute] { + pub fn attrs(&self, id: NodeId) -> &'hir [ast::Attribute] { self.read(id); // reveals attributes on the node let attrs = match self.find(id) { Some(NodeItem(i)) => Some(&i.attrs[..]), @@ -735,7 +735,7 @@ impl<'ast> Map<'ast> { /// such as `foo::bar::quux`, `bar::quux`, `other::bar::quux`, and /// any other such items it can find in the map. pub fn nodes_matching_suffix<'a>(&'a self, parts: &'a [String]) - -> NodesMatchingSuffix<'a, 'ast> { + -> NodesMatchingSuffix<'a, 'hir> { NodesMatchingSuffix { map: self, item_name: parts.last().unwrap(), @@ -790,14 +790,14 @@ impl<'ast> Map<'ast> { } } -pub struct NodesMatchingSuffix<'a, 'ast:'a> { - map: &'a Map<'ast>, +pub struct NodesMatchingSuffix<'a, 'hir:'a> { + map: &'a Map<'hir>, item_name: &'a String, in_which: &'a [String], idx: NodeId, } -impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> { +impl<'a, 'hir> NodesMatchingSuffix<'a, 'hir> { /// Returns true only if some suffix of the module path for parent /// matches `self.in_which`. /// @@ -853,7 +853,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> { } } -impl<'a, 'ast> Iterator for NodesMatchingSuffix<'a, 'ast> { +impl<'a, 'hir> Iterator for NodesMatchingSuffix<'a, 'hir> { type Item = NodeId; fn next(&mut self) -> Option { @@ -892,9 +892,9 @@ impl Named for StructField { fn name(&self) -> Name { self.name } } impl Named for TraitItem { fn name(&self) -> Name { self.name } } impl Named for ImplItem { fn name(&self) -> Name { self.name } } -pub fn map_crate<'ast>(forest: &'ast mut Forest, +pub fn map_crate<'hir>(forest: &'hir mut Forest, definitions: Definitions) - -> Map<'ast> { + -> Map<'hir> { let mut collector = NodeCollector::root(&forest.krate); intravisit::walk_crate(&mut collector, &forest.krate); let map = collector.map; @@ -926,7 +926,7 @@ pub fn map_crate<'ast>(forest: &'ast mut Forest, /// Identical to the `PpAnn` implementation for `hir::Crate`, /// except it avoids creating a dependency on the whole crate. -impl<'ast> print::PpAnn for Map<'ast> { +impl<'hir> print::PpAnn for Map<'hir> { fn nested(&self, state: &mut print::State, nested: print::Nested) -> io::Result<()> { match nested { Nested::Item(id) => state.print_item(self.expect_item(id.id)), @@ -966,7 +966,7 @@ impl<'a> print::State<'a> { NodeTyParam(_) => bug!("cannot print TyParam"), NodeField(_) => bug!("cannot print StructField"), // these cases do not carry enough information in the - // ast_map to reconstruct their full structure for pretty + // hir_map to reconstruct their full structure for pretty // printing. NodeStructCtor(_) => bug!("cannot print isolated StructCtor"), } diff --git a/src/librustc/infer/error_reporting.rs b/src/librustc/infer/error_reporting.rs index 0b43f32e3dc29..73b5fda275819 100644 --- a/src/librustc/infer/error_reporting.rs +++ b/src/librustc/infer/error_reporting.rs @@ -73,7 +73,7 @@ use super::region_inference::SameRegions; use std::collections::HashSet; -use hir::map as ast_map; +use hir::map as hir_map; use hir; use lint; @@ -152,8 +152,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } }; let tag = match self.hir.find(scope.node_id(&self.region_maps)) { - Some(ast_map::NodeBlock(_)) => "block", - Some(ast_map::NodeExpr(expr)) => match expr.node { + 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 @@ impl<'a, 'gcx, '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; @@ -207,11 +207,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let node = fr.scope.node_id(&self.region_maps); let unknown; let tag = match self.hir.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), + 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) @@ -471,14 +471,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { 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 @@ -1074,7 +1074,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { 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)) @@ -1082,9 +1082,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { _ => None, } } - ast_map::NodeImplItem(item) => { + hir_map::NodeImplItem(item) => { let id = self.tcx.hir.get_parent(item.id); - if let Some(ast_map::NodeItem(parent_scope)) = self.tcx.hir.find(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) @@ -1103,7 +1103,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { None } }, - ast_map::NodeTraitItem(item) => { + hir_map::NodeTraitItem(item) => { match item.node { hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { Some((&sig.decl, @@ -1894,14 +1894,14 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, 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,7 +1918,7 @@ fn lifetimes_in_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, 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); } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index fe1dadca05134..ae349667f9dc6 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -13,7 +13,7 @@ // from live codes are live, and everything else is dead. use dep_graph::DepNode; -use hir::map as ast_map; +use hir::map as hir_map; use hir::{self, PatKind}; use hir::intravisit::{self, Visitor, NestedVisitorMap}; use hir::itemlikevisit::ItemLikeVisitor; @@ -36,10 +36,10 @@ use syntax_pos; fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) -> bool { match tcx.hir.find(node_id) { - Some(ast_map::NodeItem(..)) | - Some(ast_map::NodeImplItem(..)) | - Some(ast_map::NodeForeignItem(..)) | - Some(ast_map::NodeTraitItem(..)) => + Some(hir_map::NodeItem(..)) | + Some(hir_map::NodeImplItem(..)) | + Some(hir_map::NodeForeignItem(..)) | + Some(hir_map::NodeTraitItem(..)) => true, _ => false @@ -150,13 +150,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { } } - fn visit_node(&mut self, node: &ast_map::Node<'tcx>) { + fn visit_node(&mut self, node: &hir_map::Node<'tcx>) { let had_extern_repr = self.struct_has_extern_repr; self.struct_has_extern_repr = false; let had_inherited_pub_visibility = self.inherited_pub_visibility; self.inherited_pub_visibility = false; match *node { - ast_map::NodeItem(item) => { + hir_map::NodeItem(item) => { match item.node { hir::ItemStruct(..) | hir::ItemUnion(..) => { self.struct_has_extern_repr = item.attrs.iter().any(|attr| { @@ -179,13 +179,13 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { _ => () } } - ast_map::NodeTraitItem(trait_item) => { + hir_map::NodeTraitItem(trait_item) => { intravisit::walk_trait_item(self, trait_item); } - ast_map::NodeImplItem(impl_item) => { + hir_map::NodeImplItem(impl_item) => { intravisit::walk_impl_item(self, impl_item); } - ast_map::NodeForeignItem(foreign_item) => { + hir_map::NodeForeignItem(foreign_item) => { intravisit::walk_foreign_item(self, &foreign_item); } _ => () diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index f2e46d4cbc96b..ff7adfb327ad4 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -10,7 +10,7 @@ use dep_graph::DepNode; -use hir::map as ast_map; +use hir::map as hir_map; use hir::def_id::{CRATE_DEF_INDEX}; use session::{config, Session}; use syntax::ast::NodeId; @@ -23,7 +23,7 @@ use hir::itemlikevisit::ItemLikeVisitor; struct EntryContext<'a, 'tcx: 'a> { session: &'a Session, - map: &'a ast_map::Map<'tcx>, + map: &'a hir_map::Map<'tcx>, // The top-level function called 'main' main_fn: Option<(NodeId, Span)>, @@ -56,8 +56,8 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> { } } -pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) { - let _task = ast_map.dep_graph.in_task(DepNode::EntryPoint); +pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) { + let _task = hir_map.dep_graph.in_task(DepNode::EntryPoint); let any_exe = session.crate_types.borrow().iter().any(|ty| { *ty == config::CrateTypeExecutable @@ -68,21 +68,21 @@ pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) { } // If the user wants no main function at all, then stop here. - if attr::contains_name(&ast_map.krate().attrs, "no_main") { + if attr::contains_name(&hir_map.krate().attrs, "no_main") { session.entry_type.set(Some(config::EntryNone)); return } let mut ctxt = EntryContext { session: session, - map: ast_map, + map: hir_map, main_fn: None, attr_main_fn: None, start_fn: None, non_main_fns: Vec::new(), }; - ast_map.krate().visit_all_item_likes(&mut ctxt); + hir_map.krate().visit_all_item_likes(&mut ctxt); configure_main(&mut ctxt); } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index cd7859af8ee7b..b9f1611f62baf 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -117,7 +117,7 @@ impl LanguageItems { struct LanguageItemCollector<'a, 'tcx: 'a> { items: LanguageItems, - ast_map: &'a hir_map::Map<'tcx>, + hir_map: &'a hir_map::Map<'tcx>, session: &'a Session, @@ -130,9 +130,9 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> { let item_index = self.item_refs.get(&*value.as_str()).cloned(); if let Some(item_index) = item_index { - self.collect_item(item_index, self.ast_map.local_def_id(item.id)) + self.collect_item(item_index, self.hir_map.local_def_id(item.id)) } else { - let span = self.ast_map.span(item.id); + let span = self.hir_map.span(item.id); span_err!(self.session, span, E0522, "definition of an unknown language item: `{}`.", value); @@ -150,7 +150,7 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> { } impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { - pub fn new(session: &'a Session, ast_map: &'a hir_map::Map<'tcx>) + pub fn new(session: &'a Session, hir_map: &'a hir_map::Map<'tcx>) -> LanguageItemCollector<'a, 'tcx> { let mut item_refs = FxHashMap(); @@ -158,7 +158,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { LanguageItemCollector { session: session, - ast_map: ast_map, + hir_map: hir_map, items: LanguageItems::new(), item_refs: item_refs, } @@ -171,7 +171,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { Some(original_def_id) if original_def_id != item_def_id => { let cstore = &self.session.cstore; let name = LanguageItems::item_name(item_index); - let mut err = match self.ast_map.span_if_local(item_def_id) { + let mut err = match self.hir_map.span_if_local(item_def_id) { Some(span) => struct_span_err!( self.session, span, @@ -183,7 +183,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { cstore.crate_name(item_def_id.krate), name)), }; - if let Some(span) = self.ast_map.span_if_local(original_def_id) { + if let Some(span) = self.hir_map.span_if_local(original_def_id) { span_note!(&mut err, span, "first defined here."); } else { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index d4438f5ecfa1a..126d43aa6900e 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -71,7 +71,7 @@ pub use self::Note::*; use self::Aliasability::*; use hir::def_id::DefId; -use hir::map as ast_map; +use hir::map as hir_map; use infer::InferCtxt; use hir::def::{Def, CtorKind}; use ty::adjustment; @@ -269,7 +269,7 @@ impl MutabilityCategory { fn from_local(tcx: TyCtxt, id: ast::NodeId) -> MutabilityCategory { let ret = match tcx.hir.get(id) { - ast_map::NodeLocal(p) => match p.node { + hir_map::NodeLocal(p) => match p.node { PatKind::Binding(bind_mode, ..) => { if bind_mode == hir::BindByValue(hir::MutMutable) { McDeclared @@ -699,7 +699,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // a free region within it let fn_body_id = { let fn_expr = match self.tcx().hir.find(upvar_id.closure_expr_id) { - Some(ast_map::NodeExpr(e)) => e, + Some(hir_map::NodeExpr(e)) => e, _ => bug!() }; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 9b00fc3f220ec..4ec43e368a60d 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -16,7 +16,7 @@ // reachable as well. use dep_graph::DepNode; -use hir::map as ast_map; +use hir::map as hir_map; use hir::def::Def; use hir::def_id::DefId; use ty::{self, TyCtxt}; @@ -65,7 +65,7 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) { match tcx.hir.find(impl_node_id) { - Some(ast_map::NodeItem(item)) => + Some(hir_map::NodeItem(item)) => item_might_be_inlined(&item), Some(..) | None => span_bug!(impl_item.span, "impl did is not an item") @@ -153,13 +153,13 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { }; match self.tcx.hir.find(node_id) { - Some(ast_map::NodeItem(item)) => { + Some(hir_map::NodeItem(item)) => { match item.node { hir::ItemFn(..) => item_might_be_inlined(&item), _ => false, } } - Some(ast_map::NodeTraitItem(trait_method)) => { + Some(hir_map::NodeTraitItem(trait_method)) => { match trait_method.node { hir::TraitItemKind::Const(_, ref default) => default.is_some(), hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true, @@ -167,7 +167,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { hir::TraitItemKind::Type(..) => false, } } - Some(ast_map::NodeImplItem(impl_item)) => { + Some(hir_map::NodeImplItem(impl_item)) => { match impl_item.node { hir::ImplItemKind::Const(..) => true, hir::ImplItemKind::Method(ref sig, _) => { @@ -216,12 +216,12 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } } - fn propagate_node(&mut self, node: &ast_map::Node<'tcx>, + fn propagate_node(&mut self, node: &hir_map::Node<'tcx>, search_item: ast::NodeId) { if !self.any_library { // If we are building an executable, only explicitly extern // types need to be exported. - if let ast_map::NodeItem(item) = *node { + if let hir_map::NodeItem(item) = *node { let reachable = if let hir::ItemFn(.., abi, _, _) = item.node { abi != Abi::Rust } else { @@ -242,7 +242,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } match *node { - ast_map::NodeItem(item) => { + hir_map::NodeItem(item) => { match item.node { hir::ItemFn(.., body) => { if item_might_be_inlined(&item) { @@ -268,7 +268,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { hir::ItemUnion(..) | hir::ItemDefaultImpl(..) => {} } } - ast_map::NodeTraitItem(trait_method) => { + hir_map::NodeTraitItem(trait_method) => { match trait_method.node { hir::TraitItemKind::Const(_, None) | hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => { @@ -281,7 +281,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { hir::TraitItemKind::Type(..) => {} } } - ast_map::NodeImplItem(impl_item) => { + hir_map::NodeImplItem(impl_item) => { match impl_item.node { hir::ImplItemKind::Const(_, body) => { self.visit_nested_body(body); @@ -296,11 +296,11 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } } // Nothing to recurse on for these - ast_map::NodeForeignItem(_) | - ast_map::NodeVariant(_) | - ast_map::NodeStructCtor(_) | - ast_map::NodeField(_) | - ast_map::NodeTy(_) => {} + hir_map::NodeForeignItem(_) | + hir_map::NodeVariant(_) | + hir_map::NodeStructCtor(_) | + hir_map::NodeField(_) | + hir_map::NodeTy(_) => {} _ => { bug!("found unexpected thingy in worklist: {}", self.tcx.hir.node_to_string(search_item)) diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index faf4a448b7a84..7337c03795b6d 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -17,7 +17,7 @@ //! `middle/infer/region_inference/README.md` use dep_graph::DepNode; -use hir::map as ast_map; +use hir::map as hir_map; use session::Session; use util::nodemap::{FxHashMap, NodeMap, NodeSet}; use ty; @@ -217,9 +217,9 @@ impl CodeExtent { /// Returns the span of this CodeExtent. Note that in general the /// returned span may not correspond to the span of any node id in /// the AST. - pub fn span(&self, region_maps: &RegionMaps, ast_map: &ast_map::Map) -> Option { - match ast_map.find(self.node_id(region_maps)) { - Some(ast_map::NodeBlock(ref blk)) => { + pub fn span(&self, region_maps: &RegionMaps, hir_map: &hir_map::Map) -> Option { + match hir_map.find(self.node_id(region_maps)) { + Some(hir_map::NodeBlock(ref blk)) => { match region_maps.code_extent_data(*self) { CodeExtentData::CallSiteScope { .. } | CodeExtentData::ParameterScope { .. } | @@ -240,9 +240,9 @@ impl CodeExtent { } } } - Some(ast_map::NodeExpr(ref expr)) => Some(expr.span), - Some(ast_map::NodeStmt(ref stmt)) => Some(stmt.span), - Some(ast_map::NodeItem(ref item)) => Some(item.span), + Some(hir_map::NodeExpr(ref expr)) => Some(expr.span), + Some(hir_map::NodeStmt(ref stmt)) => Some(stmt.span), + Some(hir_map::NodeItem(ref item)) => Some(item.span), Some(_) | None => None, } } @@ -302,7 +302,7 @@ pub struct Context { parent: CodeExtent } -struct RegionResolutionVisitor<'ast: 'a, 'a> { +struct RegionResolutionVisitor<'hir: 'a, 'a> { sess: &'a Session, // Generated maps: @@ -310,7 +310,7 @@ struct RegionResolutionVisitor<'ast: 'a, 'a> { cx: Context, - map: &'a ast_map::Map<'ast>, + map: &'a hir_map::Map<'hir>, /// `terminating_scopes` is a set containing the ids of each /// statement, or conditional/repeating expression. These scopes @@ -1137,7 +1137,7 @@ fn resolve_fn<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'tcx, 'a>, visitor.terminating_scopes = outer_ts; } -impl<'ast, 'a> RegionResolutionVisitor<'ast, 'a> { +impl<'hir, 'a> RegionResolutionVisitor<'hir, 'a> { /// Records the current parent (if any) as the parent of `child_scope`. fn new_code_extent(&mut self, child_scope: CodeExtentData) -> CodeExtent { self.region_maps.intern_code_extent(child_scope, self.cx.parent) @@ -1173,49 +1173,49 @@ impl<'ast, 'a> RegionResolutionVisitor<'ast, 'a> { } } -impl<'ast, 'a> Visitor<'ast> for RegionResolutionVisitor<'ast, 'a> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> { +impl<'hir, 'a> Visitor<'hir> for RegionResolutionVisitor<'hir, 'a> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { NestedVisitorMap::OnlyBodies(&self.map) } - fn visit_block(&mut self, b: &'ast Block) { + fn visit_block(&mut self, b: &'hir Block) { resolve_block(self, b); } - fn visit_item(&mut self, i: &'ast Item) { + fn visit_item(&mut self, i: &'hir Item) { resolve_item_like(self, i.id, |this| intravisit::walk_item(this, i)); } - fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) { + fn visit_impl_item(&mut self, ii: &'hir hir::ImplItem) { resolve_item_like(self, ii.id, |this| intravisit::walk_impl_item(this, ii)); } - fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) { + fn visit_trait_item(&mut self, ti: &'hir hir::TraitItem) { resolve_item_like(self, ti.id, |this| intravisit::walk_trait_item(this, ti)); } - fn visit_fn(&mut self, fk: FnKind<'ast>, fd: &'ast FnDecl, + fn visit_fn(&mut self, fk: FnKind<'hir>, fd: &'hir FnDecl, b: hir::BodyId, s: Span, n: NodeId) { resolve_fn(self, fk, fd, b, s, n); } - fn visit_arm(&mut self, a: &'ast Arm) { + fn visit_arm(&mut self, a: &'hir Arm) { resolve_arm(self, a); } - fn visit_pat(&mut self, p: &'ast Pat) { + fn visit_pat(&mut self, p: &'hir Pat) { resolve_pat(self, p); } - fn visit_stmt(&mut self, s: &'ast Stmt) { + fn visit_stmt(&mut self, s: &'hir Stmt) { resolve_stmt(self, s); } - fn visit_expr(&mut self, ex: &'ast Expr) { + fn visit_expr(&mut self, ex: &'hir Expr) { resolve_expr(self, ex); } - fn visit_local(&mut self, l: &'ast Local) { + fn visit_local(&mut self, l: &'hir Local) { resolve_local(self, l); } } -pub fn resolve_crate(sess: &Session, map: &ast_map::Map) -> RegionMaps { +pub fn resolve_crate(sess: &Session, map: &hir_map::Map) -> RegionMaps { let _task = map.dep_graph.in_task(DepNode::RegionResolveCrate); let krate = map.krate(); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 7f26fdfba5693..c78ba3b8a9bbf 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -16,7 +16,7 @@ use middle; use hir::TraitMap; use hir::def::Def; use hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; -use hir::map as ast_map; +use hir::map as hir_map; use hir::map::DisambiguatedDefPathData; use middle::free_region::FreeRegionMap; use middle::region::RegionMaps; @@ -428,7 +428,7 @@ pub struct GlobalCtxt<'tcx> { /// additional acyclicity requirements). pub super_predicates: RefCell>>, - pub hir: ast_map::Map<'tcx>, + pub hir: hir_map::Map<'tcx>, /// Maps from the def-id of a function/method or const/static /// to its MIR. Mutation is done at an item granularity to @@ -730,7 +730,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { arena: &'tcx DroplessArena, resolutions: ty::Resolutions, named_region_map: resolve_lifetime::NamedRegionMap, - hir: ast_map::Map<'tcx>, + hir: hir_map::Map<'tcx>, region_maps: RegionMaps, lang_items: middle::lang_items::LanguageItems, stability: stability::Index<'tcx>, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 7a8788f053dd0..5681e8c776623 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -17,7 +17,7 @@ pub use self::LvaluePreference::*; pub use self::fold::TypeFoldable; use dep_graph::{self, DepNode}; -use hir::{map as ast_map, FreevarMap, TraitMap}; +use hir::{map as hir_map, FreevarMap, TraitMap}; use middle; use hir::def::{Def, CtorKind, ExportMap}; use hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; @@ -1199,7 +1199,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { pub fn for_item(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: NodeId) -> ParameterEnvironment<'tcx> { match tcx.hir.find(id) { - Some(ast_map::NodeImplItem(ref impl_item)) => { + Some(hir_map::NodeImplItem(ref impl_item)) => { match impl_item.node { hir::ImplItemKind::Type(_) | hir::ImplItemKind::Const(..) => { // associated types don't have their own entry (for some reason), @@ -1218,7 +1218,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { } } } - Some(ast_map::NodeTraitItem(trait_item)) => { + Some(hir_map::NodeTraitItem(trait_item)) => { match trait_item.node { hir::TraitItemKind::Type(..) | hir::TraitItemKind::Const(..) => { // associated types don't have their own entry (for some reason), @@ -1247,7 +1247,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { } } } - Some(ast_map::NodeItem(item)) => { + Some(hir_map::NodeItem(item)) => { match item.node { hir::ItemFn(.., body_id) => { // We assume this is a function. @@ -1284,7 +1284,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { } } } - Some(ast_map::NodeExpr(expr)) => { + Some(hir_map::NodeExpr(expr)) => { // This is a convenience to allow closures to work. if let hir::ExprClosure(.., body, _) = expr.node { let def_id = tcx.hir.local_def_id(id); @@ -1297,7 +1297,7 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> { tcx.empty_parameter_environment() } } - Some(ast_map::NodeForeignItem(item)) => { + Some(hir_map::NodeForeignItem(item)) => { let def_id = tcx.hir.local_def_id(id); tcx.construct_parameter_environment(item.span, def_id, @@ -1945,7 +1945,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn expr_span(self, id: NodeId) -> Span { match self.hir.find(id) { - Some(ast_map::NodeExpr(e)) => { + Some(hir_map::NodeExpr(e)) => { e.span } Some(f) => { @@ -1959,7 +1959,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn local_var_name_str(self, id: NodeId) -> InternedString { match self.hir.find(id) { - Some(ast_map::NodeLocal(pat)) => { + Some(hir_map::NodeLocal(pat)) => { match pat.node { hir::PatKind::Binding(_, _, ref path1, _) => path1.node.as_str(), _ => { @@ -2225,7 +2225,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - pub fn def_key(self, id: DefId) -> ast_map::DefKey { + pub fn def_key(self, id: DefId) -> hir_map::DefKey { if id.is_local() { self.hir.def_key(id) } else { @@ -2238,7 +2238,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// /// Note that if `id` is not local to this crate, the result will // be a non-local `DefPath`. - pub fn def_path(self, id: DefId) -> ast_map::DefPath { + pub fn def_path(self, id: DefId) -> hir_map::DefPath { if id.is_local() { self.hir.def_path(id) } else { @@ -2266,7 +2266,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } else { let def_key = self.sess.cstore.def_key(id); // The name of a StructCtor is that of its struct parent. - if let ast_map::DefPathData::StructCtor = def_key.disambiguated_data.data { + if let hir_map::DefPathData::StructCtor = def_key.disambiguated_data.data { self.item_name(DefId { krate: id.krate, index: def_key.parent.unwrap() diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 65bec9ecdaf95..c05375c47b03a 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -13,7 +13,7 @@ use hir::def_id::DefId; use hir::map::DefPathData; use infer::InferCtxt; -use hir::map as ast_map; +use hir::map as hir_map; use traits::{self, Reveal}; use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable}; use ty::{Disr, ParameterEnvironment}; @@ -429,7 +429,7 @@ impl<'a, 'gcx, 'tcx, W> TypeIdHasher<'a, 'gcx, 'tcx, W> self.def_path(&path) } - pub fn def_path(&mut self, def_path: &ast_map::DefPath) { + pub fn def_path(&mut self, def_path: &hir_map::DefPath) { def_path.deterministic_hash_to(self.tcx, &mut self.state); } } diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index a02aba7208c7f..2047a58f8ed85 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -490,7 +490,7 @@ impl<'a, 'tcx> MoveData<'tcx> { /// Adds a new record for a match of `base_lp`, downcast to /// variant `lp`, that occurs at location `pattern_id`. (One /// should be able to recover the span info from the - /// `pattern_id` and the ast_map, I think.) + /// `pattern_id` and the hir_map, I think.) pub fn add_variant_match(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, lp: Rc>, pattern_id: ast::NodeId, diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index e8055602087e5..a9dcb1ed89613 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -15,7 +15,7 @@ use rustc::middle::const_val::ConstVal; use self::ErrKind::*; use self::EvalHint::*; -use rustc::hir::map as ast_map; +use rustc::hir::map as hir_map; use rustc::hir::map::blocks::FnLikeNode; use rustc::traits; use rustc::hir::def::Def; @@ -55,7 +55,7 @@ fn lookup_variant_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> Option<(&'tcx Expr, Option<&'a ty::TypeckTables<'tcx>>)> { if let Some(variant_node_id) = tcx.hir.as_local_node_id(variant_def) { let enum_node_id = tcx.hir.get_parent(variant_node_id); - if let Some(ast_map::NodeItem(it)) = tcx.hir.find(enum_node_id) { + if let Some(hir_map::NodeItem(it)) = tcx.hir.find(enum_node_id) { if let hir::ItemEnum(ref edef, _) = it.node { for variant in &edef.variants { if variant.node.data.id() == variant_node_id { @@ -86,17 +86,17 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { match tcx.hir.find(node_id) { None => None, - Some(ast_map::NodeItem(&hir::Item { + Some(hir_map::NodeItem(&hir::Item { node: hir::ItemConst(ref ty, body), .. })) | - Some(ast_map::NodeImplItem(&hir::ImplItem { + Some(hir_map::NodeImplItem(&hir::ImplItem { node: hir::ImplItemKind::Const(ref ty, body), .. })) => { Some((&tcx.hir.body(body).value, tcx.tables.borrow().get(&def_id).cloned(), tcx.ast_ty_to_prim_ty(ty))) } - Some(ast_map::NodeTraitItem(ti)) => match ti.node { + Some(hir_map::NodeTraitItem(ti)) => match ti.node { hir::TraitItemKind::Const(ref ty, default) => { if let Some(substs) = substs { // If we have a trait item and the substitutions for it, diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 1991fbb58edf1..a7188f6da1ff9 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -340,7 +340,7 @@ pub struct CompileState<'a, 'tcx: 'a> { pub arenas: Option<&'tcx GlobalArenas<'tcx>>, pub expanded_crate: Option<&'a ast::Crate>, pub hir_crate: Option<&'a hir::Crate>, - pub ast_map: Option<&'a hir_map::Map<'tcx>>, + pub hir_map: Option<&'a hir_map::Map<'tcx>>, pub resolutions: Option<&'a Resolutions>, pub analysis: Option<&'a ty::CrateAnalysis<'tcx>>, pub tcx: Option>, @@ -366,7 +366,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> { output_filenames: None, expanded_crate: None, hir_crate: None, - ast_map: None, + hir_map: None, resolutions: None, analysis: None, tcx: None, @@ -427,7 +427,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> { arena: Some(arena), arenas: Some(arenas), cstore: Some(cstore), - ast_map: Some(hir_map), + hir_map: Some(hir_map), analysis: Some(analysis), resolutions: Some(resolutions), expanded_crate: Some(krate), diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index ad2aefbb79539..7fd4fa44ca45d 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -454,7 +454,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls { }; control.after_hir_lowering.callback = box move |state| { pretty::print_after_hir_lowering(state.session, - state.ast_map.unwrap(), + state.hir_map.unwrap(), state.analysis.unwrap(), state.resolutions.unwrap(), state.input, diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 1885f76f1e4cd..21fe13997b787 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -167,7 +167,7 @@ impl PpSourceMode { /// Constructs a `PrinterSupport` object and passes it to `f`. fn call_with_pp_support<'tcx, A, B, F>(&self, sess: &'tcx Session, - ast_map: Option<&hir_map::Map<'tcx>>, + hir_map: Option<&hir_map::Map<'tcx>>, payload: B, f: F) -> A @@ -177,7 +177,7 @@ impl PpSourceMode { PpmNormal | PpmEveryBodyLoops | PpmExpanded => { let annotation = NoAnn { sess: sess, - ast_map: ast_map.map(|m| m.clone()), + hir_map: hir_map.map(|m| m.clone()), }; f(&annotation, payload) } @@ -185,14 +185,13 @@ impl PpSourceMode { PpmIdentified | PpmExpandedIdentified => { let annotation = IdentifiedAnnotation { sess: sess, - ast_map: ast_map.map(|m| m.clone()), + hir_map: hir_map.map(|m| m.clone()), }; f(&annotation, payload) } PpmExpandedHygiene => { let annotation = HygieneAnnotation { sess: sess, - ast_map: ast_map.map(|m| m.clone()), }; f(&annotation, payload) } @@ -201,7 +200,7 @@ impl PpSourceMode { } fn call_with_pp_support_hir<'tcx, A, B, F>(&self, sess: &'tcx Session, - ast_map: &hir_map::Map<'tcx>, + hir_map: &hir_map::Map<'tcx>, analysis: &ty::CrateAnalysis<'tcx>, resolutions: &Resolutions, arena: &'tcx DroplessArena, @@ -216,21 +215,21 @@ impl PpSourceMode { PpmNormal => { let annotation = NoAnn { sess: sess, - ast_map: Some(ast_map.clone()), + hir_map: Some(hir_map.clone()), }; - f(&annotation, payload, ast_map.forest.krate()) + f(&annotation, payload, hir_map.forest.krate()) } PpmIdentified => { let annotation = IdentifiedAnnotation { sess: sess, - ast_map: Some(ast_map.clone()), + hir_map: Some(hir_map.clone()), }; - f(&annotation, payload, ast_map.forest.krate()) + f(&annotation, payload, hir_map.forest.krate()) } PpmTyped => { abort_on_err(driver::phase_3_run_analysis_passes(sess, - ast_map.clone(), + hir_map.clone(), analysis.clone(), resolutions.clone(), arena, @@ -243,7 +242,7 @@ impl PpSourceMode { tables: Cell::new(&empty_tables) }; let _ignore = tcx.dep_graph.in_ignore(); - f(&annotation, payload, ast_map.forest.krate()) + f(&annotation, payload, hir_map.forest.krate()) }), sess) } @@ -252,15 +251,11 @@ impl PpSourceMode { } } -trait PrinterSupport<'ast>: pprust::PpAnn { +trait PrinterSupport: pprust::PpAnn { /// Provides a uniform interface for re-extracting a reference to a /// `Session` from a value that now owns it. fn sess<'a>(&'a self) -> &'a Session; - /// Provides a uniform interface for re-extracting a reference to an - /// `hir_map::Map` from a value that now owns it. - fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>>; - /// Produces the pretty-print annotation object. /// /// (Rust does not yet support upcasting from a trait object to @@ -268,14 +263,14 @@ trait PrinterSupport<'ast>: pprust::PpAnn { fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn; } -trait HirPrinterSupport<'ast>: pprust_hir::PpAnn { +trait HirPrinterSupport<'hir>: pprust_hir::PpAnn { /// Provides a uniform interface for re-extracting a reference to a /// `Session` from a value that now owns it. fn sess<'a>(&'a self) -> &'a Session; /// Provides a uniform interface for re-extracting a reference to an /// `hir_map::Map` from a value that now owns it. - fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>>; + fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>>; /// Produces the pretty-print annotation object. /// @@ -285,7 +280,7 @@ trait HirPrinterSupport<'ast>: pprust_hir::PpAnn { /// Computes an user-readable representation of a path, if possible. fn node_path(&self, id: ast::NodeId) -> Option { - self.ast_map().and_then(|map| map.def_path_from_id(id)).map(|path| { + self.hir_map().and_then(|map| map.def_path_from_id(id)).map(|path| { path.data .into_iter() .map(|elem| elem.data.to_string()) @@ -295,32 +290,28 @@ trait HirPrinterSupport<'ast>: pprust_hir::PpAnn { } } -struct NoAnn<'ast> { - sess: &'ast Session, - ast_map: Option>, +struct NoAnn<'hir> { + sess: &'hir Session, + hir_map: Option>, } -impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> { +impl<'hir> PrinterSupport for NoAnn<'hir> { fn sess<'a>(&'a self) -> &'a Session { self.sess } - fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> { - self.ast_map.as_ref() - } - fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn { self } } -impl<'ast> HirPrinterSupport<'ast> for NoAnn<'ast> { +impl<'hir> HirPrinterSupport<'hir> for NoAnn<'hir> { fn sess<'a>(&'a self) -> &'a Session { self.sess } - fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> { - self.ast_map.as_ref() + fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> { + self.hir_map.as_ref() } fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn { @@ -328,11 +319,11 @@ impl<'ast> HirPrinterSupport<'ast> for NoAnn<'ast> { } } -impl<'ast> pprust::PpAnn for NoAnn<'ast> {} -impl<'ast> pprust_hir::PpAnn for NoAnn<'ast> { +impl<'hir> pprust::PpAnn for NoAnn<'hir> {} +impl<'hir> pprust_hir::PpAnn for NoAnn<'hir> { fn nested(&self, state: &mut pprust_hir::State, nested: pprust_hir::Nested) -> io::Result<()> { - if let Some(ref map) = self.ast_map { + if let Some(ref map) = self.hir_map { pprust_hir::PpAnn::nested(map, state, nested) } else { Ok(()) @@ -340,26 +331,22 @@ impl<'ast> pprust_hir::PpAnn for NoAnn<'ast> { } } -struct IdentifiedAnnotation<'ast> { - sess: &'ast Session, - ast_map: Option>, +struct IdentifiedAnnotation<'hir> { + sess: &'hir Session, + hir_map: Option>, } -impl<'ast> PrinterSupport<'ast> for IdentifiedAnnotation<'ast> { +impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> { fn sess<'a>(&'a self) -> &'a Session { self.sess } - fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> { - self.ast_map.as_ref() - } - fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn { self } } -impl<'ast> pprust::PpAnn for IdentifiedAnnotation<'ast> { +impl<'hir> pprust::PpAnn for IdentifiedAnnotation<'hir> { fn pre(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> { match node { pprust::NodeExpr(_) => s.popen(), @@ -396,13 +383,13 @@ impl<'ast> pprust::PpAnn for IdentifiedAnnotation<'ast> { } } -impl<'ast> HirPrinterSupport<'ast> for IdentifiedAnnotation<'ast> { +impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> { fn sess<'a>(&'a self) -> &'a Session { self.sess } - fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> { - self.ast_map.as_ref() + fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> { + self.hir_map.as_ref() } fn pp_ann<'a>(&'a self) -> &'a pprust_hir::PpAnn { @@ -410,10 +397,10 @@ impl<'ast> HirPrinterSupport<'ast> for IdentifiedAnnotation<'ast> { } } -impl<'ast> pprust_hir::PpAnn for IdentifiedAnnotation<'ast> { +impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> { fn nested(&self, state: &mut pprust_hir::State, nested: pprust_hir::Nested) -> io::Result<()> { - if let Some(ref map) = self.ast_map { + if let Some(ref map) = self.hir_map { pprust_hir::PpAnn::nested(map, state, nested) } else { Ok(()) @@ -453,26 +440,21 @@ impl<'ast> pprust_hir::PpAnn for IdentifiedAnnotation<'ast> { } } -struct HygieneAnnotation<'ast> { - sess: &'ast Session, - ast_map: Option>, +struct HygieneAnnotation<'a> { + sess: &'a Session } -impl<'ast> PrinterSupport<'ast> for HygieneAnnotation<'ast> { - fn sess<'a>(&'a self) -> &'a Session { +impl<'a> PrinterSupport for HygieneAnnotation<'a> { + fn sess(&self) -> &Session { self.sess } - fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'ast>> { - self.ast_map.as_ref() - } - - fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn { + fn pp_ann(&self) -> &pprust::PpAnn { self } } -impl<'ast> pprust::PpAnn for HygieneAnnotation<'ast> { +impl<'a> pprust::PpAnn for HygieneAnnotation<'a> { fn post(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> { match node { pprust::NodeIdent(&ast::Ident { name, ctxt }) => { @@ -501,7 +483,7 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> { &self.tcx.sess } - fn ast_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> { + fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> { Some(&self.tcx.hir) } @@ -579,12 +561,12 @@ impl FromStr for UserIdentifiedItem { } } -enum NodesMatchingUII<'a, 'ast: 'a> { +enum NodesMatchingUII<'a, 'hir: 'a> { NodesMatchingDirect(option::IntoIter), - NodesMatchingSuffix(hir_map::NodesMatchingSuffix<'a, 'ast>), + NodesMatchingSuffix(hir_map::NodesMatchingSuffix<'a, 'hir>), } -impl<'a, 'ast> Iterator for NodesMatchingUII<'a, 'ast> { +impl<'a, 'hir> Iterator for NodesMatchingUII<'a, 'hir> { type Item = ast::NodeId; fn next(&mut self) -> Option { @@ -603,9 +585,9 @@ impl UserIdentifiedItem { } } - fn all_matching_node_ids<'a, 'ast>(&'a self, - map: &'a hir_map::Map<'ast>) - -> NodesMatchingUII<'a, 'ast> { + fn all_matching_node_ids<'a, 'hir>(&'a self, + map: &'a hir_map::Map<'hir>) + -> NodesMatchingUII<'a, 'hir> { match *self { ItemViaNode(node_id) => NodesMatchingDirect(Some(node_id).into_iter()), ItemViaPath(ref parts) => NodesMatchingSuffix(map.nodes_matching_suffix(&parts[..])), @@ -745,7 +727,7 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec, }; let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges; let lcfg = LabelledCFG { - ast_map: &tcx.hir, + hir_map: &tcx.hir, cfg: &cfg, name: format!("node_{}", code.id()), labelled_edges: labelled_edges, @@ -855,7 +837,7 @@ pub fn print_after_parsing(sess: &Session, } pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, - ast_map: &hir_map::Map<'tcx>, + hir_map: &hir_map::Map<'tcx>, analysis: &ty::CrateAnalysis<'tcx>, resolutions: &Resolutions, input: &Input, @@ -871,7 +853,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, if ppm.needs_analysis() { print_with_analysis(sess, - ast_map, + hir_map, analysis, resolutions, crate_name, @@ -892,7 +874,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, (PpmSource(s), _) => { // Silently ignores an identified node. let out: &mut Write = &mut out; - s.call_with_pp_support(sess, Some(ast_map), box out, |annotation, out| { + s.call_with_pp_support(sess, Some(hir_map), box out, |annotation, out| { debug!("pretty printing source code {:?}", s); let sess = annotation.sess(); pprust::print_crate(sess.codemap(), @@ -909,7 +891,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, (PpmHir(s), None) => { let out: &mut Write = &mut out; s.call_with_pp_support_hir(sess, - ast_map, + hir_map, analysis, resolutions, arena, @@ -933,7 +915,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, (PpmHir(s), Some(uii)) => { let out: &mut Write = &mut out; s.call_with_pp_support_hir(sess, - ast_map, + hir_map, analysis, resolutions, arena, @@ -943,7 +925,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, |annotation, (out, uii), _| { debug!("pretty printing source code {:?}", s); let sess = annotation.sess(); - let ast_map = annotation.ast_map().expect("--unpretty missing HIR map"); + let hir_map = annotation.hir_map().expect("--unpretty missing HIR map"); let mut pp_state = pprust_hir::State::new_from_input(sess.codemap(), &sess.parse_sess, src_name.to_string(), @@ -951,8 +933,8 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, box out, annotation.pp_ann(), true); - for node_id in uii.all_matching_node_ids(ast_map) { - let node = ast_map.get(node_id); + for node_id in uii.all_matching_node_ids(hir_map) { + let node = hir_map.get(node_id); pp_state.print_node(node)?; pp::space(&mut pp_state.s)?; let path = annotation.node_path(node_id) @@ -975,7 +957,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session, // with a different callback than the standard driver, so that isn't easy. // Instead, we call that function ourselves. fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, - ast_map: &hir_map::Map<'tcx>, + hir_map: &hir_map::Map<'tcx>, analysis: &ty::CrateAnalysis<'tcx>, resolutions: &Resolutions, crate_name: &str, @@ -986,7 +968,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, ofile: Option<&Path>) { let nodeid = if let Some(uii) = uii { debug!("pretty printing for {:?}", uii); - Some(uii.to_one_node_id("--unpretty", sess, &ast_map)) + Some(uii.to_one_node_id("--unpretty", sess, &hir_map)) } else { debug!("pretty printing for whole crate"); None @@ -995,7 +977,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, let mut out = Vec::new(); abort_on_err(driver::phase_3_run_analysis_passes(sess, - ast_map.clone(), + hir_map.clone(), analysis.clone(), resolutions.clone(), arena, diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 0ac95d12eeef3..59f6889ba4d94 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -131,19 +131,19 @@ fn test_env(source_string: &str, let arena = DroplessArena::new(); let arenas = ty::GlobalArenas::new(); - let ast_map = hir_map::map_crate(&mut hir_forest, defs); + let hir_map = hir_map::map_crate(&mut hir_forest, defs); // run just enough stuff to build a tcx: - let lang_items = lang_items::collect_language_items(&sess, &ast_map); - let named_region_map = resolve_lifetime::krate(&sess, &ast_map); - let region_map = region::resolve_crate(&sess, &ast_map); - let index = stability::Index::new(&ast_map); + let lang_items = lang_items::collect_language_items(&sess, &hir_map); + let named_region_map = resolve_lifetime::krate(&sess, &hir_map); + let region_map = region::resolve_crate(&sess, &hir_map); + let index = stability::Index::new(&hir_map); TyCtxt::create_and_enter(&sess, &arenas, &arena, resolutions, named_region_map.unwrap(), - ast_map, + hir_map, region_map, lang_items, index, diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index df9fe00e9a88e..a5bd69fff0138 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -43,9 +43,9 @@ enum Context { } #[derive(Copy, Clone)] -struct CheckLoopVisitor<'a, 'ast: 'a> { +struct CheckLoopVisitor<'a, 'hir: 'a> { sess: &'a Session, - hir_map: &'a Map<'ast>, + hir_map: &'a Map<'hir>, cx: Context, } @@ -59,20 +59,20 @@ pub fn check_crate(sess: &Session, map: &Map) { }.as_deep_visitor()); } -impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> { +impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { NestedVisitorMap::OnlyBodies(&self.hir_map) } - fn visit_item(&mut self, i: &'ast hir::Item) { + fn visit_item(&mut self, i: &'hir hir::Item) { self.with_context(Normal, |v| intravisit::walk_item(v, i)); } - fn visit_impl_item(&mut self, i: &'ast hir::ImplItem) { + fn visit_impl_item(&mut self, i: &'hir hir::ImplItem) { self.with_context(Normal, |v| intravisit::walk_impl_item(v, i)); } - fn visit_expr(&mut self, e: &'ast hir::Expr) { + fn visit_expr(&mut self, e: &'hir hir::Expr) { match e.node { hir::ExprWhile(ref e, ref b, _) => { self.with_context(Loop(LoopKind::WhileLoop), |v| { @@ -125,9 +125,9 @@ impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> { } } -impl<'a, 'ast> CheckLoopVisitor<'a, 'ast> { +impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> { fn with_context(&mut self, cx: Context, f: F) - where F: FnOnce(&mut CheckLoopVisitor<'a, 'ast>) + where F: FnOnce(&mut CheckLoopVisitor<'a, 'hir>) { let old_cx = self.cx; self.cx = cx; diff --git a/src/librustc_passes/static_recursion.rs b/src/librustc_passes/static_recursion.rs index ba4fc57276b2c..1ef8a5b0080f3 100644 --- a/src/librustc_passes/static_recursion.rs +++ b/src/librustc_passes/static_recursion.rs @@ -12,7 +12,7 @@ // recursively. use rustc::dep_graph::DepNode; -use rustc::hir::map as ast_map; +use rustc::hir::map as hir_map; use rustc::session::{CompileResult, Session}; use rustc::hir::def::{Def, CtorKind}; use rustc::util::nodemap::{NodeMap, NodeSet}; @@ -23,9 +23,9 @@ use syntax_pos::Span; use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; use rustc::hir; -struct CheckCrateVisitor<'a, 'ast: 'a> { +struct CheckCrateVisitor<'a, 'hir: 'a> { sess: &'a Session, - ast_map: &'a ast_map::Map<'ast>, + hir_map: &'a hir_map::Map<'hir>, // `discriminant_map` is a cache that associates the `NodeId`s of local // variant definitions with the discriminant expression that applies to // each one. If the variant uses the default values (starting from `0`), @@ -34,12 +34,12 @@ struct CheckCrateVisitor<'a, 'ast: 'a> { detected_recursive_ids: NodeSet, } -impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> { +impl<'a, 'hir: 'a> Visitor<'hir> for CheckCrateVisitor<'a, 'hir> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { NestedVisitorMap::None } - fn visit_item(&mut self, it: &'ast hir::Item) { + fn visit_item(&mut self, it: &'hir hir::Item) { match it.node { hir::ItemStatic(..) | hir::ItemConst(..) => { @@ -64,7 +64,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> { intravisit::walk_item(self, it) } - fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) { + fn visit_trait_item(&mut self, ti: &'hir hir::TraitItem) { match ti.node { hir::TraitItemKind::Const(_, ref default) => { if let Some(_) = *default { @@ -77,7 +77,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> { intravisit::walk_trait_item(self, ti) } - fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) { + fn visit_impl_item(&mut self, ii: &'hir hir::ImplItem) { match ii.node { hir::ImplItemKind::Const(..) => { let mut recursion_visitor = CheckItemRecursionVisitor::new(self, &ii.span); @@ -89,36 +89,36 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> { } } -pub fn check_crate<'ast>(sess: &Session, ast_map: &ast_map::Map<'ast>) -> CompileResult { - let _task = ast_map.dep_graph.in_task(DepNode::CheckStaticRecursion); +pub fn check_crate<'hir>(sess: &Session, hir_map: &hir_map::Map<'hir>) -> CompileResult { + let _task = hir_map.dep_graph.in_task(DepNode::CheckStaticRecursion); let mut visitor = CheckCrateVisitor { sess: sess, - ast_map: ast_map, + hir_map: hir_map, discriminant_map: NodeMap(), detected_recursive_ids: NodeSet(), }; sess.track_errors(|| { // FIXME(#37712) could use ItemLikeVisitor if trait items were item-like - ast_map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); + hir_map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); }) } -struct CheckItemRecursionVisitor<'a, 'b: 'a, 'ast: 'b> { +struct CheckItemRecursionVisitor<'a, 'b: 'a, 'hir: 'b> { root_span: &'b Span, sess: &'b Session, - ast_map: &'b ast_map::Map<'ast>, + hir_map: &'b hir_map::Map<'hir>, discriminant_map: &'a mut NodeMap>, idstack: Vec, detected_recursive_ids: &'a mut NodeSet, } -impl<'a, 'b: 'a, 'ast: 'b> CheckItemRecursionVisitor<'a, 'b, 'ast> { - fn new(v: &'a mut CheckCrateVisitor<'b, 'ast>, span: &'b Span) -> Self { +impl<'a, 'b: 'a, 'hir: 'b> CheckItemRecursionVisitor<'a, 'b, 'hir> { + fn new(v: &'a mut CheckCrateVisitor<'b, 'hir>, span: &'b Span) -> Self { CheckItemRecursionVisitor { root_span: span, sess: v.sess, - ast_map: v.ast_map, + hir_map: v.hir_map, discriminant_map: &mut v.discriminant_map, idstack: Vec::new(), detected_recursive_ids: &mut v.detected_recursive_ids, @@ -133,7 +133,7 @@ impl<'a, 'b: 'a, 'ast: 'b> CheckItemRecursionVisitor<'a, 'b, 'ast> { } self.detected_recursive_ids.insert(id); let any_static = self.idstack.iter().any(|&x| { - if let ast_map::NodeItem(item) = self.ast_map.get(x) { + if let hir_map::NodeItem(item) = self.hir_map.get(x) { if let hir::ItemStatic(..) = item.node { true } else { @@ -170,7 +170,7 @@ impl<'a, 'b: 'a, 'ast: 'b> CheckItemRecursionVisitor<'a, 'b, 'ast> { // So for every variant, we need to track whether there is an expression // somewhere in the enum definition that controls its discriminant. We do // this by starting from the end and searching backward. - fn populate_enum_discriminants(&mut self, enum_definition: &'ast hir::EnumDef) { + fn populate_enum_discriminants(&mut self, enum_definition: &'hir hir::EnumDef) { // Get the map, and return if we already processed this enum or if it // has no variants. match enum_definition.variants.first() { @@ -204,17 +204,17 @@ impl<'a, 'b: 'a, 'ast: 'b> CheckItemRecursionVisitor<'a, 'b, 'ast> { } } -impl<'a, 'b: 'a, 'ast: 'b> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'b, 'ast> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> { - NestedVisitorMap::OnlyBodies(&self.ast_map) +impl<'a, 'b: 'a, 'hir: 'b> Visitor<'hir> for CheckItemRecursionVisitor<'a, 'b, 'hir> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> { + NestedVisitorMap::OnlyBodies(&self.hir_map) } - fn visit_item(&mut self, it: &'ast hir::Item) { + fn visit_item(&mut self, it: &'hir hir::Item) { self.with_item_id_pushed(it.id, |v| intravisit::walk_item(v, it), it.span); } fn visit_enum_def(&mut self, - enum_definition: &'ast hir::EnumDef, - generics: &'ast hir::Generics, + enum_definition: &'hir hir::EnumDef, + generics: &'hir hir::Generics, item_id: ast::NodeId, _: Span) { self.populate_enum_discriminants(enum_definition); @@ -222,8 +222,8 @@ impl<'a, 'b: 'a, 'ast: 'b> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'b, ' } fn visit_variant(&mut self, - variant: &'ast hir::Variant, - _: &'ast hir::Generics, + variant: &'hir hir::Variant, + _: &'hir hir::Generics, _: ast::NodeId) { let variant_id = variant.node.data.id(); let maybe_expr = *self.discriminant_map.get(&variant_id).unwrap_or_else(|| { @@ -234,34 +234,34 @@ impl<'a, 'b: 'a, 'ast: 'b> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'b, ' // If `maybe_expr` is `None`, that's because no discriminant is // specified that affects this variant. Thus, no risk of recursion. if let Some(expr) = maybe_expr { - let expr = &self.ast_map.body(expr).value; + let expr = &self.hir_map.body(expr).value; self.with_item_id_pushed(expr.id, |v| intravisit::walk_expr(v, expr), expr.span); } } - fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) { + fn visit_trait_item(&mut self, ti: &'hir hir::TraitItem) { self.with_item_id_pushed(ti.id, |v| intravisit::walk_trait_item(v, ti), ti.span); } - fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) { + fn visit_impl_item(&mut self, ii: &'hir hir::ImplItem) { self.with_item_id_pushed(ii.id, |v| intravisit::walk_impl_item(v, ii), ii.span); } - fn visit_path(&mut self, path: &'ast hir::Path, _: ast::NodeId) { + fn visit_path(&mut self, path: &'hir hir::Path, _: ast::NodeId) { match path.def { Def::Static(def_id, _) | Def::AssociatedConst(def_id) | Def::Const(def_id) => { - if let Some(node_id) = self.ast_map.as_local_node_id(def_id) { - match self.ast_map.get(node_id) { - ast_map::NodeItem(item) => self.visit_item(item), - ast_map::NodeTraitItem(item) => self.visit_trait_item(item), - ast_map::NodeImplItem(item) => self.visit_impl_item(item), - ast_map::NodeForeignItem(_) => {} + if let Some(node_id) = self.hir_map.as_local_node_id(def_id) { + match self.hir_map.get(node_id) { + hir_map::NodeItem(item) => self.visit_item(item), + hir_map::NodeTraitItem(item) => self.visit_trait_item(item), + hir_map::NodeImplItem(item) => self.visit_impl_item(item), + hir_map::NodeForeignItem(_) => {} _ => { span_bug!(path.span, "expected item, found {}", - self.ast_map.node_to_string(node_id)); + self.hir_map.node_to_string(node_id)); } } } @@ -271,10 +271,10 @@ impl<'a, 'b: 'a, 'ast: 'b> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'b, ' // the whole enum definition to see what expression that // might be (if any). Def::VariantCtor(variant_id, CtorKind::Const) => { - if let Some(variant_id) = self.ast_map.as_local_node_id(variant_id) { - let variant = self.ast_map.expect_variant(variant_id); - let enum_id = self.ast_map.get_parent(variant_id); - let enum_item = self.ast_map.expect_item(enum_id); + if let Some(variant_id) = self.hir_map.as_local_node_id(variant_id) { + let variant = self.hir_map.expect_variant(variant_id); + let enum_id = self.hir_map.get_parent(variant_id); + let enum_item = self.hir_map.expect_item(enum_id); if let hir::ItemEnum(ref enum_def, ref generics) = enum_item.node { self.populate_enum_discriminants(enum_def); self.visit_variant(variant, generics, enum_id);