From a70babed03d58d042024e41f0a46f7e33e34d0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Tue, 4 Dec 2018 13:45:36 +0100 Subject: [PATCH] Use a function to access the Hir map to be able to turn it into a query later --- src/librustc/cfg/construct.rs | 12 +- src/librustc/cfg/graphviz.rs | 6 +- src/librustc/dep_graph/dep_node.rs | 6 +- src/librustc/dep_graph/dep_tracking_map.rs | 2 +- src/librustc/hir/check_attr.rs | 6 +- src/librustc/hir/itemlikevisit.rs | 6 +- src/librustc/hir/map/mod.rs | 4 +- src/librustc/infer/error_reporting/mod.rs | 26 +-- .../infer/error_reporting/need_type_info.rs | 4 +- .../nice_region_error/find_anon_type.rs | 18 +- .../nice_region_error/outlives_closure.rs | 2 +- .../error_reporting/nice_region_error/util.rs | 2 +- src/librustc/infer/error_reporting/note.rs | 12 +- src/librustc/infer/opaque_types/mod.rs | 16 +- src/librustc/lint/context.rs | 10 +- src/librustc/lint/mod.rs | 6 +- src/librustc/middle/dead.rs | 24 +-- src/librustc/middle/expr_use_visitor.rs | 8 +- src/librustc/middle/intrinsicck.rs | 6 +- src/librustc/middle/lang_items.rs | 8 +- src/librustc/middle/lib_features.rs | 4 +- src/librustc/middle/liveness.rs | 24 +-- src/librustc/middle/mem_categorization.rs | 16 +- src/librustc/middle/reachable.rs | 40 ++--- src/librustc/middle/region.rs | 38 ++--- src/librustc/middle/resolve_lifetime.rs | 102 ++++++------ src/librustc/middle/stability.rs | 36 ++-- src/librustc/middle/weak_lang_items.rs | 2 +- src/librustc/mir/mod.rs | 12 +- src/librustc/traits/error_reporting.rs | 24 +-- src/librustc/traits/specialize/mod.rs | 2 +- src/librustc/traits/util.rs | 4 +- src/librustc/ty/constness.rs | 4 +- src/librustc/ty/context.rs | 51 +++--- .../ty/inhabitedness/def_id_forest.rs | 2 +- src/librustc/ty/item_path.rs | 6 +- src/librustc/ty/mod.rs | 78 ++++----- src/librustc/ty/query/config.rs | 4 +- src/librustc/ty/query/on_disk_cache.rs | 6 +- src/librustc/ty/trait_def.rs | 4 +- src/librustc/ty/util.rs | 4 +- src/librustc/util/ppaux.rs | 16 +- src/librustc_borrowck/borrowck/check_loans.rs | 14 +- .../borrowck/gather_loans/gather_moves.rs | 6 +- .../borrowck/gather_loans/lifetime.rs | 2 +- .../borrowck/gather_loans/mod.rs | 14 +- .../borrowck/gather_loans/move_error.rs | 4 +- src/librustc_borrowck/borrowck/mod.rs | 94 +++++------ src/librustc_borrowck/borrowck/unused.rs | 8 +- src/librustc_borrowck/dataflow.rs | 2 +- src/librustc_codegen_llvm/consts.rs | 4 +- src/librustc_codegen_llvm/debuginfo/gdb.rs | 2 +- src/librustc_codegen_llvm/debuginfo/mod.rs | 2 +- .../back/symbol_export.rs | 14 +- src/librustc_codegen_ssa/back/write.rs | 4 +- src/librustc_codegen_ssa/base.rs | 2 +- src/librustc_codegen_ssa/mono_item.rs | 2 +- src/librustc_codegen_utils/lib.rs | 2 +- src/librustc_codegen_utils/symbol_names.rs | 4 +- .../symbol_names_test.rs | 4 +- src/librustc_driver/driver.rs | 2 +- src/librustc_driver/pretty.rs | 18 +- src/librustc_driver/test.rs | 10 +- src/librustc_incremental/assert_dep_graph.rs | 8 +- .../assert_module_sources.rs | 2 +- .../persist/dirty_clean.rs | 8 +- src/librustc_lint/builtin.rs | 26 +-- src/librustc_lint/nonstandard_style.rs | 2 +- src/librustc_lint/types.rs | 14 +- src/librustc_lint/unused.rs | 2 +- src/librustc_metadata/encoder.rs | 84 +++++----- src/librustc_metadata/foreign_modules.rs | 6 +- src/librustc_metadata/index_builder.rs | 6 +- src/librustc_metadata/link_args.rs | 4 +- src/librustc_metadata/native_libs.rs | 4 +- .../borrow_check/error_reporting.rs | 26 +-- src/librustc_mir/borrow_check/mod.rs | 6 +- src/librustc_mir/borrow_check/move_errors.rs | 4 +- .../borrow_check/mutability_errors.rs | 8 +- src/librustc_mir/borrow_check/nll/mod.rs | 2 +- .../error_reporting/region_name.rs | 20 ++- .../region_infer/error_reporting/var_name.rs | 6 +- .../borrow_check/nll/universal_regions.rs | 12 +- src/librustc_mir/build/matches/mod.rs | 4 +- src/librustc_mir/build/mod.rs | 50 +++--- src/librustc_mir/build/scope.rs | 4 +- src/librustc_mir/const_eval.rs | 8 +- src/librustc_mir/hair/cx/block.rs | 4 +- src/librustc_mir/hair/cx/expr.rs | 16 +- src/librustc_mir/hair/cx/mod.rs | 14 +- src/librustc_mir/hair/pattern/check_match.rs | 18 +- src/librustc_mir/hair/pattern/mod.rs | 2 +- src/librustc_mir/lints.rs | 8 +- src/librustc_mir/monomorphize/collector.rs | 26 +-- src/librustc_mir/monomorphize/item.rs | 10 +- src/librustc_mir/monomorphize/partitioning.rs | 8 +- src/librustc_mir/shim.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 16 +- src/librustc_mir/transform/const_prop.rs | 6 +- src/librustc_mir/transform/elaborate_drops.rs | 2 +- src/librustc_mir/transform/generator.rs | 2 +- src/librustc_mir/transform/inline.rs | 4 +- src/librustc_mir/transform/mod.rs | 8 +- src/librustc_mir/transform/qualify_consts.rs | 4 +- src/librustc_mir/transform/rustc_peek.rs | 2 +- src/librustc_mir/util/graphviz.rs | 2 +- src/librustc_mir/util/liveness.rs | 2 +- src/librustc_mir/util/pretty.rs | 6 +- src/librustc_passes/rvalue_promotion.rs | 22 +-- src/librustc_privacy/lib.rs | 105 ++++++------ src/librustc_save_analysis/dump_visitor.rs | 20 +-- src/librustc_save_analysis/lib.rs | 26 +-- src/librustc_traits/lowering/environment.rs | 4 +- src/librustc_traits/lowering/mod.rs | 6 +- src/librustc_typeck/astconv.rs | 26 +-- src/librustc_typeck/check/_match.rs | 4 +- src/librustc_typeck/check/callee.rs | 8 +- src/librustc_typeck/check/closure.rs | 6 +- src/librustc_typeck/check/coercion.rs | 2 +- src/librustc_typeck/check/compare_method.rs | 70 ++++---- src/librustc_typeck/check/demand.rs | 12 +- src/librustc_typeck/check/dropck.rs | 6 +- .../check/generator_interior.rs | 2 +- src/librustc_typeck/check/intrinsic.rs | 4 +- src/librustc_typeck/check/method/mod.rs | 4 +- src/librustc_typeck/check/method/probe.rs | 2 +- src/librustc_typeck/check/method/suggest.rs | 26 +-- src/librustc_typeck/check/mod.rs | 140 ++++++++-------- src/librustc_typeck/check/regionck.rs | 14 +- src/librustc_typeck/check/upvar.rs | 14 +- src/librustc_typeck/check/wfcheck.rs | 42 ++--- src/librustc_typeck/check/writeback.rs | 28 ++-- src/librustc_typeck/check_unused.rs | 22 +-- src/librustc_typeck/coherence/builtin.rs | 28 ++-- .../coherence/inherent_impls.rs | 6 +- .../coherence/inherent_impls_overlap.rs | 6 +- src/librustc_typeck/coherence/mod.rs | 8 +- src/librustc_typeck/coherence/orphan.rs | 6 +- src/librustc_typeck/coherence/unsafety.rs | 4 +- src/librustc_typeck/collect.rs | 156 +++++++++--------- src/librustc_typeck/impl_wf_check.rs | 8 +- src/librustc_typeck/lib.rs | 16 +- .../outlives/implicit_infer.rs | 8 +- src/librustc_typeck/outlives/mod.rs | 4 +- src/librustc_typeck/outlives/test.rs | 4 +- src/librustc_typeck/variance/constraints.rs | 8 +- src/librustc_typeck/variance/mod.rs | 6 +- src/librustc_typeck/variance/solve.rs | 2 +- src/librustc_typeck/variance/terms.rs | 8 +- src/librustc_typeck/variance/test.rs | 4 +- src/librustdoc/clean/auto_trait.rs | 2 +- src/librustdoc/clean/blanket_impl.rs | 2 +- src/librustdoc/clean/def_ctor.rs | 2 +- src/librustdoc/clean/inline.rs | 14 +- src/librustdoc/clean/mod.rs | 102 ++++++------ src/librustdoc/core.rs | 10 +- .../passes/collect_intra_doc_links.rs | 6 +- src/librustdoc/passes/collect_trait_impls.rs | 6 +- src/librustdoc/visit_ast.rs | 30 ++-- .../auxiliary/issue-40001-plugin.rs | 4 +- 160 files changed, 1220 insertions(+), 1210 deletions(-) diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 6b9c0aac52e79..457f33f8bd7b9 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -53,7 +53,7 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let body_exit; // Find the tables for this body. - let owner_def_id = tcx.hir.local_def_id(tcx.hir.body_owner(body.id())); + let owner_def_id = tcx.hir().local_def_id(tcx.hir().body_owner(body.id())); let tables = tcx.typeck_tables_of(owner_def_id); let mut cfg_builder = CFGBuilder { @@ -109,7 +109,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex { - let hir_id = self.tcx.hir.node_to_hir_id(stmt.node.id()); + let hir_id = self.tcx.hir().node_to_hir_id(stmt.node.id()); match stmt.node { hir::StmtKind::Decl(ref decl, _) => { let exit = self.decl(&decl, pred); @@ -588,9 +588,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { match destination.target_id { Ok(loop_id) => { for b in &self.breakable_block_scopes { - if b.block_expr_id == self.tcx.hir.node_to_hir_id(loop_id).local_id { + if b.block_expr_id == self.tcx.hir().node_to_hir_id(loop_id).local_id { let scope = region::Scope { - id: self.tcx.hir.node_to_hir_id(loop_id).local_id, + id: self.tcx.hir().node_to_hir_id(loop_id).local_id, data: region::ScopeData::Node }; return (scope, match scope_cf_kind { @@ -600,9 +600,9 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } } for l in &self.loop_scopes { - if l.loop_id == self.tcx.hir.node_to_hir_id(loop_id).local_id { + if l.loop_id == self.tcx.hir().node_to_hir_id(loop_id).local_id { let scope = region::Scope { - id: self.tcx.hir.node_to_hir_id(loop_id).local_id, + id: self.tcx.hir().node_to_hir_id(loop_id).local_id, data: region::ScopeData::Node }; return (scope, match scope_cf_kind { diff --git a/src/librustc/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs index 650aa39114fad..39810691df855 100644 --- a/src/librustc/cfg/graphviz.rs +++ b/src/librustc/cfg/graphviz.rs @@ -32,11 +32,11 @@ pub struct LabelledCFG<'a, 'tcx: 'a> { impl<'a, 'tcx> LabelledCFG<'a, 'tcx> { fn local_id_to_string(&self, local_id: hir::ItemLocalId) -> String { assert!(self.cfg.owner_def_id.is_local()); - let node_id = self.tcx.hir.hir_to_node_id(hir::HirId { - owner: self.tcx.hir.def_index_to_hir_id(self.cfg.owner_def_id.index).owner, + let node_id = self.tcx.hir().hir_to_node_id(hir::HirId { + owner: self.tcx.hir().def_index_to_hir_id(self.cfg.owner_def_id.index).owner, local_id }); - let s = self.tcx.hir.node_to_string(node_id); + let s = self.tcx.hir().node_to_string(node_id); // Replacing newlines with \\l causes each line to be left-aligned, // improving presentation of (long) pretty-printed expressions. diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index a20d04972fd75..dd46dd3fd6461 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -449,10 +449,10 @@ define_dep_nodes!( <'tcx> // 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.hir.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.hir.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 @@ -733,7 +733,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefIndex { const CAN_RECONSTRUCT_QUERY_KEY: bool = true; fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint { - tcx.hir.definitions().def_path_hash(*self).0 + tcx.hir().definitions().def_path_hash(*self).0 } fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String { diff --git a/src/librustc/dep_graph/dep_tracking_map.rs b/src/librustc/dep_graph/dep_tracking_map.rs index a674b5df6395c..da7dabf6e1839 100644 --- a/src/librustc/dep_graph/dep_tracking_map.rs +++ b/src/librustc/dep_graph/dep_tracking_map.rs @@ -65,7 +65,7 @@ impl MemoizationMap for RefCell> { /// /// ``` /// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> { - /// let item_def_id = ccx.tcx.hir.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/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 020012d756a1c..5ff533fe34b2d 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -100,7 +100,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { /// Check any attribute. fn check_attributes(&self, item: &hir::Item, target: Target) { if target == Target::Fn || target == Target::Const { - self.tcx.codegen_fn_attrs(self.tcx.hir.local_def_id(item.id)); + self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(item.id)); } else if let Some(a) = item.attrs.iter().find(|a| a.check_name("target_feature")) { self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function") .span_label(item.span, "not a function") @@ -352,7 +352,7 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for CheckAttrVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -375,7 +375,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckAttrVisitor<'a, 'tcx> { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut checker = CheckAttrVisitor { tcx }; - tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor()); + tcx.hir().krate().visit_all_item_likes(&mut checker.as_deep_visitor()); } fn is_c_like_enum(item: &hir::Item) -> bool { diff --git a/src/librustc/hir/itemlikevisit.rs b/src/librustc/hir/itemlikevisit.rs index a62000e10c79f..f8bc764572f02 100644 --- a/src/librustc/hir/itemlikevisit.rs +++ b/src/librustc/hir/itemlikevisit.rs @@ -19,7 +19,7 @@ use super::intravisit::Visitor; /// /// 1. **Shallow visit**: Get a simple callback for every item (or item-like thing) in the HIR. /// - Example: find all items with a `#[foo]` attribute on them. -/// - How: Implement `ItemLikeVisitor` and call `tcx.hir.krate().visit_all_item_likes()`. +/// - How: Implement `ItemLikeVisitor` and call `tcx.hir().krate().visit_all_item_likes()`. /// - Pro: Efficient; just walks the lists of item-like things, not the nodes themselves. /// - Con: Don't get information about nesting /// - Con: Don't have methods for specific bits of HIR, like "on @@ -29,7 +29,7 @@ use super::intravisit::Visitor; /// within one another. /// - Example: Examine each expression to look for its type and do some check or other. /// - How: Implement `intravisit::Visitor` and use -/// `tcx.hir.krate().visit_all_item_likes(visitor.as_deep_visitor())`. Within +/// `tcx.hir().krate().visit_all_item_likes(visitor.as_deep_visitor())`. Within /// your `intravisit::Visitor` impl, implement methods like /// `visit_expr()`; don't forget to invoke /// `intravisit::walk_visit_expr()` to keep walking the subparts. @@ -43,7 +43,7 @@ use super::intravisit::Visitor; /// - How: Implement `intravisit::Visitor` and override the /// `nested_visit_map()` methods to return /// `NestedVisitorMap::All`. Walk your crate with -/// `intravisit::walk_crate()` invoked on `tcx.hir.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/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 4ac07d78a2613..99c92e1e31db1 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -1258,8 +1258,8 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String { } pub fn describe_def(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option { - if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { - tcx.hir.describe_def(node_id) + if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { + tcx.hir().describe_def(node_id) } else { bug!("Calling local describe_def query provider for upstream DefId: {:?}", def_id) diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 59a490f4a013d..7d997a0154600 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -97,7 +97,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ) }; let span = scope.span(self, region_scope_tree); - let tag = match self.hir.find(scope.node_id(self, region_scope_tree)) { + let tag = match self.hir().find(scope.node_id(self, region_scope_tree)) { Some(Node::Block(_)) => "block", Some(Node::Expr(expr)) => match expr.node { hir::ExprKind::Call(..) => "call", @@ -190,8 +190,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { let cm = self.sess.source_map(); let scope = region.free_region_binding_scope(self); - let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID); - let tag = match self.hir.find(node) { + let node = self.hir().as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID); + let tag = match self.hir().find(node) { Some(Node::Block(_)) | Some(Node::Expr(_)) => "body", Some(Node::Item(it)) => Self::item_scope_tag(&it), Some(Node::TraitItem(it)) => Self::trait_item_scope_tag(&it), @@ -200,8 +200,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { }; let (prefix, span) = match *region { ty::ReEarlyBound(ref br) => { - let mut sp = cm.def_span(self.hir.span(node)); - if let Some(param) = self.hir + let mut sp = cm.def_span(self.hir().span(node)); + if let Some(param) = self.hir() .get_generics(scope) .and_then(|generics| generics.get_named(&br.name)) { @@ -213,8 +213,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { bound_region: ty::BoundRegion::BrNamed(_, ref name), .. }) => { - let mut sp = cm.def_span(self.hir.span(node)); - if let Some(param) = self.hir + let mut sp = cm.def_span(self.hir().span(node)); + if let Some(param) = self.hir() .get_generics(scope) .and_then(|generics| generics.get_named(&name)) { @@ -225,15 +225,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ty::ReFree(ref fr) => match fr.bound_region { ty::BrAnon(idx) => ( format!("the anonymous lifetime #{} defined on", idx + 1), - self.hir.span(node), + self.hir().span(node), ), ty::BrFresh(_) => ( "an anonymous lifetime defined on".to_owned(), - self.hir.span(node), + self.hir().span(node), ), _ => ( format!("the lifetime {} as defined on", fr.bound_region), - cm.def_span(self.hir.span(node)), + cm.def_span(self.hir().span(node)), ), }, _ => bug!(), @@ -1083,7 +1083,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // the expected type argument. if !param.is_self() { let type_param = generics.type_param(param, self.tcx); - let hir = &self.tcx.hir; + let hir = &self.tcx.hir(); hir.as_local_node_id(type_param.def_id).map(|id| { // Get the `hir::Param` to verify whether it already has any bounds. // We do this to avoid suggesting code that ends up as `T: 'a'b`, @@ -1315,8 +1315,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { format!(" for lifetime parameter `{}` in coherence check", name) } infer::UpvarRegion(ref upvar_id, _) => { - let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id); - let var_name = self.tcx.hir.name(var_node_id); + let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id); + let var_name = self.tcx.hir().name(var_node_id); format!(" for capture of `{}` by closure", var_name) } infer::NLL(..) => bug!("NLL variable found in lexical phase"), diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index efb316243fad0..4064df0a09d7f 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -109,13 +109,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let mut local_visitor = FindLocalByTypeVisitor { infcx: &self, target_ty: &ty, - hir_map: &self.tcx.hir, + hir_map: &self.tcx.hir(), found_local_pattern: None, found_arg_pattern: None, }; if let Some(body_id) = body_id { - let expr = self.tcx.hir.expect_expr(body_id.node_id); + let expr = self.tcx.hir().expect_expr(body_id.node_id); local_visitor.visit_expr(expr); } diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index 10a2d179dd564..38363be482715 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -38,8 +38,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { ) -> Option<(&hir::Ty, &hir::FnDecl)> { if let Some(anon_reg) = self.tcx.is_suitable_region(region) { let def_id = anon_reg.def_id; - if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { - let fndecl = match self.tcx.hir.get(node_id) { + if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) { + let fndecl = match self.tcx.hir().get(node_id) { Node::Item(&hir::Item { node: hir::ItemKind::Fn(ref fndecl, ..), .. @@ -104,7 +104,7 @@ struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_ty(&mut self, arg: &'gcx hir::Ty) { @@ -124,7 +124,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { hir::TyKind::Rptr(ref lifetime, _) => { // the lifetime of the TyRptr - let hir_id = self.tcx.hir.node_to_hir_id(lifetime.id); + let hir_id = self.tcx.hir().node_to_hir_id(lifetime.id); match (self.tcx.named_region(hir_id), self.bound_region) { // Find the index of the anonymous region that was part of the // error. We will then search the function parameters for a bound @@ -150,7 +150,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { // region at the right depth with the same index (Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => { debug!( - "EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \ + "EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \ def_id={:?}", id, def_id @@ -172,7 +172,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> { "FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}", debruijn_index ); - debug!("self.infcx.tcx.hir.local_def_id(id)={:?}", id); + debug!("self.infcx.tcx.hir().local_def_id(id)={:?}", id); debug!("def_id={:?}", def_id); if debruijn_index == self.current_index && id == def_id { self.found_type = Some(arg); @@ -227,11 +227,11 @@ struct TyPathVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) { - let hir_id = self.tcx.hir.node_to_hir_id(lifetime.id); + let hir_id = self.tcx.hir().node_to_hir_id(lifetime.id); match (self.tcx.named_region(hir_id), self.bound_region) { // the lifetime of the TyPath! (Some(rl::Region::LateBoundAnon(debruijn_index, anon_index)), ty::BrAnon(br_index)) => { @@ -243,7 +243,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> { (Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => { debug!( - "EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \ + "EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \ def_id={:?}", id, def_id diff --git a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs index 7a92b3084ba9f..4c3fbc7964659 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs @@ -56,7 +56,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { // closure, provide a specific message pointing this out. if let (&SubregionOrigin::BindingTypeIsNotValidAtDecl(ref external_span), &RegionKind::ReFree(ref free_region)) = (&sub_origin, sup_region) { - let hir = &self.tcx.hir; + let hir = &self.tcx.hir(); if let Some(node_id) = hir.as_local_node_id(free_region.scope) { if let Node::Expr(Expr { node: Closure(_, _, _, closure_span, None), diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs index 013c02f75b883..e5c2c75a3f384 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs @@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { _ => return None, // not a free region }; - let hir = &self.tcx.hir; + let hir = &self.tcx.hir(); if let Some(node_id) = hir.as_local_node_id(id) { if let Some(body_id) = hir.maybe_body_owned_by(node_id) { let body = hir.body(body_id); diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index a539c321af3f0..f5ac39ae838f6 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -41,8 +41,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { "...so that reference does not outlive borrowed content"); } infer::ReborrowUpvar(span, ref upvar_id) => { - let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id); - let var_name = self.tcx.hir.name(var_node_id); + let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id); + let var_name = self.tcx.hir().name(var_node_id); err.span_note(span, &format!("...so that closure can access `{}`", var_name)); } @@ -61,7 +61,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { err.span_note(span, &format!("...so that captured variable `{}` does not outlive the \ enclosing closure", - self.tcx.hir.name(id))); + self.tcx.hir().name(id))); } infer::IndexSlice(span) => { err.span_note(span, "...so that slice is not indexed outside the lifetime"); @@ -174,8 +174,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { err } infer::ReborrowUpvar(span, ref upvar_id) => { - let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id); - let var_name = self.tcx.hir.name(var_node_id); + let var_node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id); + let var_name = self.tcx.hir().name(var_node_id); let mut err = struct_span_err!(self.tcx.sess, span, E0313, @@ -232,7 +232,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { E0474, "captured variable `{}` does not outlive the \ enclosing closure", - self.tcx.hir.name(id)); + self.tcx.hir().name(id)); self.tcx.note_and_explain_region(region_scope_tree, &mut err, "captured variable is valid for ", sup, ""); self.tcx.note_and_explain_region(region_scope_tree, &mut err, diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index fda9817cc88ae..09053118f6961 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -691,13 +691,13 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { // let x = || foo(); // returns the Opaque assoc with `foo` // } // ``` - if let Some(opaque_node_id) = tcx.hir.as_local_node_id(def_id) { + if let Some(opaque_node_id) = tcx.hir().as_local_node_id(def_id) { let parent_def_id = self.parent_def_id; let def_scope_default = || { - let opaque_parent_node_id = tcx.hir.get_parent(opaque_node_id); - parent_def_id == tcx.hir.local_def_id(opaque_parent_node_id) + let opaque_parent_node_id = tcx.hir().get_parent(opaque_node_id); + parent_def_id == tcx.hir().local_def_id(opaque_parent_node_id) }; - let in_definition_scope = match tcx.hir.find(opaque_node_id) { + let in_definition_scope = match tcx.hir().find(opaque_node_id) { Some(Node::Item(item)) => match item.node { // impl trait hir::ItemKind::Existential(hir::ExistTy { @@ -725,7 +725,7 @@ impl<'a, 'gcx, 'tcx> Instantiator<'a, 'gcx, 'tcx> { }, _ => bug!( "expected (impl) item, found {}", - tcx.hir.node_to_string(opaque_node_id), + tcx.hir().node_to_string(opaque_node_id), ), }; if in_definition_scope { @@ -848,16 +848,16 @@ pub fn may_define_existential_type( opaque_node_id: ast::NodeId, ) -> bool { let mut node_id = tcx - .hir + .hir() .as_local_node_id(def_id) .unwrap(); // named existential types can be defined by any siblings or // children of siblings - let mod_id = tcx.hir.get_parent(opaque_node_id); + let mod_id = tcx.hir().get_parent(opaque_node_id); // so we walk up the node tree until we hit the root or the parent // of the opaque type while node_id != mod_id && node_id != ast::CRATE_NODE_ID { - node_id = tcx.hir.get_parent(node_id); + node_id = tcx.hir().get_parent(node_id); } // syntactically we are allowed to define the concrete type node_id == mod_id diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 469d77403a3d8..c633c0fb0360a 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -774,7 +774,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> { where F: FnOnce(&mut Self), { let old_param_env = self.param_env; - self.param_env = self.tcx.param_env(self.tcx.hir.local_def_id(id)); + self.param_env = self.tcx.param_env(self.tcx.hir().local_def_id(id)); f(self); self.param_env = old_param_env; } @@ -797,13 +797,13 @@ 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.hir) + hir_visit::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.hir.body(body); + let body = self.tcx.hir().body(body); self.visit_body(body); self.tables = old_tables; } @@ -866,7 +866,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.hir.body(body_id); + let body = self.tcx.hir().body(body_id); run_lints!(self, check_fn, fk, decl, body, span, id); hir_visit::walk_fn(self, fk, decl, body_id, span, id); run_lints!(self, check_fn_post, fk, decl, body, span, id); @@ -1191,7 +1191,7 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let passes = tcx.sess.lint_store.borrow_mut().late_passes.take(); let passes = { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 4b878b862526b..f54fdf8b46875 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -643,7 +643,7 @@ fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum) levels: LintLevelSets::builder(tcx.sess), tcx: tcx, }; - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); builder.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |builder| { intravisit::walk_crate(builder, krate); @@ -665,7 +665,7 @@ impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> { where F: FnOnce(&mut Self) { let push = self.levels.push(attrs); - self.levels.register_id(self.tcx.hir.definitions().node_to_hir_id(id)); + self.levels.register_id(self.tcx.hir().definitions().node_to_hir_id(id)); f(self); self.levels.pop(push); } @@ -673,7 +673,7 @@ impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> { impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { - intravisit::NestedVisitorMap::All(&self.tcx.hir) + intravisit::NestedVisitorMap::All(&self.tcx.hir()) } fn visit_item(&mut self, it: &'tcx hir::Item) { diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index bb7a6a6ee7b72..807d5a31143d9 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.hir.find(node_id) { + match tcx.hir().find(node_id) { Some(Node::Item(..)) | Some(Node::ImplItem(..)) | Some(Node::ForeignItem(..)) | @@ -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.hir.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.hir.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); } @@ -137,7 +137,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { continue } - if let Some(ref node) = self.tcx.hir.find(id) { + if let Some(ref node) = self.tcx.hir().find(id) { self.live_symbols.insert(id); self.visit_node(node); } @@ -153,7 +153,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { Node::Item(item) => { match item.node { hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => { - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); let def = self.tcx.adt_def(def_id); self.repr_has_repr_c = def.repr.c(); @@ -206,7 +206,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.hir.body(body); + let body = self.tcx.hir().body(body); self.visit_body(body); self.tables = old_tables; } @@ -307,7 +307,7 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>, return true; } - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); let cg_attrs = tcx.codegen_fn_attrs(def_id); // #[used], #[no_mangle], #[export_name], etc also keeps the item alive @@ -469,7 +469,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { } fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool { - let field_type = self.tcx.type_of(self.tcx.hir.local_def_id(field.id)); + let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id)); !field.is_positional() && !self.symbol_is_live(field.id, None) && !field_type.is_phantom_data() @@ -510,11 +510,11 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { // This is done to handle the case where, for example, the static // method of a private type is used, but the type itself is never // called directly. - let def_id = self.tcx.hir.local_def_id(id); + let def_id = self.tcx.hir().local_def_id(id); let inherent_impls = self.tcx.inherent_impls(def_id); for &impl_did in inherent_impls.iter() { for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] { - if let Some(item_node_id) = self.tcx.hir.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; } @@ -547,7 +547,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.hir) + NestedVisitorMap::All(&self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -648,7 +648,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let live_symbols = find_live(tcx, access_levels, krate); let mut visitor = DeadVisitor { tcx, diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 5b92bfe6ad3c4..32e23a67bdc3b 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -622,7 +622,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { match local.init { None => { local.pat.each_binding(|_, hir_id, span, _| { - let node_id = self.mc.tcx.hir.hir_to_node_id(hir_id); + let node_id = self.mc.tcx.hir().hir_to_node_id(hir_id); self.delegate.decl_without_init(node_id, span); }) } @@ -935,8 +935,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { self.tcx().with_freevars(closure_expr.id, |freevars| { for freevar in freevars { - let var_hir_id = self.tcx().hir.node_to_hir_id(freevar.var_id()); - let closure_def_id = self.tcx().hir.local_def_id(closure_expr.id); + let var_hir_id = self.tcx().hir().node_to_hir_id(freevar.var_id()); + let closure_def_id = self.tcx().hir().local_def_id(closure_expr.id); let upvar_id = ty::UpvarId { var_path: ty::UpvarPath { hir_id: var_hir_id }, closure_expr_id: closure_def_id.to_local(), @@ -973,7 +973,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_hir_id = self.tcx().hir.node_to_hir_id(upvar.var_id()); + let var_hir_id = self.tcx().hir().node_to_hir_id(upvar.var_id()); let var_ty = self.mc.node_ty(var_hir_id)?; self.mc.cat_def(closure_hir_id, closure_span, var_ty, upvar.def) } diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index d2be0e4dcb9b9..fa34c2e63daa9 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -23,7 +23,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut visitor = ItemVisitor { tcx, }; - tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); + tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); } struct ItemVisitor<'a, 'tcx: 'a> { @@ -134,8 +134,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> { } fn visit_nested_body(&mut self, body_id: hir::BodyId) { - let owner_def_id = self.tcx.hir.body_owner_def_id(body_id); - let body = self.tcx.hir.body(body_id); + let owner_def_id = self.tcx.hir().body_owner_def_id(body_id); + let body = self.tcx.hir().body(body_id); let param_env = self.tcx.param_env(owner_def_id); let tables = self.tcx.typeck_tables_of(owner_def_id); ExprVisitor { tcx: self.tcx, param_env, tables }.visit_body(body); diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index e7a8baf738395..f0f8124c076f6 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -108,7 +108,7 @@ impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> { match self.item_refs.get(&*value.as_str()).cloned() { // Known lang item with attribute on correct target. Some((item_index, expected_target)) if actual_target == expected_target => { - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); self.collect_item(item_index, def_id); }, // Known lang item with attribute on incorrect target. @@ -171,7 +171,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { if let Some(original_def_id) = self.items.items[item_index] { if original_def_id != item_def_id { let name = LangItem::from_u32(item_index as u32).unwrap().name(); - let mut err = match self.tcx.hir.span_if_local(item_def_id) { + let mut err = match self.tcx.hir().span_if_local(item_def_id) { Some(span) => struct_span_err!( self.tcx.sess, span, @@ -183,7 +183,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { self.tcx.crate_name(item_def_id.krate), name)), }; - if let Some(span) = self.tcx.hir.span_if_local(original_def_id) { + if let Some(span) = self.tcx.hir().span_if_local(original_def_id) { span_note!(&mut err, span, "first defined here."); } else { err.note(&format!("first defined in crate `{}`.", @@ -221,7 +221,7 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItems { collector.collect_item(item_index, def_id); } } - tcx.hir.krate().visit_all_item_likes(&mut collector); + tcx.hir().krate().visit_all_item_likes(&mut collector); let LanguageItemCollector { mut items, .. } = collector; weak_lang_items::check_crate(tcx, &mut items); items diff --git a/src/librustc/middle/lib_features.rs b/src/librustc/middle/lib_features.rs index 7d65d412e01d7..a33ef10a27b76 100644 --- a/src/librustc/middle/lib_features.rs +++ b/src/librustc/middle/lib_features.rs @@ -140,7 +140,7 @@ impl<'a, 'tcx> LibFeatureCollector<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::All(&self.tcx.hir) + NestedVisitorMap::All(&self.tcx.hir()) } fn visit_attribute(&mut self, attr: &'tcx Attribute) { @@ -152,6 +152,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LibFeatureCollector<'a, 'tcx> { pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LibFeatures { let mut collector = LibFeatureCollector::new(tcx); - intravisit::walk_crate(&mut collector, tcx.hir.krate()); + intravisit::walk_crate(&mut collector, tcx.hir().krate()); collector.lib_features } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index b846a1c4930fb..b7cea975e0a22 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -176,7 +176,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_, '_, '_>) -> Strin impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl, @@ -190,7 +190,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> { } pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - tcx.hir.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(); } @@ -362,8 +362,8 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>, // Don't run unused pass for #[derive()] if let FnKind::Method(..) = fk { - let parent = ir.tcx.hir.get_parent(id); - if let Some(Node::Item(i)) = ir.tcx.hir.find(parent) { + let parent = ir.tcx.hir().get_parent(id); + if let Some(Node::Item(i)) = ir.tcx.hir().find(parent) { if i.attrs.iter().any(|a| a.check_name("automatically_derived")) { return; } @@ -372,7 +372,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.hir.body(body_id); + let body = ir.tcx.hir().body(body_id); for arg in &body.arguments { arg.pat.each_binding(|_bm, hir_id, _x, ident| { @@ -476,7 +476,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { call_caps.extend(freevars.iter().filter_map(|fv| { if let Def::Local(rv) = fv.def { let fv_ln = ir.add_live_node(FreeVarNode(fv.span)); - let var_hid = ir.tcx.hir.node_to_hir_id(rv); + let var_hid = ir.tcx.hir().node_to_hir_id(rv); Some(CaptureInfo { ln: fv_ln, var_hid }) } else { None @@ -924,7 +924,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.hir.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; @@ -1021,7 +1021,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.hir.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 @@ -1035,7 +1035,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { hir::ExprKind::Closure(.., blk_id, _, _) => { debug!("{} is an ExprKind::Closure", - self.ir.tcx.hir.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 // loop. The next-node for a continue is the top of this loop. @@ -1356,7 +1356,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let ln = self.live_node(hir_id, span); if acc != 0 { self.init_from_succ(ln, succ); - let var_hid = self.ir.tcx.hir.node_to_hir_id(nid); + let var_hid = self.ir.tcx.hir().node_to_hir_id(nid); let var = self.variable(var_hid, span); self.acc(ln, var, acc); } @@ -1413,7 +1413,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } debug!("propagate_through_loop: using id for loop body {} {}", - expr.id, self.ir.tcx.hir.node_to_pretty_string(body.id)); + expr.id, self.ir.tcx.hir().node_to_pretty_string(body.id)); let break_ln = succ; let cont_ln = ln; @@ -1547,7 +1547,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { // mutable, then check for a reassignment to flag the mutability // as being used. let ln = self.live_node(expr.hir_id, expr.span); - let var_hid = self.ir.tcx.hir.node_to_hir_id(nid); + let var_hid = self.ir.tcx.hir().node_to_hir_id(nid); let var = self.variable(var_hid, expr.span); self.warn_about_dead_assign(expr.span, expr.hir_id, ln, var); } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index cadf0c42d228f..c8fd75a6ec9d8 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -348,7 +348,7 @@ impl MutabilityCategory { fn from_local(tcx: TyCtxt<'_, '_, '_>, tables: &ty::TypeckTables<'_>, id: ast::NodeId) -> MutabilityCategory { - let ret = match tcx.hir.get(id) { + let ret = match tcx.hir().get(id) { Node::Binding(p) => match p.node { PatKind::Binding(..) => { let bm = *tables.pat_binding_modes() @@ -362,7 +362,7 @@ impl MutabilityCategory { } _ => span_bug!(p.span, "expected identifier pattern") }, - _ => span_bug!(tcx.hir.span(id), "expected identifier pattern") + _ => span_bug!(tcx.hir().span(id), "expected identifier pattern") }; debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}", "from_local", id, ret); @@ -495,9 +495,9 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { // FIXME None if self.is_tainted_by_errors() => Err(()), None => { - let id = self.tcx.hir.hir_to_node_id(id); + let id = self.tcx.hir().hir_to_node_id(id); bug!("no type for node {}: {} in mem_categorization", - id, self.tcx.hir.node_to_string(id)); + id, self.tcx.hir().node_to_string(id)); } } } @@ -770,7 +770,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { fn_node_id: ast::NodeId) -> McResult> { - let fn_hir_id = self.tcx.hir.node_to_hir_id(fn_node_id); + let fn_hir_id = self.tcx.hir().node_to_hir_id(fn_node_id); // An upvar can have up to 3 components. We translate first to a // `Categorization::Upvar`, which is itself a fiction -- it represents the reference to the @@ -815,8 +815,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { ref t => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", t), }; - let closure_expr_def_id = self.tcx.hir.local_def_id(fn_node_id); - let var_hir_id = self.tcx.hir.node_to_hir_id(var_id); + let closure_expr_def_id = self.tcx.hir().local_def_id(fn_node_id); + let var_hir_id = self.tcx.hir().node_to_hir_id(var_id); let upvar_id = ty::UpvarId { var_path: ty::UpvarPath { hir_id: var_hir_id }, closure_expr_id: closure_expr_def_id.to_local(), @@ -1504,7 +1504,7 @@ impl<'tcx> cmt_<'tcx> { "non-place".into() } Categorization::Local(vid) => { - if tcx.hir.is_argument(vid) { + if tcx.hir().is_argument(vid) { "argument" } else { "local variable" diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index ab0094df0e219..89814dde2623e 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -47,7 +47,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>, match item.node { hir::ItemKind::Impl(..) | hir::ItemKind::Fn(..) => { - let generics = tcx.generics_of(tcx.hir.local_def_id(item.id)); + let generics = tcx.generics_of(tcx.hir().local_def_id(item.id)); generics.requires_monomorphization(tcx) } _ => false, @@ -58,12 +58,12 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item: &hir::ImplItem, impl_src: DefId) -> bool { let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id()); - let generics = tcx.generics_of(tcx.hir.local_def_id(impl_item.id)); + let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.id)); if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) { return true } - if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) { - match tcx.hir.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(Node::Item(item)) => item_might_be_inlined(tcx, &item, codegen_fn_attrs), Some(..) | None => @@ -96,7 +96,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.hir.body(body); + let body = self.tcx.hir().body(body); self.visit_body(body); self.tables = old_tables; } @@ -118,7 +118,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> { } Some(def) => { if let Some((node_id, def_id)) = def.opt_def_id().and_then(|def_id| { - self.tcx.hir.as_local_node_id(def_id).map(|node_id| (node_id, def_id)) + self.tcx.hir().as_local_node_id(def_id).map(|node_id| (node_id, def_id)) }) { if self.def_id_represents_local_inlined_item(def_id) { self.worklist.push(node_id); @@ -151,12 +151,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.hir.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.hir.find(node_id) { + match self.tcx.hir().find(node_id) { Some(Node::Item(item)) => { match item.node { hir::ItemKind::Fn(..) => @@ -182,13 +182,13 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { true } else { let impl_did = self.tcx - .hir + .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.hir.as_local_node_id(impl_did).unwrap(); - match self.tcx.hir.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::ItemKind::Impl(..) => { let generics = self.tcx.generics_of(impl_did); generics.requires_monomorphization(self.tcx) @@ -214,7 +214,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { continue } - if let Some(ref item) = self.tcx.hir.find(search_item) { + if let Some(ref item) = self.tcx.hir().find(search_item) { self.propagate_node(item, search_item); } } @@ -231,7 +231,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } else { false }; - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); let codegen_attrs = self.tcx.codegen_fn_attrs(def_id); let is_extern = codegen_attrs.contains_extern_indicator(); let std_internal = codegen_attrs.flags.contains( @@ -252,7 +252,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { Node::Item(item) => { match item.node { hir::ItemKind::Fn(.., body) => { - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); if item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)) { @@ -305,7 +305,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { self.visit_nested_body(body); } hir::ImplItemKind::Method(_, body) => { - let did = self.tcx.hir.get_parent_did(search_item); + let did = self.tcx.hir().get_parent_did(search_item); if method_might_be_inlined(self.tcx, impl_item, did) { self.visit_nested_body(body) } @@ -326,7 +326,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { Node::MacroDef(_) => {} _ => { bug!("found unexpected thingy in worklist: {}", - self.tcx.hir.node_to_string(search_item)) + self.tcx.hir().node_to_string(search_item)) } } } @@ -351,7 +351,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, // Anything which has custom linkage gets thrown on the worklist no // matter where it is in the crate, along with "special std symbols" // which are currently akin to allocator symbols. - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); let codegen_attrs = self.tcx.codegen_fn_attrs(def_id); if codegen_attrs.contains_extern_indicator() || codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) { @@ -376,7 +376,7 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, self.worklist.reserve(provided_trait_methods.len()); for default_method in provided_trait_methods { let node_id = self.tcx - .hir + .hir() .as_local_node_id(default_method.def_id) .unwrap(); self.worklist.push(node_id); @@ -422,7 +422,7 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> reachable_context.worklist.extend(access_levels.map.iter().map(|(id, _)| *id)); for item in tcx.lang_items().items().iter() { if let Some(did) = *item { - if let Some(node_id) = tcx.hir.as_local_node_id(did) { + if let Some(node_id) = tcx.hir().as_local_node_id(did) { reachable_context.worklist.push(node_id); } } @@ -433,7 +433,7 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> access_levels, worklist: &mut reachable_context.worklist, }; - tcx.hir.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/region.rs b/src/librustc/middle/region.rs index 3c2551f5cd436..0a4ddf8b572fc 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -181,7 +181,7 @@ impl Scope { pub fn node_id(&self, tcx: TyCtxt<'_, '_, '_>, scope_tree: &ScopeTree) -> ast::NodeId { match scope_tree.root_body { Some(hir_id) => { - tcx.hir.hir_to_node_id(hir::HirId { + tcx.hir().hir_to_node_id(hir::HirId { owner: hir_id.owner, local_id: self.item_local_id() }) @@ -198,9 +198,9 @@ impl Scope { if node_id == ast::DUMMY_NODE_ID { return DUMMY_SP; } - let span = tcx.hir.span(node_id); + let span = tcx.hir().span(node_id); if let ScopeData::Remainder(first_statement_index) = self.data { - if let Node::Block(ref blk) = tcx.hir.get(node_id) { + if let Node::Block(ref blk) = tcx.hir().get(node_id) { // Want span for scope starting after the // indexed statement and ending at end of // `blk`; reuse span of `blk` and shift `lo` @@ -660,9 +660,9 @@ impl<'tcx> ScopeTree { -> Scope { let param_owner = tcx.parent_def_id(br.def_id).unwrap(); - let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap(); - let scope = tcx.hir.maybe_body_owned_by(param_owner_id).map(|body_id| { - tcx.hir.body(body_id).value.hir_id.local_id + let param_owner_id = tcx.hir().as_local_node_id(param_owner).unwrap(); + let scope = tcx.hir().maybe_body_owned_by(param_owner_id).map(|body_id| { + tcx.hir().body(body_id).value.hir_id.local_id }).unwrap_or_else(|| { // The lifetime was defined on node that doesn't own a body, // which in practice can only mean a trait or an impl, that @@ -671,7 +671,7 @@ impl<'tcx> ScopeTree { "free_scope: {:?} not recognized by the \ region scope tree for {:?} / {:?}", param_owner, - self.root_parent.map(|id| tcx.hir.local_def_id(id)), + self.root_parent.map(|id| tcx.hir().local_def_id(id)), self.root_body.map(|hir_id| DefId::local(hir_id.owner))); // The trait/impl lifetime is in scope for the method's body. @@ -696,9 +696,9 @@ impl<'tcx> ScopeTree { // on the same function that they ended up being freed in. assert_eq!(param_owner, fr.scope); - let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap(); - let body_id = tcx.hir.body_owned_by(param_owner_id); - Scope { id: tcx.hir.body(body_id).value.hir_id.local_id, data: ScopeData::CallSite } + let param_owner_id = tcx.hir().as_local_node_id(param_owner).unwrap(); + let body_id = tcx.hir().body_owned_by(param_owner_id); + Scope { id: tcx.hir().body(body_id).value.hir_id.local_id, data: ScopeData::CallSite } } /// Checks whether the given scope contains a `yield`. If so, @@ -845,7 +845,7 @@ fn resolve_pat<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, pat: & } fn resolve_stmt<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, stmt: &'tcx hir::Stmt) { - let stmt_id = visitor.tcx.hir.node_to_hir_id(stmt.node.id()).local_id; + let stmt_id = visitor.tcx.hir().node_to_hir_id(stmt.node.id()).local_id; debug!("resolve_stmt(stmt.id={:?})", stmt_id); // Every statement will clean up the temporaries created during @@ -942,7 +942,7 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr: // Manually recurse over closures, because they are the only // case of nested bodies that share the parent environment. hir::ExprKind::Closure(.., body, _, _) => { - let body = visitor.tcx.hir.body(body); + let body = visitor.tcx.hir().body(body); visitor.visit_body(body); } @@ -1244,7 +1244,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> { fn visit_body(&mut self, body: &'tcx hir::Body) { let body_id = body.id(); - let owner_id = self.tcx.hir.body_owner(body_id); + let owner_id = self.tcx.hir().body_owner(body_id); debug!("visit_body(id={:?}, span={:?}, body.id={:?}, cx.parent={:?})", owner_id, @@ -1273,7 +1273,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> { // The body of the every fn is a root scope. self.cx.parent = self.cx.var_parent; - if let hir::BodyOwnerKind::Fn = self.tcx.hir.body_owner_kind(owner_id) { + if let hir::BodyOwnerKind::Fn = self.tcx.hir().body_owner_kind(owner_id) { self.visit_expr(&body.value); } else { // Only functions have an outer terminating (drop) scope, while @@ -1333,8 +1333,8 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) return tcx.region_scope_tree(closure_base_def_id); } - let id = tcx.hir.as_local_node_id(def_id).unwrap(); - let scope_tree = if let Some(body_id) = tcx.hir.maybe_body_owned_by(id) { + let id = tcx.hir().as_local_node_id(def_id).unwrap(); + let scope_tree = if let Some(body_id) = tcx.hir().maybe_body_owned_by(id) { let mut visitor = RegionResolutionVisitor { tcx, scope_tree: ScopeTree::default(), @@ -1347,16 +1347,16 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) terminating_scopes: Default::default(), }; - let body = tcx.hir.body(body_id); + let body = tcx.hir().body(body_id); visitor.scope_tree.root_body = Some(body.value.hir_id); // If the item is an associated const or a method, // record its impl/trait parent, as it can also have // lifetime parameters free in this body. - match tcx.hir.get(id) { + match tcx.hir().get(id) { Node::ImplItem(_) | Node::TraitItem(_) => { - visitor.scope_tree.root_parent = Some(tcx.hir.get_parent(id)); + visitor.scope_tree.root_parent = Some(tcx.hir().get_parent(id)); } _ => {} } diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 07054ee99af76..54d8d169288d1 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -398,19 +398,19 @@ fn resolve_lifetimes<'tcx>( let mut rl = ResolveLifetimes::default(); for (k, v) in named_region_map.defs { - let hir_id = tcx.hir.node_to_hir_id(k); + let hir_id = tcx.hir().node_to_hir_id(k); let map = rl.defs.entry(hir_id.owner_local_def_id()).or_default(); Lrc::get_mut(map).unwrap().insert(hir_id.local_id, v); } for k in named_region_map.late_bound { - let hir_id = tcx.hir.node_to_hir_id(k); + let hir_id = tcx.hir().node_to_hir_id(k); let map = rl.late_bound .entry(hir_id.owner_local_def_id()) .or_default(); Lrc::get_mut(map).unwrap().insert(hir_id.local_id); } for (k, v) in named_region_map.object_lifetime_defaults { - let hir_id = tcx.hir.node_to_hir_id(k); + let hir_id = tcx.hir().node_to_hir_id(k); let map = rl.object_lifetime_defaults .entry(hir_id.owner_local_def_id()) .or_default(); @@ -423,7 +423,7 @@ fn resolve_lifetimes<'tcx>( } fn krate<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> NamedRegionMap { - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let mut map = NamedRegionMap { defs: Default::default(), late_bound: Default::default(), @@ -460,7 +460,7 @@ fn sub_items_have_self_param(node: &hir::ItemKind) -> bool { impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::All(&self.tcx.hir) + NestedVisitorMap::All(&self.tcx.hir()) } // We want to nest trait/impl items in their parent, but nothing else. @@ -469,7 +469,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_nested_body(&mut self, body: hir::BodyId) { // Each body has their own set of labels, save labels. let saved = replace(&mut self.labels_in_fn, vec![]); - let body = self.tcx.hir.body(body); + let body = self.tcx.hir().body(body); extract_labels(self, body); self.with( Scope::Body { @@ -545,7 +545,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { - Some(Region::early(&self.tcx.hir, &mut index, param)) + Some(Region::early(&self.tcx.hir(), &mut index, param)) } GenericParamKind::Type { .. } => { type_count += 1; @@ -596,7 +596,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { - Some(Region::late(&self.tcx.hir, param)) + Some(Region::late(&self.tcx.hir(), param)) } _ => None, }) @@ -655,7 +655,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // `abstract type MyAnonTy<'b>: MyTrait<'b>;` // ^ ^ this gets resolved in the scope of // the exist_ty generics - let (generics, bounds) = match self.tcx.hir.expect_item(item_id.id).node { + let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node { // named existential types are reached via TyKind::Path // this arm is for `impl Trait` in the types of statics, constants and locals hir::ItemKind::Existential(hir::ExistTy { @@ -689,12 +689,12 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { // In the future, this should be fixed and this error should be removed. let def = self.map.defs.get(&lifetime.id).cloned(); if let Some(Region::LateBound(_, def_id, _)) = def { - if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { + if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) { // Ensure that the parent of the def is an item, not HRTB - let parent_id = self.tcx.hir.get_parent_node(node_id); + let parent_id = self.tcx.hir().get_parent_node(node_id); let parent_impl_id = hir::ImplItemId { node_id: parent_id }; let parent_trait_id = hir::TraitItemId { node_id: parent_id }; - let krate = self.tcx.hir.forest.krate(); + let krate = self.tcx.hir().forest.krate(); if !(krate.items.contains_key(&parent_id) || krate.impl_items.contains_key(&parent_impl_id) || krate.trait_items.contains_key(&parent_trait_id)) @@ -724,7 +724,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { for param in &generics.params { match param.kind { GenericParamKind::Lifetime { .. } => { - let (name, reg) = Region::early(&self.tcx.hir, &mut index, ¶m); + let (name, reg) = Region::early(&self.tcx.hir(), &mut index, ¶m); if let hir::ParamName::Plain(param_name) = name { if param_name.name == keywords::UnderscoreLifetime.name() { // Pick the elided lifetime "definition" if one exists @@ -790,7 +790,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { Method(ref sig, _) => { let tcx = self.tcx; self.visit_early_late( - Some(tcx.hir.get_parent(trait_item.id)), + Some(tcx.hir().get_parent(trait_item.id)), &sig.decl, &trait_item.generics, |this| intravisit::walk_trait_item(this, trait_item), @@ -806,7 +806,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { - Some(Region::early(&self.tcx.hir, &mut index, param)) + Some(Region::early(&self.tcx.hir(), &mut index, param)) } GenericParamKind::Type { .. } => { type_count += 1; @@ -845,7 +845,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { Method(ref sig, _) => { let tcx = self.tcx; self.visit_early_late( - Some(tcx.hir.get_parent(impl_item.id)), + Some(tcx.hir().get_parent(impl_item.id)), &sig.decl, &impl_item.generics, |this| intravisit::walk_impl_item(this, impl_item), @@ -861,7 +861,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { - Some(Region::early(&self.tcx.hir, &mut index, param)) + Some(Region::early(&self.tcx.hir(), &mut index, param)) } GenericParamKind::Type { .. } => { next_early_index += 1; @@ -891,7 +891,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { - Some(Region::early(&self.tcx.hir, &mut index, param)) + Some(Region::early(&self.tcx.hir(), &mut index, param)) } GenericParamKind::Type { .. } => { next_early_index += 1; @@ -976,7 +976,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { - Some(Region::late(&self.tcx.hir, param)) + Some(Region::late(&self.tcx.hir(), param)) } _ => None, }) @@ -1051,7 +1051,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { - Some(Region::late(&self.tcx.hir, param)) + Some(Region::late(&self.tcx.hir(), param)) } _ => None, }) @@ -1258,12 +1258,12 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { } => { // FIXME (#24278): non-hygienic comparison if let Some(def) = lifetimes.get(&hir::ParamName::Plain(label.modern())) { - let node_id = tcx.hir.as_local_node_id(def.id().unwrap()).unwrap(); + let node_id = tcx.hir().as_local_node_id(def.id().unwrap()).unwrap(); signal_shadowing_problem( tcx, label.name, - original_lifetime(tcx.hir.span(node_id)), + original_lifetime(tcx.hir().span(node_id)), shadower_label(label.span), ); return; @@ -1279,7 +1279,7 @@ fn compute_object_lifetime_defaults( tcx: TyCtxt<'_, '_, '_>, ) -> NodeMap> { let mut map = NodeMap::default(); - for item in tcx.hir.krate().items.values() { + for item in tcx.hir().krate().items.values() { match item.node { hir::ItemKind::Struct(_, ref generics) | hir::ItemKind::Union(_, ref generics) @@ -1355,7 +1355,7 @@ fn object_lifetime_defaults_for_item( add_bounds(&mut set, ¶m.bounds); - let param_def_id = tcx.hir.local_def_id(param.id); + let param_def_id = tcx.hir().local_def_id(param.id); for predicate in &generics.where_clause.predicates { // Look for `type: ...` where clauses. let data = match *predicate { @@ -1399,7 +1399,7 @@ fn object_lifetime_defaults_for_item( .enumerate() .find(|&(_, (_, lt_name, _))| lt_name == name) .map_or(Set1::Many, |(i, (id, _, origin))| { - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); Set1::One(Region::EarlyBound(i as u32, def_id, origin)) }) } @@ -1492,7 +1492,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let name = lifetime.name.ident(); let mut remove_decl = None; if let Some(parent_def_id) = self.tcx.parent(def_id) { - if let Some(generics) = self.tcx.hir.get_generics(parent_def_id) { + if let Some(generics) = self.tcx.hir().get_generics(parent_def_id) { remove_decl = self.lifetime_deletion_span(name, generics); } } @@ -1513,8 +1513,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } }; - if let Node::Lifetime(hir_lifetime) = self.tcx.hir.get(lifetime.id) { - if let Some(parent) = self.tcx.hir.find(self.tcx.hir.get_parent(hir_lifetime.id)) { + if let Node::Lifetime(hir_lifetime) = self.tcx.hir().get(lifetime.id) { + if let Some(parent) = self.tcx.hir().find(self.tcx.hir().get_parent(hir_lifetime.id)) { match parent { Node::Item(item) => { if let hir::ItemKind::Fn(decl, _, _, _) = &item.node { @@ -1590,9 +1590,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { match lifetimeuseset { Some(LifetimeUseSet::One(lifetime)) => { - let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); + let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap(); debug!("node id first={:?}", node_id); - if let Some((id, span, name)) = match self.tcx.hir.get(node_id) { + if let Some((id, span, name)) = match self.tcx.hir().get(node_id) { Node::Lifetime(hir_lifetime) => Some(( hir_lifetime.id, hir_lifetime.span, @@ -1631,8 +1631,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { debug!("Not one use lifetime"); } None => { - let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); - if let Some((id, span, name)) = match self.tcx.hir.get(node_id) { + let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap(); + if let Some((id, span, name)) = match self.tcx.hir().get(node_id) { Node::Lifetime(hir_lifetime) => Some(( hir_lifetime.id, hir_lifetime.span, @@ -1651,7 +1651,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { &format!("lifetime parameter `{}` never used", name), ); if let Some(parent_def_id) = self.tcx.parent(def_id) { - if let Some(generics) = self.tcx.hir.get_generics(parent_def_id) { + if let Some(generics) = self.tcx.hir().get_generics(parent_def_id) { let unused_lt_span = self.lifetime_deletion_span(name, generics); if let Some(span) = unused_lt_span { err.span_suggestion_with_applicability( @@ -1702,7 +1702,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // Find the start of nested early scopes, e.g. in methods. let mut index = 0; if let Some(parent_id) = parent_id { - let parent = self.tcx.hir.expect_item(parent_id); + let parent = self.tcx.hir().expect_item(parent_id); if sub_items_have_self_param(&parent.node) { index += 1; // Self comes before lifetimes } @@ -1722,9 +1722,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { if self.map.late_bound.contains(¶m.id) { - Some(Region::late(&self.tcx.hir, param)) + Some(Region::late(&self.tcx.hir(), param)) } else { - Some(Region::early(&self.tcx.hir, &mut index, param)) + Some(Region::early(&self.tcx.hir(), &mut index, param)) } } GenericParamKind::Type { .. } => { @@ -1837,8 +1837,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { if let Region::EarlyBound(..) = def { // Do not free early-bound regions, only late-bound ones. } else if let Some(body_id) = outermost_body { - let fn_id = self.tcx.hir.body_owner(body_id); - match self.tcx.hir.get(fn_id) { + let fn_id = self.tcx.hir().body_owner(body_id); + match self.tcx.hir().get(fn_id) { Node::Item(&hir::Item { node: hir::ItemKind::Fn(..), .. @@ -1851,7 +1851,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { node: hir::ImplItemKind::Method(..), .. }) => { - let scope = self.tcx.hir.local_def_id(fn_id); + let scope = self.tcx.hir().local_def_id(fn_id); def = Region::Free(scope, def.id().unwrap()); } _ => {} @@ -1967,7 +1967,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { }; let map = &self.map; - let unsubst = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { + let unsubst = if let Some(id) = self.tcx.hir().as_local_node_id(def_id) { &map.object_lifetime_defaults[&id] } else { let tcx = self.tcx; @@ -2061,8 +2061,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { // and whether there's a `self` argument (treated specially). let mut assoc_item_kind = None; let mut impl_self = None; - let parent = self.tcx.hir.get_parent_node(output.id); - let body = match self.tcx.hir.get(parent) { + let parent = self.tcx.hir().get_parent_node(output.id); + let body = match self.tcx.hir().get(parent) { // `fn` definitions and methods. Node::Item(&hir::Item { node: hir::ItemKind::Fn(.., body), @@ -2074,8 +2074,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { .. }) => { if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx - .hir - .expect_item(self.tcx.hir.get_parent(parent)) + .hir() + .expect_item(self.tcx.hir().get_parent(parent)) .node { assoc_item_kind = trait_items @@ -2094,8 +2094,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { .. }) => { if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx - .hir - .expect_item(self.tcx.hir.get_parent(parent)) + .hir() + .expect_item(self.tcx.hir().get_parent(parent)) .node { impl_self = Some(self_ty); @@ -2396,8 +2396,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } = info; let help_name = if let Some(body) = parent { - let arg = &self.tcx.hir.body(body).arguments[index]; - format!("`{}`", self.tcx.hir.node_to_pretty_string(arg.pat.id)) + let arg = &self.tcx.hir().body(body).arguments[index]; + format!("`{}`", self.tcx.hir().node_to_pretty_string(arg.pat.id)) } else { format!("argument {}", index + 1) }; @@ -2603,12 +2603,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { ref lifetimes, s, .. } => { if let Some(&def) = lifetimes.get(¶m.name.modern()) { - let node_id = self.tcx.hir.as_local_node_id(def.id().unwrap()).unwrap(); + let node_id = self.tcx.hir().as_local_node_id(def.id().unwrap()).unwrap(); signal_shadowing_problem( self.tcx, param.name.ident().name, - original_lifetime(self.tcx.hir.span(node_id)), + original_lifetime(self.tcx.hir().span(node_id)), shadower_lifetime(¶m), ); return; @@ -2675,7 +2675,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { debug!( "insert_lifetime: {} resolved to {:?} span={:?}", - self.tcx.hir.node_to_string(lifetime_ref.id), + self.tcx.hir().node_to_string(lifetime_ref.id), def, self.tcx.sess.source_map().span_to_string(lifetime_ref.span) ); diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 543d1053b55e6..52a81d9a1c009 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -188,7 +188,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { } } - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); self.index.stab_map.insert(hir_id, stab); let orig_parent_stab = replace(&mut self.parent_stab, Some(stab)); @@ -198,7 +198,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 hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); self.index.stab_map.insert(hir_id, stab); } } @@ -219,7 +219,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { // -Zforce-unstable-if-unmarked is set. if let Some(stab) = self.parent_stab { if stab.level.is_unstable() { - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); self.index.stab_map.insert(hir_id, stab); } } @@ -230,7 +230,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { } // `Deprecation` is just two pointers, no need to intern it - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); let depr_entry = DeprecationEntry::local(depr, hir_id); self.index.depr_map.insert(hir_id, depr_entry.clone()); @@ -239,7 +239,7 @@ impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { visit_children(self); self.parent_depr = orig_parent_depr; } else if let Some(parent_depr) = self.parent_depr.clone() { - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); self.index.depr_map.insert(hir_id, parent_depr); visit_children(self); } else { @@ -254,7 +254,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.hir) + NestedVisitorMap::All(&self.tcx.hir()) } fn visit_item(&mut self, i: &'tcx Item) { @@ -333,7 +333,7 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> { impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> { fn check_missing_stability(&self, id: NodeId, span: Span) { - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); let stab = self.tcx.stability().local_stability(hir_id); let is_error = !self.tcx.sess.opts.test && stab.is_none() && @@ -346,7 +346,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.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_item(&mut self, i: &'tcx Item) { @@ -369,7 +369,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.hir.local_def_id(self.tcx.hir.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); } @@ -416,7 +416,7 @@ impl<'a, 'tcx> Index<'tcx> { index.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect(); { - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let mut annotator = Annotator { tcx, index: &mut index, @@ -470,7 +470,7 @@ impl<'a, 'tcx> Index<'tcx> { /// features and possibly prints errors. pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut checker = Checker { tcx }; - tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor()); + tcx.hir().krate().visit_all_item_likes(&mut checker.as_deep_visitor()); } /// Check whether an item marked with `deprecated(since="X")` is currently @@ -591,7 +591,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { false }; - let parent_def_id = self.hir.local_def_id(self.hir.get_parent(id)); + let parent_def_id = self.hir().local_def_id(self.hir().get_parent(id)); let skip = deprecated_in_future_version || self.lookup_deprecation_entry(parent_def_id) .map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry)); @@ -717,7 +717,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.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -726,7 +726,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // compiler-generated `extern crate` items have a dummy span. if item.span.is_dummy() { return } - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); let cnum = match self.tcx.extern_mod_stmt_cnum(def_id) { Some(cnum) => cnum, None => return, @@ -741,7 +741,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { hir::ItemKind::Impl(.., 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.hir.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.ident.name == impl_item.ident.name) .map(|item| item.def_id); @@ -756,7 +756,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { // There's no good place to insert stability check for non-Copy unions, // so semi-randomly perform it here in stability.rs hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => { - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); let adt_def = self.tcx.adt_def(def_id); let ty = self.tcx.type_of(def_id); @@ -780,7 +780,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { } fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) { - let id = self.tcx.hir.hir_to_node_id(id); + let id = self.tcx.hir().hir_to_node_id(id); if let Some(def_id) = path.def.opt_def_id() { self.tcx.check_stability(def_id, Some(id), path.span) } @@ -801,7 +801,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE); if tcx.stability().staged_api[&LOCAL_CRATE] { - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let mut missing = MissingStabilityAnnotations { tcx, access_levels, diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 0d407765c9e10..824ccda3dbd1a 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -49,7 +49,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, { let mut cx = Context { tcx, items }; - tcx.hir.krate().visit_all_item_likes(&mut cx.as_deep_visitor()); + tcx.hir().krate().visit_all_item_likes(&mut cx.as_deep_visitor()); } verify(tcx, items); } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 91663557409f2..d8a445e8582c7 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2376,17 +2376,17 @@ impl<'tcx> Debug for Rvalue<'tcx> { } AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| { - if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { + if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { let name = if tcx.sess.opts.debugging_opts.span_free_formats { format!("[closure@{:?}]", node_id) } else { - format!("[closure@{:?}]", tcx.hir.span(node_id)) + format!("[closure@{:?}]", tcx.hir().span(node_id)) }; let mut struct_fmt = fmt.debug_struct(&name); tcx.with_freevars(node_id, |freevars| { for (freevar, place) in freevars.iter().zip(places) { - let var_name = tcx.hir.name(freevar.var_id()); + let var_name = tcx.hir().name(freevar.var_id()); struct_fmt.field(&var_name.as_str(), place); } }); @@ -2398,13 +2398,13 @@ impl<'tcx> Debug for Rvalue<'tcx> { }), AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| { - if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { - let name = format!("[generator@{:?}]", tcx.hir.span(node_id)); + if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { + let name = format!("[generator@{:?}]", tcx.hir().span(node_id)); let mut struct_fmt = fmt.debug_struct(&name); tcx.with_freevars(node_id, |freevars| { for (freevar, place) in freevars.iter().zip(places) { - let var_name = tcx.hir.name(freevar.var_id()); + let var_name = tcx.hir().name(freevar.var_id()); struct_fmt.field(&var_name.as_str(), place); } struct_fmt.field("$state", &places[freevars.len()]); diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 7e97dc3c84a79..80634aa306674 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -580,7 +580,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg); - if let Some(trait_item_span) = self.tcx.hir.span_if_local(trait_item_def_id) { + if let Some(trait_item_span) = self.tcx.hir().span_if_local(trait_item_def_id) { let span = self.tcx.sess.source_map().def_span(trait_item_span); err.span_label(span, format!("definition of `{}` from trait", item_name)); } @@ -765,8 +765,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => { let found_kind = self.closure_kind(closure_def_id, closure_substs).unwrap(); let closure_span = self.tcx.sess.source_map() - .def_span(self.tcx.hir.span_if_local(closure_def_id).unwrap()); - let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap(); + .def_span(self.tcx.hir().span_if_local(closure_def_id).unwrap()); + let node_id = self.tcx.hir().as_local_node_id(closure_def_id).unwrap(); let mut err = struct_span_err!( self.tcx.sess, closure_span, E0525, "expected a closure that implements the `{}` trait, \ @@ -785,7 +785,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // a particular trait. if let Some(tables) = self.in_progress_tables { let tables = tables.borrow(); - let closure_hir_id = self.tcx.hir.node_to_hir_id(node_id); + let closure_hir_id = self.tcx.hir().node_to_hir_id(node_id); match (found_kind, tables.closure_kind_origins().get(closure_hir_id)) { (ty::ClosureKind::FnOnce, Some((span, name))) => { err.span_label(*span, format!( @@ -841,7 +841,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { }; let found_span = found_did.and_then(|did| - self.tcx.hir.span_if_local(did) + self.tcx.hir().span_if_local(did) ).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def let found = match found_trait_ref.skip_binder().substs.type_at(1).sty { @@ -862,7 +862,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { expected_trait_ref) } else { let (closure_span, found) = found_did - .and_then(|did| self.tcx.hir.get_if_local(did)) + .and_then(|did| self.tcx.hir().get_if_local(did)) .map(|node| { let (found_span, found) = self.get_fn_like_arguments(node); (Some(found_span), found) @@ -901,8 +901,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { code: &ObligationCauseCode<'tcx>, err: &mut DiagnosticBuilder<'tcx>) { if let &ObligationCauseCode::VariableType(node_id) = code { - let parent_node = self.tcx.hir.get_parent_node(node_id); - if let Some(Node::Local(ref local)) = self.tcx.hir.find(parent_node) { + let parent_node = self.tcx.hir().get_parent_node(node_id); + if let Some(Node::Local(ref local)) = self.tcx.hir().find(parent_node) { if let Some(ref expr) = local.init { if let hir::ExprKind::Index(_, _) = expr.node { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) { @@ -976,7 +976,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { node: hir::ExprKind::Closure(_, ref _decl, id, span, _), .. }) => { - (self.tcx.sess.source_map().def_span(span), self.tcx.hir.body(id).arguments.iter() + (self.tcx.sess.source_map().def_span(span), self.tcx.hir().body(id).arguments.iter() .map(|arg| { if let hir::Pat { node: hir::PatKind::Tuple(args, _), @@ -1037,7 +1037,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ).collect::>()) } Node::StructCtor(ref variant_data) => { - (self.tcx.sess.source_map().def_span(self.tcx.hir.span(variant_data.id())), + (self.tcx.sess.source_map().def_span(self.tcx.hir().span(variant_data.id())), vec![ArgKind::empty(); variant_data.fields().len()]) } _ => panic!("non-FnLike node found: {:?}", node), @@ -1236,7 +1236,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { -> DiagnosticBuilder<'tcx> { assert!(type_def_id.is_local()); - let span = self.hir.span_if_local(type_def_id).unwrap(); + let span = self.hir().span_if_local(type_def_id).unwrap(); let span = self.sess.source_map().def_span(span); let mut err = struct_span_err!(self.sess, span, E0072, "recursive type `{}` has infinite size", @@ -1482,7 +1482,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let item_name = tcx.item_path_str(item_def_id); let msg = format!("required by `{}`", item_name); - if let Some(sp) = tcx.hir.span_if_local(item_def_id) { + if let Some(sp) = tcx.hir().span_if_local(item_def_id) { let sp = tcx.sess.source_map().def_span(sp); err.span_note(sp, &msg); } else { diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index cb17246b15f11..50d2179c412aa 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -337,7 +337,7 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx let mut err = if used_to_be_allowed { tcx.struct_span_lint_node( lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS, - tcx.hir.as_local_node_id(impl_def_id).unwrap(), + tcx.hir().as_local_node_id(impl_def_id).unwrap(), impl_span, &msg) } else { diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 3a882506b41d6..6d3fc0d4fe405 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -535,9 +535,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn impl_is_default(self, node_item_def_id: DefId) -> bool { - match self.hir.as_local_node_id(node_item_def_id) { + match self.hir().as_local_node_id(node_item_def_id) { Some(node_id) => { - let item = self.hir.expect_item(node_id); + let item = self.hir().expect_item(node_id); if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node { defaultness.is_default() } else { diff --git a/src/librustc/ty/constness.rs b/src/librustc/ty/constness.rs index bc06167399533..3741f4051b896 100644 --- a/src/librustc/ty/constness.rs +++ b/src/librustc/ty/constness.rs @@ -67,10 +67,10 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { /// only checks whether the function has a `const` modifier fn is_const_fn_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { - let node_id = tcx.hir.as_local_node_id(def_id) + let node_id = tcx.hir().as_local_node_id(def_id) .expect("Non-local call to local provider is_const_fn"); - if let Some(fn_like) = FnLikeNode::from_node(tcx.hir.get(node_id)) { + if let Some(fn_like) = FnLikeNode::from_node(tcx.hir().get(node_id)) { fn_like.constness() == hir::Constness::Const } else { false diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index f041192413107..fd406b1380572 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -250,11 +250,11 @@ fn validate_hir_id_for_typeck_tables(local_id_root: Option, if let Some(local_id_root) = local_id_root { if hir_id.owner != local_id_root.index { ty::tls::with(|tcx| { - let node_id = tcx.hir.hir_to_node_id(hir_id); + let node_id = tcx.hir().hir_to_node_id(hir_id); bug!("node {} with HirId::owner {:?} cannot be placed in \ TypeckTables with local_id_root {:?}", - tcx.hir.node_to_string(node_id), + tcx.hir().node_to_string(node_id), DefId::local(hir_id.owner), local_id_root) }); @@ -530,8 +530,8 @@ impl<'tcx> TypeckTables<'tcx> { self.node_id_to_type_opt(id).unwrap_or_else(|| bug!("node_id_to_type: no type for node `{}`", tls::with(|tcx| { - let id = tcx.hir.hir_to_node_id(id); - tcx.hir.node_to_string(id) + let id = tcx.hir().hir_to_node_id(id); + tcx.hir().node_to_string(id) })) ) } @@ -903,7 +903,7 @@ pub struct GlobalCtxt<'tcx> { /// Export map produced by name resolution. export_map: FxHashMap>>, - pub hir: hir_map::Map<'tcx>, + hir_map: hir_map::Map<'tcx>, /// A map from DefPathHash -> DefId. Includes DefIds from the local crate /// as well as all upstream crates. Only populated in incremental mode. @@ -971,6 +971,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } + #[inline(always)] + pub fn hir(self) -> &'a hir_map::Map<'gcx> { + &self.hir_map + } + pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics { self.global_arenas.generics.alloc(generics) } @@ -1186,7 +1191,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { .map(|(id, sp)| (hir.local_def_id(id), sp)) .collect(), extern_prelude: resolutions.extern_prelude, - hir, + hir_map: hir, def_path_hash_to_def_id, queries: query::Queries::new( providers, @@ -1272,7 +1277,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn def_key(self, id: DefId) -> hir_map::DefKey { if id.is_local() { - self.hir.def_key(id) + self.hir().def_key(id) } else { self.cstore.def_key(id) } @@ -1285,7 +1290,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// be a non-local `DefPath`. pub fn def_path(self, id: DefId) -> hir_map::DefPath { if id.is_local() { - self.hir.def_path(id) + self.hir().def_path(id) } else { self.cstore.def_path(id) } @@ -1294,7 +1299,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { #[inline] pub fn def_path_hash(self, def_id: DefId) -> hir_map::DefPathHash { if def_id.is_local() { - self.hir.definitions().def_path_hash(def_id.index) + self.hir().definitions().def_path_hash(def_id.index) } else { self.cstore.def_path_hash(def_id) } @@ -1332,11 +1337,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn create_stable_hashing_context(self) -> StableHashingContext<'a> { - let krate = self.dep_graph.with_ignore(|| self.gcx.hir.krate()); + let krate = self.dep_graph.with_ignore(|| self.hir().krate()); StableHashingContext::new(self.sess, krate, - self.hir.definitions(), + self.hir().definitions(), self.cstore) } @@ -1524,10 +1529,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { _ => return None, // not a free region }; - let node_id = self.hir + let node_id = self.hir() .as_local_node_id(suitable_region_binding_scope) .unwrap(); - let is_impl_item = match self.hir.find(node_id) { + let is_impl_item = match self.hir().find(node_id) { Some(Node::Item(..)) | Some(Node::TraitItem(..)) => false, Some(Node::ImplItem(..)) => { self.is_bound_region_in_impl_item(suitable_region_binding_scope) @@ -1547,8 +1552,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { scope_def_id: DefId, ) -> Option> { // HACK: `type_of_def_id()` will fail on these (#55796), so return None - let node_id = self.hir.as_local_node_id(scope_def_id).unwrap(); - match self.hir.get(node_id) { + let node_id = self.hir().as_local_node_id(scope_def_id).unwrap(); + match self.hir().get(node_id) { Node::Item(item) => { match item.node { ItemKind::Fn(..) => { /* type_of_def_id() will work */ } @@ -2895,11 +2900,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.dep_graph.with_ignore(|| { let sets = self.lint_levels(LOCAL_CRATE); loop { - let hir_id = self.hir.definitions().node_to_hir_id(id); + let hir_id = self.hir().definitions().node_to_hir_id(id); if let Some(pair) = sets.level_and_source(lint, hir_id, self.sess) { return pair } - let next = self.hir.get_parent_node(id); + let next = self.hir().get_parent_node(id); if next == id { bug!("lint traversal reached the root of the crate"); } @@ -2915,7 +2920,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { msg: &str) -> DiagnosticBuilder<'tcx> { - let node_id = self.hir.hir_to_node_id(hir_id); + let node_id = self.hir().hir_to_node_id(hir_id); let (level, src) = self.lint_level_at_node(lint, node_id); lint::struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg) } @@ -3039,16 +3044,16 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { }; providers.lookup_stability = |tcx, id| { assert_eq!(id.krate, LOCAL_CRATE); - let id = tcx.hir.definitions().def_index_to_hir_id(id.index); + let id = tcx.hir().definitions().def_index_to_hir_id(id.index); tcx.stability().local_stability(id) }; providers.lookup_deprecation_entry = |tcx, id| { assert_eq!(id.krate, LOCAL_CRATE); - let id = tcx.hir.definitions().def_index_to_hir_id(id.index); + let id = tcx.hir().definitions().def_index_to_hir_id(id.index); tcx.stability().local_deprecation_entry(id) }; providers.extern_mod_stmt_cnum = |tcx, id| { - let id = tcx.hir.as_local_node_id(id).unwrap(); + let id = tcx.hir().as_local_node_id(id).unwrap(); tcx.cstore.extern_mod_stmt_cnum_untracked(id) }; providers.all_crate_nums = |tcx, cnum| { @@ -3069,10 +3074,10 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { }; providers.is_panic_runtime = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); - attr::contains_name(tcx.hir.krate_attrs(), "panic_runtime") + attr::contains_name(tcx.hir().krate_attrs(), "panic_runtime") }; providers.is_compiler_builtins = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); - attr::contains_name(tcx.hir.krate_attrs(), "compiler_builtins") + attr::contains_name(tcx.hir().krate_attrs(), "compiler_builtins") }; } diff --git a/src/librustc/ty/inhabitedness/def_id_forest.rs b/src/librustc/ty/inhabitedness/def_id_forest.rs index 7bc77e1b1a140..163263babf899 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.hir.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 350e55288ea10..e24f9094dd2f5 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -83,7 +83,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.hir.local_def_id(id)) + self.item_path_str(self.hir().local_def_id(id)) } /// Returns a string identifying this def-id. This string is @@ -464,8 +464,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, pushed_prelude_crate); - let node_id = self.hir.as_local_node_id(impl_def_id).unwrap(); - let item = self.hir.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.source_map().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 4633ab1166347..7c819941173d7 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -289,7 +289,7 @@ impl Visibility { def => Visibility::Restricted(def.def_id()), }, hir::VisibilityKind::Inherited => { - Visibility::Restricted(tcx.hir.get_module_parent(id)) + Visibility::Restricted(tcx.hir().get_module_parent(id)) } } } @@ -2619,29 +2619,29 @@ impl<'gcx> ::std::ops::Deref for Attributes<'gcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn body_tables(self, body: hir::BodyId) -> &'gcx TypeckTables<'gcx> { - self.typeck_tables_of(self.hir.body_owner_def_id(body)) + self.typeck_tables_of(self.hir().body_owner_def_id(body)) } /// Returns an iterator of the def-ids for all body-owners in this /// crate. If you would prefer to iterate over the bodies - /// themselves, you can do `self.hir.krate().body_ids.iter()`. + /// themselves, you can do `self.hir().krate().body_ids.iter()`. pub fn body_owners( self, ) -> impl Iterator + Captures<'tcx> + Captures<'gcx> + 'a { - self.hir.krate() - .body_ids - .iter() - .map(move |&body_id| self.hir.body_owner_def_id(body_id)) + self.hir().krate() + .body_ids + .iter() + .map(move |&body_id| self.hir().body_owner_def_id(body_id)) } pub fn par_body_owners(self, f: F) { - par_iter(&self.hir.krate().body_ids).for_each(|&body_id| { - f(self.hir.body_owner_def_id(body_id)) + par_iter(&self.hir().krate().body_ids).for_each(|&body_id| { + f(self.hir().body_owner_def_id(body_id)) }); } pub fn expr_span(self, id: NodeId) -> Span { - match self.hir.find(id) { + match self.hir().find(id) { Some(Node::Expr(e)) => { e.span } @@ -2667,8 +2667,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn opt_associated_item(self, def_id: DefId) -> Option { - let is_associated_item = if let Some(node_id) = self.hir.as_local_node_id(def_id) { - match self.hir.get(node_id) { + let is_associated_item = if let Some(node_id) = self.hir().as_local_node_id(def_id) { + match self.hir().get(node_id) { Node::TraitItem(_) | Node::ImplItem(_) => true, _ => false, } @@ -2691,7 +2691,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { parent_vis: &hir::Visibility, trait_item_ref: &hir::TraitItemRef) -> AssociatedItem { - let def_id = self.hir.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 } => { @@ -2717,7 +2717,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { parent_def_id: DefId, impl_item_ref: &hir::ImplItemRef) -> AssociatedItem { - let def_id = self.hir.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 } => { @@ -2740,7 +2740,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn field_index(self, node_id: NodeId, tables: &TypeckTables<'_>) -> usize { - let hir_id = self.hir.node_to_hir_id(node_id); + let hir_id = self.hir().node_to_hir_id(node_id); tables.field_indices().get(hir_id).cloned().expect("no index for a field") } @@ -2878,8 +2878,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Get the attributes of a definition. pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> { - if let Some(id) = self.hir.as_local_node_id(did) { - Attributes::Borrowed(self.hir.attrs(id)) + if let Some(id) = self.hir().as_local_node_id(did) { + Attributes::Borrowed(self.hir().attrs(id)) } else { Attributes::Owned(self.item_attrs(did)) } @@ -2930,8 +2930,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.hir.as_local_node_id(impl_did).unwrap(); - Ok(self.hir.span(node_id)) + let node_id = self.hir().as_local_node_id(impl_did).unwrap(); + Ok(self.hir().span(node_id)) } else { Err(self.crate_name(impl_did.krate)) } @@ -2947,14 +2947,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn adjust_ident(self, mut ident: Ident, scope: DefId, block: NodeId) -> (Ident, DefId) { ident = ident.modern(); let target_expansion = match scope.krate { - LOCAL_CRATE => self.hir.definitions().expansion_that_defined(scope.index), + LOCAL_CRATE => self.hir().definitions().expansion_that_defined(scope.index), _ => Mark::root(), }; let scope = match ident.span.adjust(target_expansion) { Some(actual_expansion) => - self.hir.definitions().parent_module_of_macro_def(actual_expansion), + self.hir().definitions().parent_module_of_macro_def(actual_expansion), None if block == DUMMY_NODE_ID => DefId::local(CRATE_DEF_INDEX), // Dummy DefId - None => self.hir.get_module_parent(block), + None => self.hir().get_module_parent(block), }; (ident, scope) } @@ -2980,7 +2980,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn with_freevars(self, fid: NodeId, f: F) -> T where F: FnOnce(&[hir::Freevar]) -> T, { - let def_id = self.hir.local_def_id(fid); + let def_id = self.hir().local_def_id(fid); match self.freevars(def_id) { None => f(&[]), Some(d) => f(&d), @@ -2989,10 +2989,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssociatedItem { - let id = tcx.hir.as_local_node_id(def_id).unwrap(); - let parent_id = tcx.hir.get_parent(id); - let parent_def_id = tcx.hir.local_def_id(parent_id); - let parent_item = tcx.hir.expect_item(parent_id); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); + let parent_id = tcx.hir().get_parent(id); + let parent_def_id = tcx.hir().local_def_id(parent_id); + let parent_item = tcx.hir().expect_item(parent_id); match parent_item.node { hir::ItemKind::Impl(.., ref impl_item_refs) => { if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.node_id == id) { @@ -3049,19 +3049,19 @@ fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Lrc> { - let id = tcx.hir.as_local_node_id(def_id).unwrap(); - let item = tcx.hir.expect_item(id); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); + let item = tcx.hir().expect_item(id); let vec: Vec<_> = match item.node { hir::ItemKind::Trait(.., ref trait_item_refs) => { trait_item_refs.iter() .map(|trait_item_ref| trait_item_ref.id) - .map(|id| tcx.hir.local_def_id(id.node_id)) + .map(|id| tcx.hir().local_def_id(id.node_id)) .collect() } hir::ItemKind::Impl(.., ref impl_item_refs) => { impl_item_refs.iter() .map(|impl_item_ref| impl_item_ref.id) - .map(|id| tcx.hir.local_def_id(id.node_id)) + .map(|id| tcx.hir().local_def_id(id.node_id)) .collect() } hir::ItemKind::TraitAlias(..) => vec![], @@ -3071,7 +3071,7 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } fn def_span<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Span { - tcx.hir.span_if_local(def_id).unwrap() + tcx.hir().span_if_local(def_id).unwrap() } /// If the given def ID describes an item belonging to a trait, @@ -3089,8 +3089,8 @@ fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option /// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition. pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option { - if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { - if let Node::Item(item) = tcx.hir.get(node_id) { + if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { + if let Node::Item(item) = tcx.hir().get(node_id) { if let hir::ItemKind::Existential(ref exist_ty) = item.node { return exist_ty.impl_trait_fn; } @@ -3101,8 +3101,8 @@ pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option, def_id: DefId) -> bool { - if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { - if let Node::Item(item) = tcx.hir.get(node_id) { + if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { + if let Node::Item(item) = tcx.hir().get(node_id) { if let hir::ItemKind::TraitAlias(..) = item.node { return true; } @@ -3140,8 +3140,8 @@ fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let unnormalized_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates), traits::Reveal::UserFacing); - let body_id = tcx.hir.as_local_node_id(def_id).map_or(DUMMY_NODE_ID, |id| { - tcx.hir.maybe_body_owned_by(id).map_or(id, |body| body.node_id) + let body_id = tcx.hir().as_local_node_id(def_id).map_or(DUMMY_NODE_ID, |id| { + tcx.hir().maybe_body_owned_by(id).map_or(id, |body| body.node_id) }); let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id); traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause) @@ -3163,7 +3163,7 @@ fn crate_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> Svh { assert_eq!(crate_num, LOCAL_CRATE); - tcx.hir.crate_hash + tcx.hir().crate_hash } fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index 5d12aaeed5f79..fd9143be679a4 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -227,9 +227,9 @@ impl<'tcx> QueryDescription<'tcx> for queries::erase_regions_ty<'tcx> { impl<'tcx> QueryDescription<'tcx> for queries::type_param_predicates<'tcx> { fn describe(tcx: TyCtxt<'_, '_, '_>, (_, def_id): (DefId, DefId)) -> Cow<'static, str> { - let id = tcx.hir.as_local_node_id(def_id).unwrap(); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); format!("computing the bounds for type parameter `{}`", - tcx.hir.ty_param_name(id)).into() + tcx.hir().ty_param_name(id)).into() } } diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 7d3ae64f4fcd6..04c880826fe79 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -725,7 +725,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder for CacheDecoder<'a, 'tcx, 'x> { #[inline] fn specialized_decode(&mut self) -> Result { let hir_id = hir::HirId::decode(self)?; - Ok(self.tcx().hir.hir_to_node_id(hir_id)) + Ok(self.tcx().hir().hir_to_node_id(hir_id)) } } @@ -926,7 +926,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder for CacheEncoder<'enc, 'a local_id, } = *id; - let def_path_hash = self.tcx.hir.definitions().def_path_hash(owner); + let def_path_hash = self.tcx.hir().definitions().def_path_hash(owner); def_path_hash.encode(self)?; local_id.encode(self) @@ -968,7 +968,7 @@ impl<'enc, 'a, 'tcx, E> SpecializedEncoder for CacheEncoder<'enc, 'a, 't { #[inline] fn specialized_encode(&mut self, node_id: &NodeId) -> Result<(), Self::Error> { - let hir_id = self.tcx.hir.node_to_hir_id(*node_id); + let hir_id = self.tcx.hir().node_to_hir_id(*node_id); hir_id.encode(self) } } diff --git a/src/librustc/ty/trait_def.rs b/src/librustc/ty/trait_def.rs index af678c3e9924b..fadb1a1cf6ee6 100644 --- a/src/librustc/ty/trait_def.rs +++ b/src/librustc/ty/trait_def.rs @@ -189,8 +189,8 @@ pub(super) fn trait_impls_of_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } - for &node_id in tcx.hir.trait_impls(trait_id) { - add_impl(tcx.hir.local_def_id(node_id)); + for &node_id in tcx.hir().trait_impls(trait_id) { + add_impl(tcx.hir().local_def_id(node_id)); } } diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 51b197d7b990b..2b9bd91e48a6c 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -601,7 +601,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Return whether the node pointed to by def_id is a static item, and its mutability pub fn is_static(&self, def_id: DefId) -> Option { - if let Some(node) = self.hir.get_if_local(def_id) { + if let Some(node) = self.hir().get_if_local(def_id) { match node { Node::Item(&hir::Item { node: hir::ItemKind::Static(_, mutbl, _), .. @@ -711,7 +711,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { // Find non representable fields with their spans fold_repr(def.all_fields().map(|field| { let ty = field.ty(tcx, substs); - let span = tcx.hir.span_if_local(field.did).unwrap_or(sp); + let span = tcx.hir().span_if_local(field.did).unwrap_or(sp); match is_type_structurally_recursive(tcx, span, seen, representable_cache, ty) { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index eea3b54919d52..e248f6b42bea2 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -523,7 +523,7 @@ impl PrintContext { } }; let _ = write!(f, "{}", name); - ty::BrNamed(tcx.hir.local_def_id(CRATE_NODE_ID), name) + ty::BrNamed(tcx.hir().local_def_id(CRATE_NODE_ID), name) } }; tcx.mk_region(ty::ReLateBound(ty::INNERMOST, br)) @@ -679,7 +679,7 @@ impl fmt::Debug for ty::UpvarId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "UpvarId({:?};`{}`;{:?})", self.var_path.hir_id, - ty::tls::with(|tcx| tcx.hir.name(tcx.hir.hir_to_node_id(self.var_path.hir_id))), + ty::tls::with(|tcx| tcx.hir().name(tcx.hir().hir_to_node_id(self.var_path.hir_id))), self.closure_expr_id) } } @@ -1208,15 +1208,15 @@ define_print! { write!(f, "[static generator")?; } - if let Some(node_id) = tcx.hir.as_local_node_id(did) { - write!(f, "@{:?}", tcx.hir.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) { print!(f, cx, write("{}{}:", sep, - tcx.hir.name(freevar.var_id())), + tcx.hir().name(freevar.var_id())), print(upvar_ty))?; sep = ", "; } @@ -1244,11 +1244,11 @@ define_print! { let upvar_tys = substs.upvar_tys(did, tcx); write!(f, "[closure")?; - if let Some(node_id) = tcx.hir.as_local_node_id(did) { + if let Some(node_id) = tcx.hir().as_local_node_id(did) { if tcx.sess.opts.debugging_opts.span_free_formats { write!(f, "@{:?}", node_id)?; } else { - write!(f, "@{:?}", tcx.hir.span(node_id))?; + write!(f, "@{:?}", tcx.hir().span(node_id))?; } let mut sep = " "; tcx.with_freevars(node_id, |freevars| { @@ -1256,7 +1256,7 @@ define_print! { print!(f, cx, write("{}{}:", sep, - tcx.hir.name(freevar.var_id())), + tcx.hir().name(freevar.var_id())), print(upvar_ty))?; sep = ", "; } diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index e47e95afb1643..51afb43d973b7 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -105,7 +105,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { debug!("consume(consume_id={}, cmt={:?}, mode={:?})", consume_id, cmt, mode); - let hir_id = self.tcx().hir.node_to_hir_id(consume_id); + let hir_id = self.tcx().hir().node_to_hir_id(consume_id); self.consume_common(hir_id.local_id, consume_span, cmt, mode); } @@ -139,7 +139,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { borrow_id, cmt, loan_region, bk, loan_cause); - let hir_id = self.tcx().hir.node_to_hir_id(borrow_id); + let hir_id = self.tcx().hir().node_to_hir_id(borrow_id); if let Some(lp) = opt_loan_path(cmt) { let moved_value_use_kind = match loan_cause { euv::ClosureCapture(_) => MovedInCapture, @@ -185,7 +185,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { } } } - self.check_assignment(self.tcx().hir.node_to_hir_id(assignment_id).local_id, + self.check_assignment(self.tcx().hir().node_to_hir_id(assignment_id).local_id, assignment_span, assignee_cmt); } @@ -199,10 +199,10 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, body: &hir::Body) { debug!("check_loans(body id={})", body.value.id); - let def_id = bccx.tcx.hir.body_owner_def_id(body.id()); + let def_id = bccx.tcx.hir().body_owner_def_id(body.id()); - let node_id = bccx.tcx.hir.as_local_node_id(def_id).unwrap(); - let movable_generator = !match bccx.tcx.hir.get(node_id) { + let node_id = bccx.tcx.hir().as_local_node_id(def_id).unwrap(); + let movable_generator = !match bccx.tcx.hir().get(node_id) { Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), .. @@ -907,7 +907,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { let lp = opt_loan_path(assignee_cmt).unwrap(); self.move_data.each_assignment_of(assignment_id, &lp, |assign| { if assignee_cmt.mutbl.is_mutable() { - let hir_id = self.bccx.tcx.hir.node_to_hir_id(local_id); + let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id); self.bccx.used_mut_nodes.borrow_mut().insert(hir_id); } else { self.bccx.report_reassigned_immutable_variable( diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index 7bb5f411752fe..9fa541cdd07b4 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -57,9 +57,9 @@ pub enum PatternSource<'tcx> { /// with a reference to the let fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> PatternSource<'tcx> { - let parent = tcx.hir.get_parent_node(pat.id); + let parent = tcx.hir().get_parent_node(pat.id); - match tcx.hir.get(parent) { + match tcx.hir().get(parent) { Node::Expr(ref e) => { // the enclosing expression must be a `match` or something else assert!(match e.node { @@ -79,7 +79,7 @@ pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, var_id: ast::NodeId, var_ty: Ty<'tcx>) { let loan_path = Rc::new(LoanPath::new(LpVar(var_id), var_ty)); - let hir_id = bccx.tcx.hir.node_to_hir_id(var_id); + let hir_id = bccx.tcx.hir().node_to_hir_id(var_id); move_data.add_move(bccx.tcx, loan_path, hir_id.local_id, Declared); } diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index 6ef5d65d10dca..ccc091a6a1ce6 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -114,7 +114,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { self.bccx.tcx.mk_region(ty::ReScope(self.item_scope)) } Categorization::Local(local_id) => { - let hir_id = self.bccx.tcx.hir.node_to_hir_id(local_id); + let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id); self.bccx.tcx.mk_region(ty::ReScope( self.bccx.region_scope_tree.var_scope(hir_id.local_id))) } diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 21fb0cdf90ad1..1a9672aa6ce5e 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -38,13 +38,13 @@ mod move_error; pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, body: hir::BodyId) -> (Vec>, move_data::MoveData<'tcx>) { - let def_id = bccx.tcx.hir.body_owner_def_id(body); + let def_id = bccx.tcx.hir().body_owner_def_id(body); let param_env = bccx.tcx.param_env(def_id); let mut glcx = GatherLoanCtxt { bccx, all_loans: Vec::new(), item_ub: region::Scope { - id: bccx.tcx.hir.body(body).value.hir_id.local_id, + id: bccx.tcx.hir().body(body).value.hir_id.local_id, data: region::ScopeData::Node }, move_data: MoveData::default(), @@ -88,7 +88,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { euv::Move(move_reason) => { gather_moves::gather_move_from_expr( self.bccx, &self.move_data, &mut self.move_error_collector, - self.bccx.tcx.hir.node_to_hir_id(consume_id).local_id, cmt, move_reason); + self.bccx.tcx.hir().node_to_hir_id(consume_id).local_id, cmt, move_reason); } euv::Copy => { } } @@ -135,7 +135,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { bk={:?}, loan_cause={:?})", borrow_id, cmt, loan_region, bk, loan_cause); - let hir_id = self.bccx.tcx.hir.node_to_hir_id(borrow_id); + let hir_id = self.bccx.tcx.hir().node_to_hir_id(borrow_id); self.guarantee_valid(hir_id.local_id, borrow_span, cmt, @@ -158,7 +158,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { fn decl_without_init(&mut self, id: ast::NodeId, _span: Span) { let ty = self.bccx .tables - .node_id_to_type(self.bccx.tcx.hir.node_to_hir_id(id)); + .node_id_to_type(self.bccx.tcx.hir().node_to_hir_id(id)); gather_moves::gather_decl(self.bccx, &self.move_data, id, ty); } } @@ -280,7 +280,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { self.mark_loan_path_as_mutated(&lp); } gather_moves::gather_assignment(self.bccx, &self.move_data, - self.bccx.tcx.hir.node_to_hir_id(assignment_id) + self.bccx.tcx.hir().node_to_hir_id(assignment_id) .local_id, assignment_span, lp); @@ -448,7 +448,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { wrapped_path = match current_path.kind { LpVar(local_id) => { if !through_borrow { - let hir_id = self.bccx.tcx.hir.node_to_hir_id(local_id); + let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id); self.bccx.used_mut_nodes.borrow_mut().insert(hir_id); } None diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index cfd530b7e3d09..08c5b247b2f65 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -97,8 +97,8 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveErr } } if let NoteClosureEnv(upvar_id) = error.move_from.note { - let var_node_id = bccx.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id); - err.span_label(bccx.tcx.hir.span(var_node_id), + let var_node_id = bccx.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id); + err.span_label(bccx.tcx.hir().span(var_node_id), "captured outer variable"); } err.emit(); diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index d189460d08848..3a0d252137c22 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -93,9 +93,9 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) debug!("borrowck(body_owner_def_id={:?})", owner_def_id); - let owner_id = tcx.hir.as_local_node_id(owner_def_id).unwrap(); + let owner_id = tcx.hir().as_local_node_id(owner_def_id).unwrap(); - match tcx.hir.get(owner_id) { + match tcx.hir().get(owner_id) { Node::StructCtor(_) | Node::Variant(_) => { // We get invoked with anything that has MIR, but some of @@ -110,10 +110,10 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) _ => { } } - let body_id = tcx.hir.body_owned_by(owner_id); + let body_id = tcx.hir().body_owned_by(owner_id); let tables = tcx.typeck_tables_of(owner_def_id); let region_scope_tree = tcx.region_scope_tree(owner_def_id); - let body = tcx.hir.body(body_id); + let body = tcx.hir().body(body_id); let mut bccx = BorrowckCtxt { tcx, tables, @@ -169,7 +169,7 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc // Check the body of fn items. let tcx = this.tcx; let id_range = { - let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.hir); + let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.hir()); visitor.visit_body(this.body); visitor.result() }; @@ -224,11 +224,11 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>( cfg: &cfg::CFG) -> (BorrowckCtxt<'a, 'tcx>, AnalysisData<'a, 'tcx>) { - let owner_id = tcx.hir.body_owner(body_id); - let owner_def_id = tcx.hir.local_def_id(owner_id); + let owner_id = tcx.hir().body_owner(body_id); + let owner_def_id = tcx.hir().local_def_id(owner_id); let tables = tcx.typeck_tables_of(owner_def_id); let region_scope_tree = tcx.region_scope_tree(owner_def_id); - let body = tcx.hir.body(body_id); + let body = tcx.hir().body(body_id); let mut bccx = BorrowckCtxt { tcx, tables, @@ -418,8 +418,8 @@ pub enum LoanPathElem<'tcx> { fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt) -> ast::NodeId { - let closure_id = tcx.hir.local_def_id_to_node_id(closure_id); - match tcx.hir.get(closure_id) { + let closure_id = tcx.hir().local_def_id_to_node_id(closure_id); + match tcx.hir().get(closure_id) { Node::Expr(expr) => match expr.node { hir::ExprKind::Closure(.., body_id, _, _) => { body_id.node_id @@ -436,12 +436,12 @@ impl<'a, 'tcx> LoanPath<'tcx> { pub fn kill_scope(&self, bccx: &BorrowckCtxt<'a, 'tcx>) -> region::Scope { match self.kind { LpVar(local_id) => { - let hir_id = bccx.tcx.hir.node_to_hir_id(local_id); + let hir_id = bccx.tcx.hir().node_to_hir_id(local_id); bccx.region_scope_tree.var_scope(hir_id.local_id) } LpUpvar(upvar_id) => { let block_id = closure_to_block(upvar_id.closure_expr_id, bccx.tcx); - let hir_id = bccx.tcx.hir.node_to_hir_id(block_id); + let hir_id = bccx.tcx.hir().node_to_hir_id(block_id); region::Scope { id: hir_id.local_id, data: region::ScopeData::Node } } LpDowncast(ref base, _) | @@ -700,8 +700,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { Origin::Ast); let need_note = match lp.ty.sty { ty::Closure(id, _) => { - let node_id = self.tcx.hir.as_local_node_id(id).unwrap(); - let hir_id = self.tcx.hir.node_to_hir_id(node_id); + let node_id = self.tcx.hir().as_local_node_id(id).unwrap(); + let hir_id = self.tcx.hir().node_to_hir_id(node_id); if let Some((span, name)) = self.tables.closure_kind_origins().get(hir_id) { err.span_note(*span, &format!( "closure cannot be invoked more than once because \ @@ -721,7 +721,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { // Get type of value and span where it was previously // moved. - let node_id = self.tcx.hir.hir_to_node_id(hir::HirId { + let node_id = self.tcx.hir().hir_to_node_id(hir::HirId { owner: self.body.value.hir_id.owner, local_id: the_move.id }); @@ -731,10 +731,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } move_data::MoveExpr | - move_data::MovePat => (self.tcx.hir.span(node_id), ""), + move_data::MovePat => (self.tcx.hir().span(node_id), ""), move_data::Captured => - (match self.tcx.hir.expect_expr(node_id).node { + (match self.tcx.hir().expect_expr(node_id).node { hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span, ref r => bug!("Captured({:?}) maps to non-closure: {:?}", the_move.id, r), @@ -846,8 +846,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { MutabilityViolation => { let mut db = self.cannot_assign(error_span, &descr, Origin::Ast); if let mc::NoteClosureEnv(upvar_id) = err.cmt.note { - let node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id); - let sp = self.tcx.hir.span(node_id); + let node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id); + let sp = self.tcx.hir().span(node_id); let fn_closure_msg = "`Fn` closures cannot capture their enclosing \ environment for modifications"; match (self.tcx.sess.source_map().span_to_snippet(sp), &err.cmt.cat) { @@ -916,8 +916,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { // to implement two traits for "one operator" is not very intuitive for // many programmers. if err.cmt.note == mc::NoteIndex { - let node_id = self.tcx.hir.hir_to_node_id(err.cmt.hir_id); - let node = self.tcx.hir.get(node_id); + let node_id = self.tcx.hir().hir_to_node_id(err.cmt.hir_id); + let node = self.tcx.hir().get(node_id); // This pattern probably always matches. if let Node::Expr( @@ -937,7 +937,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { self.note_immutability_blame( &mut db, err.cmt.immutability_blame(), - self.tcx.hir.hir_to_node_id(err.cmt.hir_id) + self.tcx.hir().hir_to_node_id(err.cmt.hir_id) ); db.emit(); self.signal_error(); @@ -1043,7 +1043,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { if let ty::ReScope(scope) = *super_scope { let node_id = scope.node_id(self.tcx, &self.region_scope_tree); - match self.tcx.hir.find(node_id) { + match self.tcx.hir().find(node_id) { Some(Node::Stmt(_)) => { if *sub_scope != ty::ReStatic { db.note("consider using a `let` binding to increase its lifetime"); @@ -1138,8 +1138,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } else { "consider changing this closure to take self by mutable reference" }; - let node_id = self.tcx.hir.local_def_id_to_node_id(id); - let help_span = self.tcx.hir.span(node_id); + let node_id = self.tcx.hir().local_def_id_to_node_id(id); + let help_span = self.tcx.hir().span(node_id); self.cannot_act_on_capture_in_sharable_fn(span, prefix, (help_span, help_msg), @@ -1153,7 +1153,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { self.note_immutability_blame( &mut err, blame, - self.tcx.hir.hir_to_node_id(cmt.hir_id) + self.tcx.hir().hir_to_node_id(cmt.hir_id) ); if is_closure { @@ -1194,7 +1194,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } fn local_binding_mode(&self, node_id: ast::NodeId) -> ty::BindingMode { - let pat = match self.tcx.hir.get(node_id) { + let pat = match self.tcx.hir().get(node_id) { Node::Binding(pat) => pat, node => bug!("bad node for local: {:?}", node) }; @@ -1211,13 +1211,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } fn local_ty(&self, node_id: ast::NodeId) -> (Option<&hir::Ty>, bool) { - let parent = self.tcx.hir.get_parent_node(node_id); - let parent_node = self.tcx.hir.get(parent); + let parent = self.tcx.hir().get_parent_node(node_id); + let parent_node = self.tcx.hir().get(parent); // The parent node is like a fn if let Some(fn_like) = FnLikeNode::from_node(parent_node) { // `nid`'s parent's `Body` - let fn_body = self.tcx.hir.body(fn_like.body()); + let fn_body = self.tcx.hir().body(fn_like.body()); // Get the position of `node_id` in the arguments list let arg_pos = fn_body.arguments.iter().position(|arg| arg.pat.id == node_id); if let Some(i) = arg_pos { @@ -1245,7 +1245,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { Some(ImmutabilityBlame::LocalDeref(node_id)) => { match self.local_binding_mode(node_id) { ty::BindByReference(..) => { - let let_span = self.tcx.hir.span(node_id); + let let_span = self.tcx.hir().span(node_id); let suggestion = suggest_ref_mut(self.tcx, let_span); if let Some(replace_str) = suggestion { db.span_suggestion_with_applicability( @@ -1272,12 +1272,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } } Some(ImmutabilityBlame::AdtFieldDeref(_, field)) => { - let node_id = match self.tcx.hir.as_local_node_id(field.did) { + let node_id = match self.tcx.hir().as_local_node_id(field.did) { Some(node_id) => node_id, None => return }; - if let Node::Field(ref field) = self.tcx.hir.get(node_id) { + if let Node::Field(ref field) = self.tcx.hir().get(node_id) { if let Some(msg) = self.suggest_mut_for_immutable(&field.ty, false) { db.span_label(field.ty.span, msg); } @@ -1293,7 +1293,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { db: &mut DiagnosticBuilder, borrowed_node_id: ast::NodeId, binding_node_id: ast::NodeId) { - let let_span = self.tcx.hir.span(binding_node_id); + let let_span = self.tcx.hir().span(binding_node_id); if let ty::BindByValue(..) = self.local_binding_mode(binding_node_id) { if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) { let (ty, is_implicit_self) = self.local_ty(binding_node_id); @@ -1309,9 +1309,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { }, )) = ty.map(|t| &t.node) { - let borrow_expr_id = self.tcx.hir.get_parent_node(borrowed_node_id); + let borrow_expr_id = self.tcx.hir().get_parent_node(borrowed_node_id); db.span_suggestion_with_applicability( - self.tcx.hir.span(borrow_expr_id), + self.tcx.hir().span(borrow_expr_id), "consider removing the `&mut`, as it is an \ immutable binding to a mutable reference", snippet, @@ -1381,8 +1381,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { }; if *kind == ty::ClosureKind::Fn { let closure_node_id = - self.tcx.hir.local_def_id_to_node_id(upvar_id.closure_expr_id); - db.span_help(self.tcx.hir.span(closure_node_id), + self.tcx.hir().local_def_id_to_node_id(upvar_id.closure_expr_id); + db.span_help(self.tcx.hir().span(closure_node_id), "consider changing this closure to take \ self by mutable reference"); } @@ -1391,7 +1391,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { if let Categorization::Deref(..) = err.cmt.cat { db.span_label(*error_span, "cannot borrow as mutable"); } else if let Categorization::Local(local_id) = err.cmt.cat { - let span = self.tcx.hir.span(local_id); + let span = self.tcx.hir().span(local_id); if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") { db.span_label(*error_span, "cannot reborrow mutably"); @@ -1416,10 +1416,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { out: &mut String) { match loan_path.kind { LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id}, closure_expr_id: _ }) => { - out.push_str(&self.tcx.hir.name(self.tcx.hir.hir_to_node_id(id)).as_str()); + out.push_str(&self.tcx.hir().name(self.tcx.hir().hir_to_node_id(id)).as_str()); } LpVar(id) => { - out.push_str(&self.tcx.hir.name(id).as_str()); + out.push_str(&self.tcx.hir().name(id).as_str()); } LpDowncast(ref lp_base, variant_def_id) => { @@ -1530,13 +1530,13 @@ 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.hir.node_to_string(id))) + write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id))) } LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => { let s = ty::tls::with(|tcx| { - let var_node_id = tcx.hir.hir_to_node_id(var_id); - tcx.hir.node_to_string(var_node_id) + let var_node_id = tcx.hir().hir_to_node_id(var_id); + tcx.hir().node_to_string(var_node_id) }); write!(f, "$({} captured by id={:?})", s, closure_expr_id) } @@ -1565,13 +1565,13 @@ 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.hir.node_to_user_string(id))) + write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_user_string(id))) } LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => { let s = ty::tls::with(|tcx| { - let var_node_id = tcx.hir.hir_to_node_id(hir_id); - tcx.hir.node_to_string(var_node_id) + let var_node_id = tcx.hir().hir_to_node_id(hir_id); + tcx.hir().node_to_string(var_node_id) }); write!(f, "$({} captured by closure)", s) } diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs index 85794c5b10af4..a9a33f35842ce 100644 --- a/src/librustc_borrowck/borrowck/unused.rs +++ b/src/librustc_borrowck/borrowck/unused.rs @@ -100,7 +100,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for UnusedMutCx<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir()) } fn visit_arm(&mut self, arm: &hir::Arm) { @@ -114,12 +114,12 @@ impl<'a, 'tcx> Visitor<'tcx> for UnusedMutCx<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for UsedMutFinder<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir()) } fn visit_nested_body(&mut self, id: hir::BodyId) { - let def_id = self.bccx.tcx.hir.body_owner_def_id(id); + let def_id = self.bccx.tcx.hir().body_owner_def_id(id); self.set.extend(self.bccx.tcx.borrowck(def_id).used_mut_nodes.iter().cloned()); - self.visit_body(self.bccx.tcx.hir.body(id)); + self.visit_body(self.bccx.tcx.hir().body(id)); } } diff --git a/src/librustc_borrowck/dataflow.rs b/src/librustc_borrowck/dataflow.rs index 1760fb138ead8..99df0fa5e471f 100644 --- a/src/librustc_borrowck/dataflow.rs +++ b/src/librustc_borrowck/dataflow.rs @@ -111,7 +111,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.hir, state, nested) + pprust::PpAnn::nested(self.tcx.hir(), state, nested) } fn pre(&self, ps: &mut pprust::State, diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 5311a6a373026..a4baa332fe2a7 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -223,10 +223,10 @@ impl CodegenCx<'ll, 'tcx> { debug!("get_static: sym={} instance={:?}", sym, instance); - let g = if let Some(id) = self.tcx.hir.as_local_node_id(def_id) { + let g = if let Some(id) = self.tcx.hir().as_local_node_id(def_id) { let llty = self.layout_of(ty).llvm_type(self); - let (g, attrs) = match self.tcx.hir.get(id) { + let (g, attrs) = match self.tcx.hir().get(id) { Node::Item(&hir::Item { ref attrs, span, node: hir::ItemKind::Static(..), .. }) => { diff --git a/src/librustc_codegen_llvm/debuginfo/gdb.rs b/src/librustc_codegen_llvm/debuginfo/gdb.rs index 4be93d826b88f..ff5ec20254ea1 100644 --- a/src/librustc_codegen_llvm/debuginfo/gdb.rs +++ b/src/librustc_codegen_llvm/debuginfo/gdb.rs @@ -76,7 +76,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>) pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool { let omit_gdb_pretty_printer_section = - attr::contains_name(&cx.tcx.hir.krate_attrs(), + attr::contains_name(&cx.tcx.hir().krate_attrs(), "omit_gdb_pretty_printer_section"); !omit_gdb_pretty_printer_section && diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 78bdf678f6707..e54e180224eec 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -300,7 +300,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { let mut flags = DIFlags::FlagPrototyped; - let local_id = self.tcx().hir.as_local_node_id(def_id); + let local_id = self.tcx().hir().as_local_node_id(def_id); if let Some((id, _, _)) = *self.sess().entry_fn.borrow() { if local_id == Some(id) { flags |= DIFlags::FlagMainSubprogram; diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index ecae6197dc7ca..84b17e31dd4eb 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -93,9 +93,9 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // // 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.hir.get(node_id) { + match tcx.hir().get(node_id) { Node::ForeignItem(..) => { - let def_id = tcx.hir.local_def_id(node_id); + let def_id = tcx.hir().local_def_id(node_id); if tcx.is_statically_included_foreign_item(def_id) { Some(def_id) } else { @@ -115,7 +115,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node: hir::ImplItemKind::Method(..), .. }) => { - let def_id = tcx.hir.local_def_id(node_id); + let def_id = tcx.hir().local_def_id(node_id); let generics = tcx.generics_of(def_id); if !generics.requires_monomorphization(tcx) && // Functions marked with #[inline] are only ever codegened @@ -158,12 +158,12 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .collect(); if let Some(id) = *tcx.sess.proc_macro_decls_static.get() { - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); reachable_non_generics.insert(def_id, SymbolExportLevel::C); } if let Some(id) = *tcx.sess.plugin_registrar_fn.get() { - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); reachable_non_generics.insert(def_id, SymbolExportLevel::C); } @@ -355,7 +355,7 @@ fn upstream_monomorphizations_for_provider<'a, 'tcx>( } fn is_unreachable_local_definition_provider(tcx: TyCtxt, def_id: DefId) -> bool { - if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { + if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { !tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id) } else { bug!("is_unreachable_local_definition called with non-local DefId: {:?}", @@ -393,7 +393,7 @@ fn symbol_export_level(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportLevel { if let Some(Node::Item(&hir::Item { node: hir::ItemKind::Static(..), .. - })) = tcx.hir.get_if_local(sym_def_id) { + })) = tcx.hir().get_if_local(sym_def_id) { return SymbolExportLevel::Rust; } } diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 46aee5339ba9e..2300b3e8c9b2d 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -313,8 +313,8 @@ pub fn start_async_codegen( let sess = tcx.sess; let crate_name = tcx.crate_name(LOCAL_CRATE); let crate_hash = tcx.crate_hash(LOCAL_CRATE); - let no_builtins = attr::contains_name(&tcx.hir.krate().attrs, "no_builtins"); - let subsystem = attr::first_attr_value_str_by_name(&tcx.hir.krate().attrs, + let no_builtins = attr::contains_name(&tcx.hir().krate().attrs, "no_builtins"); + let subsystem = attr::first_attr_value_str_by_name(&tcx.hir().krate().attrs, "windows_subsystem"); let windows_subsystem = subsystem.map(|subsystem| { if subsystem != "windows" && subsystem != "console" { diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 266f78996b32b..76d699d173692 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -453,7 +453,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( ) { let (main_def_id, span) = match *cx.sess().entry_fn.borrow() { Some((id, span, _)) => { - (cx.tcx().hir.local_def_id(id), span) + (cx.tcx().hir().local_def_id(id), span) } None => return, }; diff --git a/src/librustc_codegen_ssa/mono_item.rs b/src/librustc_codegen_ssa/mono_item.rs index 8fe8979196904..26f8a9a5dd4a0 100644 --- a/src/librustc_codegen_ssa/mono_item.rs +++ b/src/librustc_codegen_ssa/mono_item.rs @@ -42,7 +42,7 @@ pub trait MonoItemExt<'a, 'tcx: 'a>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> { cx.codegen_static(def_id, is_mutable); } MonoItem::GlobalAsm(node_id) => { - let item = cx.tcx().hir.expect_item(node_id); + let item = cx.tcx().hir().expect_item(node_id); if let hir::ItemKind::GlobalAsm(ref ga) = item.node { cx.codegen_global_asm(ga); } else { diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index ea8259d79a189..cbef3ff5b9286 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -53,7 +53,7 @@ pub mod symbol_names_test; /// reporting an error. pub fn check_for_rustc_errors_attr(tcx: TyCtxt) { if let Some((id, span, _)) = *tcx.sess.entry_fn.borrow() { - let main_def_id = tcx.hir.local_def_id(id); + let main_def_id = tcx.hir().local_def_id(id); if tcx.has_attr(main_def_id, "rustc_error") { tcx.sess.span_fatal(span, "compilation successful"); diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 611d7b137c6f2..305c718ff0636 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -250,7 +250,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance debug!("symbol_name(def_id={:?}, substs={:?})", def_id, substs); - let node_id = tcx.hir.as_local_node_id(def_id); + let node_id = tcx.hir().as_local_node_id(def_id); if let Some(id) = node_id { if *tcx.sess.plugin_registrar_fn.get() == Some(id) { @@ -265,7 +265,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance // FIXME(eddyb) Precompute a custom symbol name based on attributes. let is_foreign = if let Some(id) = node_id { - match tcx.hir.get(id) { + match tcx.hir().get(id) { Node::ForeignItem(_) => true, _ => false, } diff --git a/src/librustc_codegen_utils/symbol_names_test.rs b/src/librustc_codegen_utils/symbol_names_test.rs index 6eaf0c1c08da1..c4ad31ab02198 100644 --- a/src/librustc_codegen_utils/symbol_names_test.rs +++ b/src/librustc_codegen_utils/symbol_names_test.rs @@ -33,7 +33,7 @@ pub fn report_symbol_names<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { tcx.dep_graph.with_ignore(|| { let mut visitor = SymbolNamesTest { tcx }; - tcx.hir.krate().visit_all_item_likes(&mut visitor); + tcx.hir().krate().visit_all_item_likes(&mut visitor); }) } @@ -45,7 +45,7 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> { fn process_attrs(&mut self, node_id: ast::NodeId) { let tcx = self.tcx; - let def_id = tcx.hir.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_driver/driver.rs b/src/librustc_driver/driver.rs index 48014a9e1192c..8130f31a6954d 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -305,7 +305,7 @@ pub fn compile_input( outdir, output, opt_crate, - tcx.hir.krate(), + tcx.hir().krate(), &analysis, tcx, &crate_name, diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index fb8093d1d77a7..b89c4262024d1 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -495,7 +495,7 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> { } fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> { - Some(&self.tcx.hir) + Some(&self.tcx.hir()) } fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn { @@ -514,7 +514,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.hir, state, nested)?; + pprust_hir::PpAnn::nested(self.tcx.hir(), state, nested)?; self.tables.set(old_tables); Ok(()) } @@ -851,18 +851,18 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec, // Find the function this expression is from. let mut node_id = expr.id; loop { - let node = tcx.hir.get(node_id); + let node = tcx.hir().get(node_id); if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) { break n.body(); } - let parent = tcx.hir.get_parent_node(node_id); + let parent = tcx.hir().get_parent_node(node_id); assert_ne!(node_id, parent); node_id = parent; } } blocks::Code::FnLike(fn_like) => fn_like.body(), }; - let body = tcx.hir.body(body_id); + let body = tcx.hir().body(body_id); let cfg = cfg::CFG::new(tcx, &body); let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges; let lcfg = LabelledCFG { @@ -1164,7 +1164,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, match ppm { PpmMir | PpmMirCFG => { if let Some(nodeid) = nodeid { - let def_id = tcx.hir.local_def_id(nodeid); + let def_id = tcx.hir().local_def_id(nodeid); match ppm { PpmMir => write_mir_pretty(tcx, Some(def_id), &mut out), PpmMirCFG => write_mir_graphviz(tcx, Some(def_id), &mut out), @@ -1183,11 +1183,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.hir.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.hir, nodeid) { + match blocks::Code::from_node(&tcx.hir(), nodeid) { Some(code) => { let variants = gather_flowgraph_variants(tcx.sess); @@ -1200,7 +1200,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session, got {:?}", node); - tcx.sess.span_fatal(tcx.hir.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 b8cd9bda7f020..912371714e39d 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -186,7 +186,7 @@ fn test_env_with_pool( param_env: param_env, }); let outlives_env = OutlivesEnvironment::new(param_env); - let def_id = tcx.hir.local_def_id(ast::CRATE_NODE_ID); + let def_id = tcx.hir().local_def_id(ast::CRATE_NODE_ID); infcx.resolve_regions_and_report_errors( def_id, ®ion_scope_tree, @@ -256,7 +256,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.hir.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("::")); @@ -271,7 +271,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.hir.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); } @@ -364,7 +364,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { self.infcx .tcx .mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion { - def_id: self.infcx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), + def_id: self.infcx.tcx.hir().local_def_id(ast::CRATE_NODE_ID), index, name, })) @@ -410,7 +410,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { pub fn re_free(&self, id: u32) -> ty::Region<'tcx> { self.infcx.tcx.mk_region(ty::ReFree(ty::FreeRegion { - scope: self.infcx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), + scope: self.infcx.tcx.hir().local_def_id(ast::CRATE_NODE_ID), bound_region: ty::BrAnon(id), })) } diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 22a0cc983daab..15c0dbabd0c90 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, if_this_changed: vec![], then_this_would_need: vec![] }; - visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir.krate().attrs); - tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); + visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir().krate().attrs); + tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); (visitor.if_this_changed, visitor.then_this_would_need) }; @@ -121,7 +121,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> { } fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) { - let def_id = self.tcx.hir.local_def_id(node_id); + let def_id = self.tcx.hir().local_def_id(node_id); let def_path_hash = self.tcx.def_path_hash(def_id); for attr in attrs { if attr.check_name(ATTR_IF_THIS_CHANGED) { @@ -170,7 +170,7 @@ impl<'a, 'tcx> IfThisChanged<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for IfThisChanged<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item) { diff --git a/src/librustc_incremental/assert_module_sources.rs b/src/librustc_incremental/assert_module_sources.rs index 17ac9a6b53973..8c562ff24fd6d 100644 --- a/src/librustc_incremental/assert_module_sources.rs +++ b/src/librustc_incremental/assert_module_sources.rs @@ -62,7 +62,7 @@ pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { available_cgus }; - for attr in &tcx.hir.krate().attrs { + for attr in &tcx.hir().krate().attrs { ams.check_attr(attr); } }) diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index f76086139ed7e..55a4a63c8f3d5 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -223,7 +223,7 @@ pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { } tcx.dep_graph.with_ignore(|| { - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let mut dirty_clean_visitor = DirtyCleanVisitor { tcx, checked_attrs: Default::default(), @@ -333,7 +333,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { /// Return all DepNode labels that should be asserted for this item. /// index=0 is the "name" used for error messages fn auto_labels(&mut self, item_id: ast::NodeId, attr: &Attribute) -> (&'static str, Labels) { - let node = self.tcx.hir.get(item_id); + let node = self.tcx.hir().get(item_id); let (name, labels) = match node { HirNode::Item(item) => { match item.node { @@ -511,7 +511,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { } fn check_item(&mut self, item_id: ast::NodeId, item_span: Span) { - let def_id = self.tcx.hir.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() { let assertion = match self.assertion_maybe(item_id, attr) { Some(a) => a, @@ -630,7 +630,7 @@ impl<'a, 'tcx> FindAllAttrs<'a, 'tcx> { impl<'a, 'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { - intravisit::NestedVisitorMap::All(&self.tcx.hir) + intravisit::NestedVisitorMap::All(&self.tcx.hir()) } fn visit_attribute(&mut self, attr: &'tcx Attribute) { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 7dd1ca3493e9d..9d3dc97552f96 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => { - let def_id = cx.tcx.hir.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.type_of(def_id)) } _ => () @@ -142,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers { hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => { for struct_field in struct_def.fields() { - let def_id = cx.tcx.hir.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.type_of(def_id)); } @@ -424,8 +424,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.hir.as_local_node_id(real_trait) { - match cx.tcx.hir.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(Node::Item(item)) => { if let hir::VisibilityKind::Inherited = item.vis.node { for impl_item_ref in impl_item_refs { @@ -527,21 +527,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations { if !ast_generics.params.is_empty() { return; } - let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); + let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } hir::ItemKind::Union(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; } - let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); + let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } hir::ItemKind::Enum(_, ref ast_generics) => { if !ast_generics.params.is_empty() { return; } - let def = cx.tcx.adt_def(cx.tcx.hir.local_def_id(item.id)); + let def = cx.tcx.adt_def(cx.tcx.hir().local_def_id(item.id)); (def, cx.tcx.mk_adt(def, cx.tcx.intern_substs(&[]))) } _ => return, @@ -606,7 +606,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations { let mut impls = NodeSet::default(); cx.tcx.for_each_impl(debug, |d| { if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() { - if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def.did) { + if let Some(node_id) = cx.tcx.hir().as_local_node_id(ty_def.did) { impls.insert(node_id); } } @@ -871,7 +871,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary { _ => return, }; - let def_id = cx.tcx.hir.local_def_id(it.id); + let def_id = cx.tcx.hir().local_def_id(it.id); let prfn = match cx.tcx.extern_mod_stmt_cnum(def_id) { Some(cnum) => cx.tcx.plugin_registrar_fn(cnum), None => { @@ -1073,7 +1073,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields { fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) { if let hir::ItemKind::Union(ref vdata, _) = item.node { for field in vdata.fields() { - let field_ty = ctx.tcx.type_of(ctx.tcx.hir.local_def_id(field.id)); + let field_ty = ctx.tcx.type_of(ctx.tcx.hir().local_def_id(field.id)); if field_ty.needs_drop(ctx.tcx, ctx.param_env) { ctx.span_lint(UNIONS_WITH_DROP_FIELDS, field.span, @@ -1275,7 +1275,7 @@ impl LintPass for UnusedBrokenConst { } } fn check_const(cx: &LateContext, body_id: hir::BodyId) { - let def_id = cx.tcx.hir.body_owner_def_id(body_id); + let def_id = cx.tcx.hir().body_owner_def_id(body_id); let is_static = cx.tcx.is_static(def_id).is_some(); let param_env = if is_static { // Use the same param_env as `codegen_static_initializer`, to reuse the cache. @@ -1332,7 +1332,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints { if cx.tcx.features().trivial_bounds { - let def_id = cx.tcx.hir.local_def_id(item.id); + let def_id = cx.tcx.hir().local_def_id(item.id); let predicates = cx.tcx.predicates_of(def_id); for &(predicate, span) in &predicates.predicates { let predicate_kind_name = match predicate { @@ -1746,7 +1746,7 @@ impl ExplicitOutlivesRequirements { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements { fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) { let infer_static = cx.tcx.features().infer_static_outlives_requirements; - let def_id = cx.tcx.hir.local_def_id(item.id); + let def_id = cx.tcx.hir().local_def_id(item.id); if let hir::ItemKind::Struct(_, ref generics) = item.node { let mut bound_count = 0; let mut lint_spans = Vec::new(); diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index 40781b0771d89..33250475d10d4 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -29,7 +29,7 @@ pub enum MethodLateContext { } pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext { - let def_id = cx.tcx.hir.local_def_id(id); + let def_id = cx.tcx.hir().local_def_id(id); let item = cx.tcx.associated_item(def_id); match item.container { ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl, diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 82ace620c8ab2..e225e642e72e7 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -139,8 +139,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { _ => bug!(), }; if lit_val < min || lit_val > max { - let parent_id = cx.tcx.hir.get_parent_node(e.id); - if let Node::Expr(parent_expr) = cx.tcx.hir.get(parent_id) { + let parent_id = cx.tcx.hir().get_parent_node(e.id); + if let Node::Expr(parent_expr) = cx.tcx.hir().get(parent_id) { if let hir::ExprKind::Cast(..) = parent_expr.node { if let ty::Char = cx.tables.expr_ty(parent_expr).sty { let mut err = cx.struct_span_lint( @@ -756,7 +756,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { diag.help(s); } if let ty::Adt(def, _) = unsafe_ty.sty { - if let Some(sp) = self.cx.tcx.hir.span_if_local(def.did) { + if let Some(sp) = self.cx.tcx.hir().span_if_local(def.did) { diag.span_note(sp, "type defined here"); } } @@ -766,7 +766,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.hir.local_def_id(id); + let def_id = self.cx.tcx.hir().local_def_id(id); let sig = self.cx.tcx.fn_sig(def_id); let sig = self.cx.tcx.erase_late_bound_regions(&sig); @@ -783,7 +783,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } fn check_foreign_static(&mut self, id: ast::NodeId, span: Span) { - let def_id = self.cx.tcx.hir.local_def_id(id); + let def_id = self.cx.tcx.hir().local_def_id(id); let ty = self.cx.tcx.type_of(def_id); self.check_type_for_ffi_and_report_errors(span, ty); } @@ -801,7 +801,7 @@ impl LintPass for ImproperCTypes { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) { let mut vis = ImproperCTypesVisitor { cx }; - let abi = cx.tcx.hir.get_foreign_abi(it.id); + let abi = cx.tcx.hir().get_foreign_abi(it.id); if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic { match it.node { hir::ForeignItemKind::Fn(ref decl, _, _) => { @@ -827,7 +827,7 @@ impl LintPass for VariantSizeDifferences { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { if let hir::ItemKind::Enum(ref enum_definition, _) = it.node { - let item_def_id = cx.tcx.hir.local_def_id(it.id); + let item_def_id = cx.tcx.hir().local_def_id(it.id); let t = cx.tcx.type_of(item_def_id); let ty = cx.tcx.erase_regions(&t); match cx.layout_of(ty) { diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index c7eb06cbe0053..d3e1af70c21da 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -61,7 +61,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults { let t = cx.tables.expr_ty(&expr); let type_permits_lack_of_use = if t.is_unit() - || cx.tcx.is_ty_uninhabited_from(cx.tcx.hir.get_module_parent(expr.id), t) { + || cx.tcx.is_ty_uninhabited_from(cx.tcx.hir().get_module_parent(expr.id), t) { true } else { match t.sty { diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 2736c60ffb6fa..329e2dbdd9502 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -318,7 +318,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_info_for_items(&mut self) -> Index { - let krate = self.tcx.hir.krate(); + let krate = self.tcx.hir().krate(); let mut index = IndexBuilder::new(self); let vis = Spanned { span: syntax_pos::DUMMY_SP, node: hir::VisibilityKind::Public }; index.record(DefId::local(CRATE_DEF_INDEX), @@ -333,7 +333,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_def_path_table(&mut self) -> Lazy { - let definitions = self.tcx.hir.definitions(); + let definitions = self.tcx.hir().definitions(); self.lazy(definitions.def_path_table()) } @@ -475,7 +475,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let index = items.write_index(&mut self.opaque); let index_bytes = self.position() - i; - let attrs = tcx.hir.krate_attrs(); + let attrs = tcx.hir().krate_attrs(); let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateType::ProcMacro); let has_default_lib_allocator = attr::contains_name(&attrs, "default_lib_allocator"); let has_global_allocator = *tcx.sess.has_global_allocator.get(); @@ -495,10 +495,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { plugin_registrar_fn: tcx.sess .plugin_registrar_fn .get() - .map(|id| tcx.hir.local_def_id(id).index), + .map(|id| tcx.hir().local_def_id(id).index), proc_macro_decls_static: if is_proc_macro { let id = tcx.sess.proc_macro_decls_static.get().unwrap(); - Some(tcx.hir.local_def_id(id).index) + Some(tcx.hir().local_def_id(id).index) } else { None }, @@ -600,8 +600,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { } }; - let enum_id = tcx.hir.as_local_node_id(enum_did).unwrap(); - let enum_vis = &tcx.hir.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)), @@ -636,7 +636,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { &hir::Visibility)>) -> Entry<'tcx> { let tcx = self.tcx; - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); debug!("IsolatedEncoder::encode_info_for_mod({:?})", def_id); let data = ModData { @@ -652,7 +652,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { span: self.lazy(&tcx.def_span(def_id)), attributes: self.encode_attributes(attrs), children: self.lazy_seq(md.item_ids.iter().map(|item_id| { - tcx.hir.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), @@ -686,8 +686,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { let def_id = field.did; debug!("IsolatedEncoder::encode_field({:?})", def_id); - let variant_id = tcx.hir.as_local_node_id(variant.did).unwrap(); - let variant_data = tcx.hir.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, @@ -726,8 +726,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { } }; - let struct_id = tcx.hir.as_local_node_id(adt_def_id).unwrap(); - let struct_vis = &tcx.hir.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; let mut ctor_vis = ty::Visibility::from_hir(struct_vis, struct_id, tcx); for field in &variant.fields { if ctor_vis.is_at_least(field.vis, tcx) { @@ -791,8 +791,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { debug!("IsolatedEncoder::encode_info_for_trait_item({:?})", def_id); let tcx = self.tcx; - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let ast_item = tcx.hir.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 { @@ -814,7 +814,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { }; let rendered = - hir::print::to_string(&self.tcx.hir, |s| s.print_trait_item(ast_item)); + hir::print::to_string(self.tcx.hir(), |s| s.print_trait_item(ast_item)); let rendered_const = self.lazy(&RenderedConst(rendered)); EntryKind::AssociatedConst(container, const_qualif, rendered_const) @@ -891,7 +891,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { } fn const_qualif(&self, mir: u8, body_id: hir::BodyId) -> ConstQualif { - let body_owner_def_id = self.tcx.hir.body_owner_def_id(body_id); + let body_owner_def_id = self.tcx.hir().body_owner_def_id(body_id); let ast_promotable = self.tcx.const_is_rvalue_promotable_to_static(body_owner_def_id); ConstQualif { mir, ast_promotable } @@ -901,8 +901,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { debug!("IsolatedEncoder::encode_info_for_impl_item({:?})", def_id); let tcx = self.tcx; - 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 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 { @@ -987,7 +987,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { fn encode_fn_arg_names_for_body(&mut self, body_id: hir::BodyId) -> LazySeq { self.tcx.dep_graph.with_ignore(|| { - let body = self.tcx.hir.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(_, _, ident, _) => ident.name, @@ -1036,8 +1036,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { } fn encode_rendered_const_for_body(&mut self, body_id: hir::BodyId) -> Lazy { - let body = self.tcx.hir.body(body_id); - let rendered = hir::print::to_string(&self.tcx.hir, |s| s.print_expr(&body.value)); + let body = self.tcx.hir().body(body_id); + let rendered = hir::print::to_string(self.tcx.hir(), |s| s.print_expr(&body.value)); let rendered_const = &RenderedConst(rendered); self.lazy(rendered_const) } @@ -1081,7 +1081,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { // for methods, write all the stuff get_trait_method // needs to know let struct_ctor = if !struct_def.is_struct() { - Some(tcx.hir.local_def_id(struct_def.id()).index) + Some(tcx.hir().local_def_id(struct_def.id()).index) } else { None }; @@ -1167,7 +1167,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { hir::ItemKind::ForeignMod(ref fm) => { self.lazy_seq(fm.items .iter() - .map(|foreign_item| tcx.hir.local_def_id(foreign_item.id).index)) + .map(|foreign_item| tcx.hir().local_def_id(foreign_item.id).index)) } hir::ItemKind::Enum(..) => { let def = self.tcx.adt_def(def_id); @@ -1282,7 +1282,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { /// Serialize the text of exported macros fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef) -> Entry<'tcx> { use syntax::print::pprust; - let def_id = self.tcx.hir.local_def_id(macro_def.id); + let def_id = self.tcx.hir().local_def_id(macro_def.id); Entry { kind: EntryKind::MacroDef(self.lazy(&MacroDef { body: pprust::tts_to_string(¯o_def.body.trees().collect::>()), @@ -1339,8 +1339,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { let tcx = self.tcx; let tables = self.tcx.typeck_tables_of(def_id); - let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); - let hir_id = self.tcx.hir.node_to_hir_id(node_id); + let node_id = self.tcx.hir().as_local_node_id(def_id).unwrap(); + let hir_id = self.tcx.hir().node_to_hir_id(node_id); let kind = match tables.node_id_to_type(hir_id).sty { ty::Generator(def_id, ..) => { let layout = self.tcx.generator_layout(def_id); @@ -1382,8 +1382,8 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { fn encode_info_for_anon_const(&mut self, def_id: DefId) -> Entry<'tcx> { debug!("IsolatedEncoder::encode_info_for_anon_const({:?})", def_id); let tcx = self.tcx; - let id = tcx.hir.as_local_node_id(def_id).unwrap(); - let body_id = tcx.hir.body_owned_by(id); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); + let body_id = tcx.hir().body_owned_by(id); let const_data = self.encode_rendered_const_for_body(body_id); let mir = tcx.mir_const_qualif(def_id).0; @@ -1491,7 +1491,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { tcx, impls: FxHashMap::default(), }; - tcx.hir.krate().visit_all_item_likes(&mut visitor); + tcx.hir().krate().visit_all_item_likes(&mut visitor); let mut all_impls: Vec<_> = visitor.impls.into_iter().collect(); @@ -1505,7 +1505,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { .map(|(trait_def_id, mut impls)| { // Bring everything into deterministic order for hashing impls.sort_by_cached_key(|&def_index| { - tcx.hir.definitions().def_path_hash(def_index) + tcx.hir().definitions().def_path_hash(def_index) }); TraitImpls { @@ -1617,7 +1617,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.hir) + NestedVisitorMap::OnlyBodies(&self.index.tcx.hir()) } fn visit_expr(&mut self, ex: &'tcx hir::Expr) { intravisit::walk_expr(self, ex); @@ -1625,7 +1625,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.hir.local_def_id(item.id); + let def_id = self.index.tcx.hir().local_def_id(item.id); match item.node { hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) => (), // ignore these @@ -1635,7 +1635,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.hir.local_def_id(ni.id); + let def_id = self.index.tcx.hir().local_def_id(ni.id); self.index.record(def_id, IsolatedEncoder::encode_info_for_foreign_item, (def_id, ni)); @@ -1647,7 +1647,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> { intravisit::walk_variant(self, v, g, id); if let Some(ref discr) = v.node.disr_expr { - let def_id = self.index.tcx.hir.local_def_id(discr.id); + let def_id = self.index.tcx.hir().local_def_id(discr.id); self.index.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id); } } @@ -1660,7 +1660,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.hir.local_def_id(macro_def.id); + let def_id = self.index.tcx.hir().local_def_id(macro_def.id); self.index.record(def_id, IsolatedEncoder::encode_info_for_macro_def, macro_def); } } @@ -1682,7 +1682,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { match param.kind { hir::GenericParamKind::Lifetime { .. } => {} hir::GenericParamKind::Type { ref default, .. } => { - let def_id = self.tcx.hir.local_def_id(param.id); + let def_id = self.tcx.hir().local_def_id(param.id); let has_default = Untracked(default.is_some()); let encode_info = IsolatedEncoder::encode_info_for_ty_param; self.record(def_id, encode_info, (def_id, has_default)); @@ -1694,7 +1694,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { fn encode_info_for_ty(&mut self, ty: &hir::Ty) { match ty.node { hir::TyKind::Array(_, ref length) => { - let def_id = self.tcx.hir.local_def_id(length.id); + let def_id = self.tcx.hir().local_def_id(length.id); self.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id); } _ => {} @@ -1704,7 +1704,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> { fn encode_info_for_expr(&mut self, expr: &hir::Expr) { match expr.node { hir::ExprKind::Closure(..) => { - let def_id = self.tcx.hir.local_def_id(expr.id); + let def_id = self.tcx.hir().local_def_id(expr.id); self.record(def_id, IsolatedEncoder::encode_info_for_closure, def_id); } _ => {} @@ -1716,7 +1716,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.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); match item.node { hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | @@ -1746,7 +1746,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.hir.local_def_id(struct_def.id()); + let ctor_def_id = self.tcx.hir().local_def_id(struct_def.id()); self.record(ctor_def_id, IsolatedEncoder::encode_struct_ctor, (def_id, ctor_def_id)); @@ -1781,7 +1781,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::ItemKind::Impl(..) = item.node { - let impl_id = self.tcx.hir.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) diff --git a/src/librustc_metadata/foreign_modules.rs b/src/librustc_metadata/foreign_modules.rs index e96d56fb38893..5b2002f2a9683 100644 --- a/src/librustc_metadata/foreign_modules.rs +++ b/src/librustc_metadata/foreign_modules.rs @@ -18,7 +18,7 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec { tcx, modules: Vec::new(), }; - tcx.hir.krate().visit_all_item_likes(&mut collector); + tcx.hir().krate().visit_all_item_likes(&mut collector); return collector.modules } @@ -35,11 +35,11 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { }; let foreign_items = fm.items.iter() - .map(|it| self.tcx.hir.local_def_id(it.id)) + .map(|it| self.tcx.hir().local_def_id(it.id)) .collect(); self.modules.push(ForeignModule { foreign_items, - def_id: self.tcx.hir.local_def_id(it.id), + def_id: self.tcx.hir().local_def_id(it.id), }); } diff --git a/src/librustc_metadata/index_builder.rs b/src/librustc_metadata/index_builder.rs index fd2c2237c32d6..aea3ac1be8188 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.hir.definitions().def_index_counts_lo_hi()), + items: Index::new(ecx.tcx.hir().definitions().def_index_counts_lo_hi()), ecx, } } @@ -195,7 +195,7 @@ macro_rules! read_hir { ($t:ty) => { impl<'tcx> DepGraphRead for &'tcx $t { fn read(&self, tcx: TyCtxt) { - tcx.hir.read(self.id); + tcx.hir().read(self.id); } } } @@ -229,6 +229,6 @@ pub struct FromId(pub ast::NodeId, pub T); impl DepGraphRead for FromId { fn read(&self, tcx: TyCtxt) { - tcx.hir.read(self.0); + tcx.hir().read(self.0); } } diff --git a/src/librustc_metadata/link_args.rs b/src/librustc_metadata/link_args.rs index 008e1e363ff53..decd85c507e25 100644 --- a/src/librustc_metadata/link_args.rs +++ b/src/librustc_metadata/link_args.rs @@ -17,9 +17,9 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec { let mut collector = Collector { args: Vec::new(), }; - tcx.hir.krate().visit_all_item_likes(&mut collector); + tcx.hir().krate().visit_all_item_likes(&mut collector); - for attr in tcx.hir.krate().attrs.iter() { + for attr in tcx.hir().krate().attrs.iter() { if attr.path == "link_args" { if let Some(linkarg) = attr.value_str() { collector.add_link_args(&linkarg.as_str()); diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 392644c793d8c..6f85418b297ed 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -25,7 +25,7 @@ pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec { tcx, libs: Vec::new(), }; - tcx.hir.krate().visit_all_item_likes(&mut collector); + tcx.hir().krate().visit_all_item_likes(&mut collector); collector.process_command_line(); return collector.libs } @@ -65,7 +65,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { name: None, kind: cstore::NativeUnknown, cfg: None, - foreign_module: Some(self.tcx.hir.local_def_id(it.id)), + foreign_module: Some(self.tcx.hir().local_def_id(it.id)), wasm_import_module: None, }; let mut kind_specified = false; diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index ba26ed36c20f4..b8d0c0b348ffa 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -195,8 +195,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let needs_note = match ty.sty { ty::Closure(id, _) => { let tables = self.infcx.tcx.typeck_tables_of(id); - let node_id = self.infcx.tcx.hir.as_local_node_id(id).unwrap(); - let hir_id = self.infcx.tcx.hir.node_to_hir_id(node_id); + let node_id = self.infcx.tcx.hir().as_local_node_id(id).unwrap(); + let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id); tables.closure_kind_origins().get(hir_id).is_none() } @@ -720,13 +720,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { format!("`{}` would have to be valid for `{}`...", name, region_name), ); - if let Some(fn_node_id) = self.infcx.tcx.hir.as_local_node_id(self.mir_def_id) { + if let Some(fn_node_id) = self.infcx.tcx.hir().as_local_node_id(self.mir_def_id) { err.span_label( drop_span, format!( "...but `{}` will be dropped here, when the function `{}` returns", name, - self.infcx.tcx.hir.name(fn_node_id), + self.infcx.tcx.hir().name(fn_node_id), ), ); @@ -1064,7 +1064,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let escapes_from = if tcx.is_closure(self.mir_def_id) { let tables = tcx.typeck_tables_of(self.mir_def_id); - let mir_hir_id = tcx.hir.def_index_to_hir_id(self.mir_def_id.index); + let mir_hir_id = tcx.hir().def_index_to_hir_id(self.mir_def_id.index); match tables.node_id_to_type(mir_hir_id).sty { ty::Closure(..) => "closure", ty::Generator(..) => "generator", @@ -1412,11 +1412,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ); if let ty::TyKind::Closure(did, _substs) = self.mir.local_decls[closure].ty.sty { - let node_id = match self.infcx.tcx.hir.as_local_node_id(did) { + let node_id = match self.infcx.tcx.hir().as_local_node_id(did) { Some(node_id) => node_id, _ => return, }; - let hir_id = self.infcx.tcx.hir.node_to_hir_id(node_id); + let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id); if let Some(( span, name @@ -1654,12 +1654,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // the local code in the current crate, so this returns an `Option` in case // the closure comes from another crate. But in that case we wouldn't // be borrowck'ing it, so we can just unwrap: - let node_id = self.infcx.tcx.hir.as_local_node_id(def_id).unwrap(); + let node_id = self.infcx.tcx.hir().as_local_node_id(def_id).unwrap(); let freevar = self.infcx .tcx .with_freevars(node_id, |fv| fv[field.index()]); - self.infcx.tcx.hir.name(freevar.var_id()).to_string() + self.infcx.tcx.hir().name(freevar.var_id()).to_string() } _ => { // Might need a revision when the fields in trait RFC is implemented @@ -1980,8 +1980,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ) -> Option { debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig); let is_closure = self.infcx.tcx.is_closure(did); - let fn_node_id = self.infcx.tcx.hir.as_local_node_id(did)?; - let fn_decl = self.infcx.tcx.hir.fn_decl(fn_node_id)?; + let fn_node_id = self.infcx.tcx.hir().as_local_node_id(did)?; + let fn_decl = self.infcx.tcx.hir().fn_decl(fn_node_id)?; // We need to work out which arguments to highlight. We do this by looking // at the return type, where there are three cases: @@ -2423,8 +2423,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { "closure_span: def_id={:?} target_place={:?} places={:?}", def_id, target_place, places ); - let node_id = self.infcx.tcx.hir.as_local_node_id(def_id)?; - let expr = &self.infcx.tcx.hir.expect_expr(node_id).node; + let node_id = self.infcx.tcx.hir().as_local_node_id(def_id)?; + let expr = &self.infcx.tcx.hir().expect_expr(node_id).node; debug!("closure_span: node_id={:?} expr={:?}", node_id, expr); if let hir::ExprKind::Closure( .., args_span, _ diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 76ba6ae5de6ee..14c366b762832 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -137,7 +137,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( let attributes = tcx.get_attrs(def_id); let param_env = tcx.param_env(def_id); let id = tcx - .hir + .hir() .as_local_node_id(def_id) .expect("do_mir_borrowck: non-local DefId"); @@ -173,7 +173,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( |bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]), )); - let locals_are_invalidated_at_exit = match tcx.hir.body_owner_kind(id) { + let locals_are_invalidated_at_exit = match tcx.hir().body_owner_kind(id) { hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => false, hir::BodyOwnerKind::Fn => true, }; @@ -229,7 +229,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( |bd, i| DebugFormatted::new(&bd.move_data().inits[i]), )); - let movable_generator = match tcx.hir.get(id) { + let movable_generator = match tcx.hir().get(id) { Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)), .. diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs index a556199b875bf..1811333e445b6 100644 --- a/src/librustc_mir/borrow_check/move_errors.rs +++ b/src/librustc_mir/borrow_check/move_errors.rs @@ -319,8 +319,8 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { let upvar_hir_id = upvar_decl.var_hir_id.assert_crate_local(); let upvar_node_id = - self.infcx.tcx.hir.hir_to_node_id(upvar_hir_id); - let upvar_span = self.infcx.tcx.hir.span(upvar_node_id); + self.infcx.tcx.hir().hir_to_node_id(upvar_hir_id); + let upvar_span = self.infcx.tcx.hir().span(upvar_node_id); diag.span_label(upvar_span, "captured outer variable"); break; } diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index 4bcabfef4fd7f..ab819aafc47c7 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -317,8 +317,8 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { let upvar_hir_id = self.mir.upvar_decls[upvar_index.index()] .var_hir_id .assert_crate_local(); - let upvar_node_id = self.infcx.tcx.hir.hir_to_node_id(upvar_hir_id); - if let Some(Node::Binding(pat)) = self.infcx.tcx.hir.find(upvar_node_id) { + let upvar_node_id = self.infcx.tcx.hir().hir_to_node_id(upvar_hir_id); + if let Some(Node::Binding(pat)) = self.infcx.tcx.hir().find(upvar_node_id) { if let hir::PatKind::Binding( hir::BindingAnnotation::Unannotated, _, @@ -641,8 +641,8 @@ fn annotate_struct_field( if let ty::TyKind::Adt(def, _) = ty.sty { let field = def.all_fields().nth(field.index())?; // Use the HIR types to construct the diagnostic message. - let node_id = tcx.hir.as_local_node_id(field.did)?; - let node = tcx.hir.find(node_id)?; + let node_id = tcx.hir().as_local_node_id(field.did)?; + let node = tcx.hir().find(node_id)?; // Now we're dealing with the actual struct that we're going to suggest a change to, // we can expect a field that is an immutable reference to a type. if let hir::Node::Field(field) = node { diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index 0c4140caee86f..cd4694351ad0e 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -176,7 +176,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( // Dump facts if requested. let polonius_output = all_facts.and_then(|all_facts| { if infcx.tcx.sess.opts.debugging_opts.nll_facts { - let def_path = infcx.tcx.hir.def_path(def_id); + let def_path = infcx.tcx.hir().def_path(def_id); let dir_path = PathBuf::from("nll-facts").join(def_path.to_filename_friendly_no_crate()); all_facts.write_to_dir(dir_path, location_table).unwrap(); diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index a32fb0503a814..655704ec06529 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -226,12 +226,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { }, ty::BoundRegion::BrEnv => { - let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir"); + let mir_node_id = tcx.hir() + .as_local_node_id(mir_def_id) + .expect("non-local mir"); let def_ty = self.universal_regions.defining_ty; if let DefiningTy::Closure(def_id, substs) = def_ty { let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) = - tcx.hir.expect_expr(mir_node_id).node + tcx.hir().expect_expr(mir_node_id).node { span } else { @@ -302,10 +304,10 @@ impl<'tcx> RegionInferenceContext<'tcx> { name: &InternedString, ) -> Span { let scope = error_region.free_region_binding_scope(tcx); - let node = tcx.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID); + let node = tcx.hir().as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID); - let span = tcx.sess.source_map().def_span(tcx.hir.span(node)); - if let Some(param) = tcx.hir + let span = tcx.sess.source_map().def_span(tcx.hir().span(node)); + if let Some(param) = tcx.hir() .get_generics(scope) .and_then(|generics| generics.get_named(name)) { @@ -361,8 +363,8 @@ impl<'tcx> RegionInferenceContext<'tcx> { argument_index: usize, counter: &mut usize, ) -> Option { - let mir_node_id = infcx.tcx.hir.as_local_node_id(mir_def_id)?; - let fn_decl = infcx.tcx.hir.fn_decl(mir_node_id)?; + let mir_node_id = infcx.tcx.hir().as_local_node_id(mir_def_id)?; + let fn_decl = infcx.tcx.hir().fn_decl(mir_node_id)?; let argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index]; match argument_hir_ty.node { // This indicates a variable with no type annotation, like @@ -685,9 +687,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { let type_name = with_highlight_region_for_regionvid( fr, *counter, || infcx.extract_type_name(&return_ty)); - let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir"); + let mir_node_id = tcx.hir().as_local_node_id(mir_def_id).expect("non-local mir"); - let (return_span, mir_description) = match tcx.hir.get(mir_node_id) { + let (return_span, mir_description) = match tcx.hir().get(mir_node_id) { hir::Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, _, _, span, gen_move), .. diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs index 73fa1b0cfb78d..5cd3d5fbc73a1 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs @@ -81,11 +81,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { upvar_index: usize, ) -> (Symbol, Span) { let upvar_hir_id = mir.upvar_decls[upvar_index].var_hir_id.assert_crate_local(); - let upvar_node_id = tcx.hir.hir_to_node_id(upvar_hir_id); + let upvar_node_id = tcx.hir().hir_to_node_id(upvar_hir_id); debug!("get_upvar_name_and_span_for_region: upvar_node_id={:?}", upvar_node_id); - let upvar_name = tcx.hir.name(upvar_node_id); - let upvar_span = tcx.hir.span(upvar_node_id); + let upvar_name = tcx.hir().name(upvar_node_id); + let upvar_span = tcx.hir().span(upvar_node_id); debug!("get_upvar_name_and_span_for_region: upvar_name={:?} upvar_span={:?}", upvar_name, upvar_span); diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index c54a4f96b7dcf..97fdb80cc78a5 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -210,8 +210,8 @@ impl<'tcx> UniversalRegions<'tcx> { param_env: ty::ParamEnv<'tcx>, ) -> Self { let tcx = infcx.tcx; - let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).unwrap(); - let mir_hir_id = tcx.hir.node_to_hir_id(mir_node_id); + let mir_node_id = tcx.hir().as_local_node_id(mir_def_id).unwrap(); + let mir_hir_id = tcx.hir().node_to_hir_id(mir_node_id); UniversalRegionsBuilder { infcx, mir_def_id, @@ -485,7 +485,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { let tcx = self.infcx.tcx; let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id); - match tcx.hir.body_owner_kind(self.mir_node_id) { + match tcx.hir().body_owner_kind(self.mir_node_id) { BodyOwnerKind::Fn => { let defining_ty = if self.mir_def_id == closure_base_def_id { tcx.type_of(closure_base_def_id) @@ -780,9 +780,9 @@ fn for_each_late_bound_region_defined_on<'tcx>( owner: fn_def_id.index, local_id: *late_bound, }; - let region_node_id = tcx.hir.hir_to_node_id(hir_id); - let name = tcx.hir.name(region_node_id).as_interned_str(); - let region_def_id = tcx.hir.local_def_id(region_node_id); + let region_node_id = tcx.hir().hir_to_node_id(hir_id); + let name = tcx.hir().name(region_node_id).as_interned_str(); + let region_def_id = tcx.hir().local_def_id(region_node_id); let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion { scope: fn_def_id, bound_region: ty::BoundRegion::BrNamed(region_def_id, name), diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 342aaf9039d10..69473ab209184 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -470,7 +470,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ); let place = Place::Local(local_id); let var_ty = self.local_decls[local_id].ty; - let hir_id = self.hir.tcx().hir.node_to_hir_id(var); + let hir_id = self.hir.tcx().hir().node_to_hir_id(var); let region_scope = self.hir.region_scope_tree.var_scope(hir_id.local_id); self.schedule_drop(span, region_scope, &place, var_ty, DropKind::Storage); place @@ -479,7 +479,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { pub fn schedule_drop_for_binding(&mut self, var: NodeId, span: Span, for_guard: ForGuard) { let local_id = self.var_local_id(var, for_guard); let var_ty = self.local_decls[local_id].ty; - let hir_id = self.hir.tcx().hir.node_to_hir_id(var); + let hir_id = self.hir.tcx().hir().node_to_hir_id(var); let region_scope = self.hir.region_scope_tree.var_scope(hir_id.local_id); self.schedule_drop( span, diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 90a204ce00d53..b0601b3bbefb1 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -39,10 +39,10 @@ use super::lints; /// Construct the MIR for a given def-id. pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'tcx> { - let id = tcx.hir.as_local_node_id(def_id).unwrap(); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); // Figure out what primary body this item has. - let (body_id, return_ty_span) = match tcx.hir.get(id) { + let (body_id, return_ty_span) = match tcx.hir().get(id) { Node::Variant(variant) => return create_constructor_shim(tcx, id, &variant.node.data), Node::StructCtor(ctor) => @@ -76,10 +76,10 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t (*body_id, ty.span) } Node::AnonConst(hir::AnonConst { body, id, .. }) => { - (*body, tcx.hir.span(*id)) + (*body, tcx.hir().span(*id)) } - _ => span_bug!(tcx.hir.span(id), "can't build MIR for {:?}", def_id), + _ => span_bug!(tcx.hir().span(id), "can't build MIR for {:?}", def_id), }; tcx.infer_ctxt().enter(|infcx| { @@ -89,9 +89,9 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t } else if let hir::BodyOwnerKind::Fn = cx.body_owner_kind { // fetch the fully liberated fn signature (that is, all bound // types/lifetimes replaced) - let fn_hir_id = tcx.hir.node_to_hir_id(id); + let fn_hir_id = tcx.hir().node_to_hir_id(id); let fn_sig = cx.tables().liberated_fn_sigs()[fn_hir_id].clone(); - let fn_def_id = tcx.hir.local_def_id(id); + let fn_def_id = tcx.hir().local_def_id(id); let ty = tcx.type_of(fn_def_id); let mut abi = fn_sig.abi; @@ -121,18 +121,18 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t hir::Unsafety::Unsafe => Safety::FnUnsafe, }; - let body = tcx.hir.body(body_id); + let body = tcx.hir().body(body_id); let explicit_arguments = body.arguments .iter() .enumerate() .map(|(index, arg)| { - let owner_id = tcx.hir.body_owner(body_id); + let owner_id = tcx.hir().body_owner(body_id); let opt_ty_info; let self_arg; - if let Some(ref fn_decl) = tcx.hir.fn_decl(owner_id) { + if let Some(ref fn_decl) = tcx.hir().fn_decl(owner_id) { let ty_hir_id = fn_decl.inputs[index].hir_id; - let ty_span = tcx.hir.span(tcx.hir.hir_to_node_id(ty_hir_id)); + let ty_span = tcx.hir().span(tcx.hir().hir_to_node_id(ty_hir_id)); opt_ty_info = Some(ty_span); self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() { match fn_decl.implicit_self { @@ -159,7 +159,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t ty::Generator(gen_def_id, gen_substs, ..) => gen_substs.sig(gen_def_id, tcx), _ => - span_bug!(tcx.hir.span(id), "generator w/o generator type: {:?}", ty), + span_bug!(tcx.hir().span(id), "generator w/o generator type: {:?}", ty), }; (Some(gen_sig.yield_ty), gen_sig.return_ty) } else { @@ -246,7 +246,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, v: &'tcx hir::VariantData) -> Mir<'tcx> { - let span = tcx.hir.span(ctor_id); + let span = tcx.hir().span(ctor_id); if let hir::VariantData::Tuple(ref fields, ctor_id) = *v { tcx.infer_ctxt().enter(|infcx| { let mut mir = shim::build_adt_ctor(&infcx, ctor_id, fields, span); @@ -263,7 +263,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; mir_util::dump_mir(tcx, None, "mir_map", &0, - MirSource::item(tcx.hir.local_def_id(ctor_id)), + MirSource::item(tcx.hir().local_def_id(ctor_id)), &mir, |_, _| Ok(()) ); mir @@ -280,7 +280,7 @@ fn liberated_closure_env_ty<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, closure_expr_id: ast::NodeId, body_id: hir::BodyId) -> Ty<'tcx> { - let closure_expr_hir_id = tcx.hir.node_to_hir_id(closure_expr_id); + let closure_expr_hir_id = tcx.hir().node_to_hir_id(closure_expr_id); let closure_ty = tcx.body_tables(body_id).node_id_to_type(closure_expr_hir_id); let (closure_def_id, closure_substs) = match closure_ty.sty { @@ -662,14 +662,14 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, let arguments: Vec<_> = arguments.collect(); let tcx = hir.tcx(); - let span = tcx.hir.span(fn_id); + let span = tcx.hir().span(fn_id); // 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 = fv.var_id(); - let var_hir_id = tcx.hir.node_to_hir_id(var_id); - let closure_expr_id = tcx.hir.local_def_id(fn_id); + let var_hir_id = tcx.hir().node_to_hir_id(var_id); + let closure_expr_id = tcx.hir().local_def_id(fn_id); let capture = hir.tables().upvar_capture(ty::UpvarId { var_path: ty::UpvarPath {hir_id: var_hir_id}, closure_expr_id: LocalDefId::from_def_id(closure_expr_id), @@ -684,7 +684,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, by_ref, mutability: Mutability::Not, }; - if let Some(Node::Binding(pat)) = tcx.hir.find(var_id) { + if let Some(Node::Binding(pat)) = tcx.hir().find(var_id) { if let hir::PatKind::Binding(_, _, ident, _) = pat.node { decl.debug_name = ident.name; @@ -711,7 +711,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, return_ty_span, upvar_decls); - let fn_def_id = tcx.hir.local_def_id(fn_id); + let fn_def_id = tcx.hir().local_def_id(fn_id); let call_site_scope = region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::CallSite @@ -754,7 +754,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, // RustCall pseudo-ABI untuples the last argument. spread_arg = Some(Local::new(arguments.len())); } - let closure_expr_id = tcx.hir.local_def_id(fn_id); + let closure_expr_id = tcx.hir().local_def_id(fn_id); info!("fn_id {:?} has attrs {:?}", closure_expr_id, tcx.get_attrs(closure_expr_id)); @@ -769,10 +769,10 @@ fn construct_const<'a, 'gcx, 'tcx>( ty_span: Span, ) -> Mir<'tcx> { let tcx = hir.tcx(); - let ast_expr = &tcx.hir.body(body_id).value; + let ast_expr = &tcx.hir().body(body_id).value; let ty = hir.tables().expr_ty_adjusted(ast_expr); - let owner_id = tcx.hir.body_owner(body_id); - let span = tcx.hir.span(owner_id); + let owner_id = tcx.hir().body_owner(body_id); + let span = tcx.hir().span(owner_id); let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span,vec![]); let mut block = START_BLOCK; @@ -798,8 +798,8 @@ fn construct_const<'a, 'gcx, 'tcx>( fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>, body_id: hir::BodyId) -> Mir<'tcx> { - let owner_id = hir.tcx().hir.body_owner(body_id); - let span = hir.tcx().hir.span(owner_id); + let owner_id = hir.tcx().hir().body_owner(body_id); + let span = hir.tcx().hir().span(owner_id); let ty = hir.tcx().types.err; let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, span, vec![]); let source_info = builder.source_info(span); diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 2a11f24095b06..7388d11ed6c50 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -322,11 +322,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let same_lint_scopes = tcx.dep_graph.with_ignore(|| { let sets = tcx.lint_levels(LOCAL_CRATE); let parent_hir_id = - tcx.hir.definitions().node_to_hir_id( + tcx.hir().definitions().node_to_hir_id( self.source_scope_local_data[source_scope].lint_root ); let current_hir_id = - tcx.hir.definitions().node_to_hir_id(node_id); + tcx.hir().definitions().node_to_hir_id(node_id); sets.lint_level_set(parent_hir_id) == sets.lint_level_set(current_hir_id) }); diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 291b5c170ef36..248c5d2db4917 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -664,7 +664,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( let cid = key.value; let def_id = cid.instance.def.def_id(); - if let Some(id) = tcx.hir.as_local_node_id(def_id) { + if let Some(id) = tcx.hir().as_local_node_id(def_id) { let tables = tcx.typeck_tables_of(def_id); // Do match-check before building MIR @@ -672,7 +672,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( return Err(ErrorHandled::Reported) } - if let hir::BodyOwnerKind::Const = tcx.hir.body_owner_kind(id) { + if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind(id) { tcx.mir_const_qualif(def_id); } @@ -708,7 +708,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( // because any code that existed before validation could not have failed validation // thus preventing such a hard error from being a backwards compatibility hazard Some(Def::Const(_)) | Some(Def::AssociatedConst(_)) => { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); err.report_as_lint( tcx.at(tcx.def_span(def_id)), "any use of this value will cause an error", @@ -728,7 +728,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( err.report_as_lint( tcx.at(span), "reaching this expression at runtime will panic or abort", - tcx.hir.as_local_node_id(def_id).unwrap(), + tcx.hir().as_local_node_id(def_id).unwrap(), ) } // anything else (array lengths, enum initializers, constant patterns) are reported diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index d56ddcb494406..beb035d82b1c8 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -55,9 +55,9 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, -> Vec> { let mut result = vec![]; for (index, stmt) in stmts.iter().enumerate() { - let hir_id = cx.tcx.hir.node_to_hir_id(stmt.node.id()); + let hir_id = cx.tcx.hir().node_to_hir_id(stmt.node.id()); let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id); - let stmt_span = StatementSpan(cx.tcx.hir.span(stmt.node.id())); + let stmt_span = StatementSpan(cx.tcx.hir().span(stmt.node.id())); match stmt.node { hir::StmtKind::Expr(ref expr, _) | hir::StmtKind::Semi(ref expr, _) => { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 2e9edf20c5708..a772f44673035 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -556,7 +556,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, // Now comes the rote stuff: hir::ExprKind::Repeat(ref v, ref count) => { - let def_id = cx.tcx.hir.local_def_id(count.id); + let def_id = cx.tcx.hir().local_def_id(count.id); let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id); let instance = ty::Instance::resolve( cx.tcx.global_tcx(), @@ -588,7 +588,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, match dest.target_id { Ok(target_id) => ExprKind::Break { label: region::Scope { - id: cx.tcx.hir.node_to_hir_id(target_id).local_id, + id: cx.tcx.hir().node_to_hir_id(target_id).local_id, data: region::ScopeData::Node }, value: value.to_ref(), @@ -600,7 +600,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, match dest.target_id { Ok(loop_id) => ExprKind::Continue { label: region::Scope { - id: cx.tcx.hir.node_to_hir_id(loop_id).local_id, + id: cx.tcx.hir().node_to_hir_id(loop_id).local_id, data: region::ScopeData::Node }, }, @@ -974,17 +974,17 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, var_id, index, closure_expr_id); - let var_hir_id = cx.tcx.hir.node_to_hir_id(var_id); + let var_hir_id = cx.tcx.hir().node_to_hir_id(var_id); let var_ty = cx.tables().node_id_to_type(var_hir_id); // FIXME free regions in closures are not right let closure_ty = cx.tables() - .node_id_to_type(cx.tcx.hir.node_to_hir_id(closure_expr_id)); + .node_id_to_type(cx.tcx.hir().node_to_hir_id(closure_expr_id)); // FIXME we're just hard-coding the idea that the // signature will be &self or &mut self and hence will // have a bound region with number 0 - let closure_def_id = cx.tcx.hir.local_def_id(closure_expr_id); + let closure_def_id = cx.tcx.hir().local_def_id(closure_expr_id); let region = ty::ReFree(ty::FreeRegion { scope: closure_def_id, bound_region: ty::BoundRegion::BrAnon(0), @@ -1176,10 +1176,10 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, freevar: &hir::Freevar, freevar_ty: Ty<'tcx>) -> ExprRef<'tcx> { - let var_hir_id = cx.tcx.hir.node_to_hir_id(freevar.var_id()); + let var_hir_id = cx.tcx.hir().node_to_hir_id(freevar.var_id()); let upvar_id = ty::UpvarId { var_path: ty::UpvarPath { hir_id: var_hir_id }, - closure_expr_id: cx.tcx.hir.local_def_id(closure_expr.id).to_local(), + closure_expr_id: cx.tcx.hir().local_def_id(closure_expr.id).to_local(), }; let upvar_capture = cx.tables().upvar_capture(upvar_id); let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id); diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index c414088b65322..a0b2d99dfd305 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -62,8 +62,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, src_id: ast::NodeId) -> Cx<'a, 'gcx, 'tcx> { let tcx = infcx.tcx; - let src_def_id = tcx.hir.local_def_id(src_id); - let body_owner_kind = tcx.hir.body_owner_kind(src_id); + let src_def_id = tcx.hir().local_def_id(src_id); + let body_owner_kind = tcx.hir().body_owner_kind(src_id); let constness = match body_owner_kind { hir::BodyOwnerKind::Const | @@ -71,7 +71,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { hir::BodyOwnerKind::Fn => hir::Constness::NotConst, }; - let attrs = tcx.hir.attrs(src_id); + let attrs = tcx.hir().attrs(src_id); // Some functions always have overflow checks enabled, // however, they may not get codegen'd, depending on @@ -157,7 +157,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> { let tcx = self.tcx.global_tcx(); - let p = match tcx.hir.get(p.id) { + let p = match tcx.hir().get(p.id) { Node::Pat(p) | Node::Binding(p) => p, node => bug!("pattern became {:?}", node) }; @@ -202,7 +202,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { } fn lint_level_of(&self, node_id: ast::NodeId) -> LintLevel { - let hir_id = self.tcx.hir.definitions().node_to_hir_id(node_id); + let hir_id = self.tcx.hir().definitions().node_to_hir_id(node_id); let has_lint_level = self.tcx.dep_graph.with_ignore(|| { self.tcx.lint_levels(LOCAL_CRATE).lint_level_set(hir_id).is_some() }); @@ -253,11 +253,11 @@ fn lint_level_for_hir_id(tcx: TyCtxt, mut id: ast::NodeId) -> ast::NodeId { tcx.dep_graph.with_ignore(|| { let sets = tcx.lint_levels(LOCAL_CRATE); loop { - let hir_id = tcx.hir.definitions().node_to_hir_id(id); + let hir_id = tcx.hir().definitions().node_to_hir_id(id); if sets.lint_level_set(hir_id).is_some() { return id } - let next = tcx.hir.get_parent_node(id); + let next = tcx.hir().get_parent_node(id); if next == id { bug!("lint traversal reached the root of the crate"); } diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index db6d9b6a427f7..4d38d207c4786 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -41,18 +41,18 @@ 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.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_body(&mut self, body: &'tcx hir::Body) { intravisit::walk_body(self, body); - let def_id = self.tcx.hir.body_owner_def_id(body.id()); + let def_id = self.tcx.hir().body_owner_def_id(body.id()); let _ = self.tcx.check_match(def_id); } } pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx }.as_deep_visitor()); + tcx.hir().krate().visit_all_item_likes(&mut OuterVisitor { tcx }.as_deep_visitor()); tcx.sess.abort_if_errors(); } @@ -60,8 +60,8 @@ pub(crate) fn check_match<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, ) -> Result<(), ErrorReported> { - let body_id = if let Some(id) = tcx.hir.as_local_node_id(def_id) { - tcx.hir.body_owned_by(id) + let body_id = if let Some(id) = tcx.hir().as_local_node_id(def_id) { + tcx.hir().body_owned_by(id) } else { return Ok(()); }; @@ -73,7 +73,7 @@ pub(crate) fn check_match<'a, 'tcx>( region_scope_tree: &tcx.region_scope_tree(def_id), param_env: tcx.param_env(def_id), identity_substs: Substs::identity_for_item(tcx, def_id), - }.visit_body(tcx.hir.body(body_id)); + }.visit_body(tcx.hir().body(body_id)); }) } @@ -192,7 +192,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { } } - let module = self.tcx.hir.get_module_parent(scrut.id); + let module = self.tcx.hir().get_module_parent(scrut.id); MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| { let mut have_errors = false; @@ -224,7 +224,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { // Then, if the match has no arms, check whether the scrutinee // is uninhabited. let pat_ty = self.tables.node_id_to_type(scrut.hir_id); - let module = self.tcx.hir.get_module_parent(scrut.id); + let module = self.tcx.hir().get_module_parent(scrut.id); if inlined_arms.is_empty() { let scrutinee_is_uninhabited = if self.tcx.features().exhaustive_patterns { self.tcx.is_ty_uninhabited_from(module, pat_ty) @@ -267,7 +267,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { } fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) { - let module = self.tcx.hir.get_module_parent(pat.id); + let module = self.tcx.hir().get_module_parent(pat.id); MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| { let mut patcx = PatternContext::new(self.tcx, self.param_env.and(self.identity_substs), diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 61d8297fec90e..5d2f7ec507b7a 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -954,7 +954,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { }; let kind = match cv.ty.sty { ty::Float(_) => { - let id = self.tcx.hir.hir_to_node_id(id); + let id = self.tcx.hir().hir_to_node_id(id); self.tcx.lint_node( ::rustc::lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, id, diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs index 4c7938504c10f..232468fefe201 100644 --- a/src/librustc_mir/lints.rs +++ b/src/librustc_mir/lints.rs @@ -20,9 +20,9 @@ use rustc::ty::subst::Substs; pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &Mir<'tcx>, def_id: DefId) { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); - if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir.get(node_id)) { + if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir().get(node_id)) { check_fn_for_unconditional_recursion(tcx, fn_like_node.kind(), mir, def_id); } } @@ -139,8 +139,8 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, // no break */ }`) shouldn't be linted unless it actually // recurs. if !reached_exit_without_self_call && !self_call_locations.is_empty() { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let sp = tcx.sess.source_map().def_span(tcx.hir.span(node_id)); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let sp = tcx.sess.source_map().def_span(tcx.hir().span(node_id)); let mut db = tcx.struct_span_lint_node(UNCONDITIONAL_RECURSION, node_id, sp, diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 7531f62fdab7b..7890b926948c2 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -332,7 +332,7 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, { let entry_fn = tcx.sess.entry_fn.borrow().map(|(node_id, _, _)| { - tcx.hir.local_def_id(node_id) + tcx.hir().local_def_id(node_id) }); debug!("collect_roots: entry_fn = {:?}", entry_fn); @@ -344,7 +344,7 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, output: &mut roots, }; - tcx.hir.krate().visit_all_item_likes(&mut visitor); + tcx.hir().krate().visit_all_item_likes(&mut visitor); visitor.push_extra_entry_roots(); } @@ -462,8 +462,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.hir.as_local_node_id(def_id) { - tcx.sess.span_fatal(tcx.hir.span(node_id), &error); + if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { + tcx.sess.span_fatal(tcx.hir().span(node_id), &error); } else { tcx.sess.fatal(&error); } @@ -494,8 +494,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.hir.as_local_node_id(instance.def_id()) { - tcx.sess.struct_span_fatal(tcx.hir.span(node_id), &msg) + let mut diag = if let Some(node_id) = tcx.hir().as_local_node_id(instance.def_id()) { + tcx.sess.struct_span_fatal(tcx.hir().span(node_id), &msg) } else { tcx.sess.struct_fatal(&msg) }; @@ -961,7 +961,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { hir::ItemKind::Union(_, ref generics) => { if generics.params.is_empty() { if self.mode == MonoItemCollectionMode::Eager { - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); debug!("RootCollector: ADT drop-glue for {}", def_id_to_string(self.tcx, def_id)); @@ -973,11 +973,11 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { hir::ItemKind::GlobalAsm(..) => { debug!("RootCollector: ItemKind::GlobalAsm({})", def_id_to_string(self.tcx, - self.tcx.hir.local_def_id(item.id))); + self.tcx.hir().local_def_id(item.id))); self.output.push(MonoItem::GlobalAsm(item.id)); } hir::ItemKind::Static(..) => { - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); debug!("RootCollector: ItemKind::Static({})", def_id_to_string(self.tcx, def_id)); self.output.push(MonoItem::Static(def_id)); @@ -987,7 +987,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { // actually used somewhere. Just declaring them is insufficient. // but even just declaring them must collect the items they refer to - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); let instance = Instance::mono(self.tcx, def_id); let cid = GlobalId { @@ -1001,7 +1001,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { } } hir::ItemKind::Fn(..) => { - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); self.push_if_root(def_id); } } @@ -1015,7 +1015,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) { match ii.node { hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => { - let def_id = self.tcx.hir.local_def_id(ii.id); + let def_id = self.tcx.hir().local_def_id(ii.id); self.push_if_root(def_id); } _ => { /* Nothing to do here */ } @@ -1108,7 +1108,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } - let impl_def_id = tcx.hir.local_def_id(item.id); + let impl_def_id = tcx.hir().local_def_id(item.id); debug!("create_mono_items_for_default_impls(item={})", def_id_to_string(tcx, impl_def_id)); diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 24de92e79f0e4..2bc6e93c8c1a9 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -68,7 +68,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug { tcx.symbol_name(Instance::mono(tcx, def_id)) } MonoItem::GlobalAsm(node_id) => { - let def_id = tcx.hir.local_def_id(node_id); + let def_id = tcx.hir().local_def_id(node_id); ty::SymbolName { name: Symbol::intern(&format!("global_asm_{:?}", def_id)).as_interned_str() } @@ -86,7 +86,7 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug { match *self.as_mono_item() { MonoItem::Fn(ref instance) => { let entry_def_id = - tcx.sess.entry_fn.borrow().map(|(id, _, _)| tcx.hir.local_def_id(id)); + tcx.sess.entry_fn.borrow().map(|(id, _, _)| tcx.hir().local_def_id(id)); // If this function isn't inlined or otherwise has explicit // linkage, then we'll be creating a globally shared version. if self.explicit_linkage(tcx).is_some() || @@ -199,15 +199,15 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug { fn local_span(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option { match *self.as_mono_item() { MonoItem::Fn(Instance { def, .. }) => { - tcx.hir.as_local_node_id(def.def_id()) + tcx.hir().as_local_node_id(def.def_id()) } MonoItem::Static(def_id) => { - tcx.hir.as_local_node_id(def_id) + tcx.hir().as_local_node_id(def_id) } MonoItem::GlobalAsm(node_id) => { Some(node_id) } - }.map(|node_id| tcx.hir.span(node_id)) + }.map(|node_id| tcx.hir().span(node_id)) } } diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index 528942df29fee..efe6f6dd6fefa 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -184,7 +184,7 @@ pub trait CodegenUnitExt<'tcx> { // the codegen tests and can even make item order // unstable. InstanceDef::Item(def_id) => { - tcx.hir.as_local_node_id(def_id) + tcx.hir().as_local_node_id(def_id) } InstanceDef::VtableShim(..) | InstanceDef::Intrinsic(..) | @@ -198,7 +198,7 @@ pub trait CodegenUnitExt<'tcx> { } } MonoItem::Static(def_id) => { - tcx.hir.as_local_node_id(def_id) + tcx.hir().as_local_node_id(def_id) } MonoItem::GlobalAsm(node_id) => { Some(node_id) @@ -415,7 +415,7 @@ fn mono_item_visibility( }; } MonoItem::GlobalAsm(node_id) => { - let def_id = tcx.hir.local_def_id(*node_id); + let def_id = tcx.hir().local_def_id(*node_id); return if tcx.is_reachable_non_generic(def_id) { *can_be_internalized = false; default_visibility(tcx, def_id, false) @@ -799,7 +799,7 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Some(def_id) } MonoItem::Static(def_id) => Some(def_id), - MonoItem::GlobalAsm(node_id) => Some(tcx.hir.local_def_id(node_id)), + MonoItem::GlobalAsm(node_id) => Some(tcx.hir().local_def_id(node_id)), } } diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 3a53cc6eaea71..114162946051e 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -860,7 +860,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>, { let tcx = infcx.tcx; let gcx = tcx.global_tcx(); - let def_id = tcx.hir.local_def_id(ctor_id); + let def_id = tcx.hir().local_def_id(ctor_id); let param_env = gcx.param_env(def_id); // Normalize the sig. diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 75f8045cfae99..660892c0a5f88 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -473,8 +473,8 @@ fn check_unused_unsafe<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, unsafe_blocks: &'a mut Vec<(ast::NodeId, bool)>) { let body_id = - tcx.hir.as_local_node_id(def_id).and_then(|node_id| { - tcx.hir.maybe_body_owned_by(node_id) + tcx.hir().as_local_node_id(def_id).and_then(|node_id| { + tcx.hir().maybe_body_owned_by(node_id) }); let body_id = match body_id { @@ -484,7 +484,7 @@ fn check_unused_unsafe<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, return } }; - let body = tcx.hir.body(body_id); + let body = tcx.hir().body(body_id); debug!("check_unused_unsafe({:?}, body={:?}, used_unsafe={:?})", def_id, body, used_unsafe); @@ -526,7 +526,7 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) } fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { - let lint_node_id = match tcx.hir.as_local_node_id(def_id) { + let lint_node_id = match tcx.hir().as_local_node_id(def_id) { Some(node_id) => node_id, None => bug!("checking unsafety for non-local def id {:?}", def_id) }; @@ -550,14 +550,14 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D fn is_enclosed(tcx: TyCtxt, used_unsafe: &FxHashSet, id: ast::NodeId) -> Option<(String, ast::NodeId)> { - let parent_id = tcx.hir.get_parent_node(id); + let parent_id = tcx.hir().get_parent_node(id); if parent_id != id { if used_unsafe.contains(&parent_id) { Some(("block".to_string(), parent_id)) } else if let Some(Node::Item(&hir::Item { node: hir::ItemKind::Fn(_, header, _, _), .. - })) = tcx.hir.find(parent_id) { + })) = tcx.hir().find(parent_id) { match header.unsafety { hir::Unsafety::Unsafe => Some(("fn".to_string(), parent_id)), hir::Unsafety::Normal => None, @@ -571,12 +571,12 @@ fn is_enclosed(tcx: TyCtxt, } fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet, id: ast::NodeId) { - let span = tcx.sess.source_map().def_span(tcx.hir.span(id)); + let span = tcx.sess.source_map().def_span(tcx.hir().span(id)); let msg = "unnecessary `unsafe` block"; let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg); db.span_label(span, msg); if let Some((kind, id)) = is_enclosed(tcx, used_unsafe, id) { - db.span_label(tcx.sess.source_map().def_span(tcx.hir.span(id)), + db.span_label(tcx.sess.source_map().def_span(tcx.hir().span(id)), format!("because it's nested under this `unsafe` {}", kind)); } db.emit(); diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index f21efaa048bb8..5e00dea5a0562 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -47,10 +47,10 @@ impl MirPass for ConstProp { } use rustc::hir::map::blocks::FnLikeNode; - let node_id = tcx.hir.as_local_node_id(source.def_id) + let node_id = tcx.hir().as_local_node_id(source.def_id) .expect("Non-local call to local provider is_const_fn"); - let is_fn_like = FnLikeNode::from_node(tcx.hir.get(node_id)).is_some(); + let is_fn_like = FnLikeNode::from_node(tcx.hir().get(node_id)).is_some(); let is_assoc_const = match tcx.describe_def(source.def_id) { Some(Def::AssociatedConst(_)) => true, _ => false, @@ -618,7 +618,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> { .span; let node_id = self .tcx - .hir + .hir() .as_local_node_id(self.source.def_id) .expect("some part of a failing const eval must be local"); use rustc::mir::interpret::EvalErrorKind::*; diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 2b3fd552e0faa..c8056ea3e1f94 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -38,7 +38,7 @@ impl MirPass for ElaborateDrops { { debug!("elaborate_drops({:?} @ {:?})", src, mir.span); - let id = tcx.hir.as_local_node_id(src.def_id).unwrap(); + let id = tcx.hir().as_local_node_id(src.def_id).unwrap(); let param_env = tcx.param_env(src.def_id).with_reveal_all(); let move_data = match MoveData::gather_moves(mir, tcx) { Ok(move_data) => move_data, diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 24cc4cce747e0..f870e4a2a4227 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -379,7 +379,7 @@ fn locals_live_across_suspend_points( FxHashMap>, ) { let dead_unwinds = BitSet::new_empty(mir.basic_blocks().len()); - let node_id = tcx.hir.as_local_node_id(source.def_id).unwrap(); + let node_id = tcx.hir().as_local_node_id(source.def_id).unwrap(); // Calculate when MIR locals have live storage. This gives us an upper bound of their // lifetimes. diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index ab71cefd434bd..0348ea5b81976 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -83,8 +83,8 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { let param_env = self.tcx.param_env(self.source.def_id); // Only do inlining into fn bodies. - let id = self.tcx.hir.as_local_node_id(self.source.def_id).unwrap(); - let body_owner_kind = self.tcx.hir.body_owner_kind(id); + let id = self.tcx.hir().as_local_node_id(self.source.def_id).unwrap(); + let body_owner_kind = self.tcx.hir().body_owner_kind(id); if let (hir::BodyOwnerKind::Fn, None) = (body_owner_kind, self.source.promoted) { diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index a77e9b502ac26..005c1a08affd5 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -91,7 +91,7 @@ fn mir_keys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: CrateNum) _: ast::NodeId, _: Span) { if let hir::VariantData::Tuple(_, node_id) = *v { - self.set.insert(self.tcx.hir.local_def_id(node_id)); + self.set.insert(self.tcx.hir().local_def_id(node_id)); } intravisit::walk_struct_def(self, v) } @@ -99,7 +99,7 @@ fn mir_keys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: CrateNum) NestedVisitorMap::None } } - tcx.hir.krate().visit_all_item_likes(&mut GatherCtors { + tcx.hir().krate().visit_all_item_likes(&mut GatherCtors { tcx, set: &mut set, }.as_deep_visitor()); @@ -219,8 +219,8 @@ fn mir_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Stea } fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Steal> { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - if let hir::BodyOwnerKind::Const = tcx.hir.body_owner_kind(node_id) { + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind(node_id) { // Ensure that we compute the `mir_const_qualif` for constants at // this point, before we steal the mir-const result. let _ = tcx.mir_const_qualif(def_id); diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index bcee6d75b5a4a..034096fe889a3 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -1293,9 +1293,9 @@ impl MirPass for QualifyAndPromoteConstants { } let def_id = src.def_id; - let id = tcx.hir.as_local_node_id(def_id).unwrap(); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); let mut const_promoted_temps = None; - let mode = match tcx.hir.body_owner_kind(id) { + let mode = match tcx.hir().body_owner_kind(id) { hir::BodyOwnerKind::Fn => { if tcx.is_const_fn(def_id) { Mode::ConstFn diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index f852195b8351a..c996dc285f7e7 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -34,7 +34,7 @@ impl MirPass for SanityCheck { fn run_pass<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, src: MirSource, mir: &mut Mir<'tcx>) { let def_id = src.def_id; - let id = tcx.hir.as_local_node_id(def_id).unwrap(); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); if !tcx.has_attr(def_id, "rustc_mir") { debug!("skipping rustc_peek::SanityCheck on {}", tcx.item_path_str(def_id)); return; diff --git a/src/librustc_mir/util/graphviz.rs b/src/librustc_mir/util/graphviz.rs index 0b883f68bff40..58963a40ad09e 100644 --- a/src/librustc_mir/util/graphviz.rs +++ b/src/librustc_mir/util/graphviz.rs @@ -38,7 +38,7 @@ pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, w: &mut W) -> io::Result<()> where W: Write { - writeln!(w, "digraph Mir_{} {{", tcx.hir.as_local_node_id(def_id).unwrap())?; + writeln!(w, "digraph Mir_{} {{", tcx.hir().as_local_node_id(def_id).unwrap())?; // Global graph properties writeln!(w, r#" graph [fontname="monospace"];"#)?; diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index 12c13b8f81531..22cc8ead478a9 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -343,7 +343,7 @@ fn dump_matched_mir_node<'a, 'tcx, V: Idx>( ) { let mut file_path = PathBuf::new(); file_path.push(Path::new(&tcx.sess.opts.debugging_opts.dump_mir_dir)); - let item_id = tcx.hir.as_local_node_id(source.def_id).unwrap(); + let item_id = tcx.hir().as_local_node_id(source.def_id).unwrap(); let file_name = format!("rustc.node{}{}-liveness.mir", item_id, pass_name); file_path.push(&file_name); let _ = fs::File::create(&file_path).and_then(|mut file| { diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 2d7e7d01274f6..0db9b23925a1f 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -193,7 +193,7 @@ fn dump_path( let mut file_path = PathBuf::new(); file_path.push(Path::new(&tcx.sess.opts.debugging_opts.dump_mir_dir)); - let item_name = tcx.hir + let item_name = tcx.hir() .def_path(source.def_id) .to_filename_friendly_no_crate(); @@ -569,8 +569,8 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>( } fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut dyn Write) -> io::Result<()> { - let id = tcx.hir.as_local_node_id(src.def_id).unwrap(); - let body_owner_kind = tcx.hir.body_owner_kind(id); + let id = tcx.hir().as_local_node_id(src.def_id).unwrap(); + let body_owner_kind = tcx.hir().body_owner_kind(id); match (body_owner_kind, src.promoted) { (_, Some(i)) => write!(w, "{:?} in", i)?, (hir::BodyOwnerKind::Fn, _) => write!(w, "fn")?, diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 099c6df32ad18..b41a04e354d27 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -50,8 +50,8 @@ pub fn provide(providers: &mut Providers) { } pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - for &body_id in &tcx.hir.krate().body_ids { - let def_id = tcx.hir.body_owner_def_id(body_id); + for &body_id in &tcx.hir().krate().body_ids { + let def_id = tcx.hir().body_owner_def_id(body_id); tcx.const_is_rvalue_promotable_to_static(def_id); } tcx.sess.abort_if_errors(); @@ -63,10 +63,10 @@ fn const_is_rvalue_promotable_to_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, { assert!(def_id.is_local()); - let node_id = tcx.hir.as_local_node_id(def_id) + let node_id = tcx.hir().as_local_node_id(def_id) .expect("rvalue_promotable_map invoked with non-local def-id"); - let body_id = tcx.hir.body_owned_by(node_id); - let body_hir_id = tcx.hir.node_to_hir_id(body_id.node_id); + let body_id = tcx.hir().body_owned_by(node_id); + let body_hir_id = tcx.hir().node_to_hir_id(body_id.node_id); tcx.rvalue_promotable_map(def_id).contains(&body_hir_id.local_id) } @@ -91,9 +91,9 @@ fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; // `def_id` should be a `Body` owner - let node_id = tcx.hir.as_local_node_id(def_id) + let node_id = tcx.hir().as_local_node_id(def_id) .expect("rvalue_promotable_map invoked with non-local def-id"); - let body_id = tcx.hir.body_owned_by(node_id); + let body_id = tcx.hir().body_owned_by(node_id); let _ = visitor.check_nested_body(body_id); Lrc::new(visitor.result) @@ -189,8 +189,8 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> { impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { fn check_nested_body(&mut self, body_id: hir::BodyId) -> Promotability { - let item_id = self.tcx.hir.body_owner(body_id); - let item_def_id = self.tcx.hir.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 outer_in_fn = self.in_fn; let outer_tables = self.tables; @@ -200,7 +200,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { self.in_fn = false; self.in_static = false; - match self.tcx.hir.body_owner_kind(item_id) { + match self.tcx.hir().body_owner_kind(item_id) { hir::BodyOwnerKind::Fn => self.in_fn = true, hir::BodyOwnerKind::Static(_) => self.in_static = true, _ => {} @@ -211,7 +211,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { self.param_env = self.tcx.param_env(item_def_id); self.identity_substs = Substs::identity_for_item(self.tcx, item_def_id); - let body = self.tcx.hir.body(body_id); + let body = self.tcx.hir().body(body_id); let tcx = self.tcx; let param_env = self.param_env; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 6d9abbf5af2ac..ccdcfe322b1c2 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -60,7 +60,7 @@ struct PubRestrictedVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> Visitor<'tcx> for PubRestrictedVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::All(&self.tcx.hir) + NestedVisitorMap::All(&self.tcx.hir()) } fn visit_vis(&mut self, vis: &'tcx hir::Visibility) { self.has_pub_restricted = self.has_pub_restricted || vis.node.is_pub_restricted(); @@ -97,7 +97,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { ty::Projection(ref proj) => proj.trait_ref(self.tcx).def_id, _ => return Some(AccessLevel::Public) }; - if let Some(node_id) = self.tcx.hir.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) @@ -106,7 +106,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.hir.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); } } @@ -134,7 +134,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> { -> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> { ReachEverythingInTheInterfaceVisitor { access_level: self.prev_level.map(|l| l.min(AccessLevel::Reachable)), - item_def_id: self.tcx.hir.local_def_id(item_id), + item_def_id: self.tcx.hir().local_def_id(item_id), ev: self, } } @@ -144,14 +144,14 @@ 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.hir) + 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::ItemKind::Impl(..) => { - let def_id = self.tcx.hir.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)) } // Foreign mods inherit level from parents @@ -220,7 +220,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { // It (and its children) are revisited if the change applies. hir::ItemKind::Existential(ref ty_data) => { if let Some(impl_trait_fn) = ty_data.impl_trait_fn { - if let Some(node_id) = self.tcx.hir.as_local_node_id(impl_trait_fn) { + if let Some(node_id) = self.tcx.hir().as_local_node_id(impl_trait_fn) { self.update(node_id, Some(AccessLevel::ReachableFromImplTrait)); } } @@ -358,12 +358,12 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { // This code is here instead of in visit_item so that the // crate module gets processed as well. if self.prev_level.is_some() { - let def_id = self.tcx.hir.local_def_id(id); + let def_id = self.tcx.hir().local_def_id(id); if let Some(exports) = self.tcx.module_exports(def_id) { for export in exports.iter() { if export.vis == ty::Visibility::Public { if let Some(def_id) = export.def.opt_def_id() { - if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { + if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) { self.update(node_id, Some(AccessLevel::Exported)); } } @@ -381,8 +381,11 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { return } - let module_did = ty::DefIdTree::parent(self.tcx, self.tcx.hir.local_def_id(md.id)).unwrap(); - let mut module_id = self.tcx.hir.as_local_node_id(module_did).unwrap(); + let module_did = ty::DefIdTree::parent( + self.tcx, + self.tcx.hir().local_def_id(md.id) + ).unwrap(); + let mut module_id = self.tcx.hir().as_local_node_id(module_did).unwrap(); let level = if md.vis.node.is_pub() { self.get(module_id) } else { None }; let level = self.update(md.id, level); if level.is_none() { @@ -391,9 +394,9 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { loop { let module = if module_id == ast::CRATE_NODE_ID { - &self.tcx.hir.krate().module - } else if let hir::ItemKind::Mod(ref module) = self.tcx.hir.expect_item(module_id).node - { + &self.tcx.hir().krate().module + } else if let hir::ItemKind::Mod(ref module) = + self.tcx.hir().expect_item(module_id).node { module } else { unreachable!() @@ -401,10 +404,10 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { for id in &module.item_ids { self.update(id.id, level); } - let def_id = self.tcx.hir.local_def_id(module_id); + let def_id = self.tcx.hir().local_def_id(module_id); if let Some(exports) = self.tcx.module_exports(def_id) { for export in exports.iter() { - if let Some(node_id) = self.tcx.hir.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, level); } } @@ -413,7 +416,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { if module_id == ast::CRATE_NODE_ID { break } - module_id = self.tcx.hir.get_parent_node(module_id); + module_id = self.tcx.hir().get_parent_node(module_id); } } } @@ -473,8 +476,8 @@ impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> { } fn check_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>) { - 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); + 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, self.access_level); } } @@ -495,7 +498,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.hir.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, self.access_level); } } @@ -543,7 +546,7 @@ fn update_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tables: &mut &'a ty::TypeckTables<'tcx>, empty_tables: &'a ty::TypeckTables<'tcx>) -> &'a ty::TypeckTables<'tcx> { - let def_id = tcx.hir.local_def_id(item_id); + let def_id = tcx.hir().local_def_id(item_id); if tcx.has_typeck_tables(def_id) { replace(tables, tcx.typeck_tables_of(def_id)) @@ -556,12 +559,12 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'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.hir) + NestedVisitorMap::All(&self.tcx.hir()) } fn visit_nested_body(&mut self, body: hir::BodyId) { let orig_tables = replace(&mut self.tables, self.tcx.body_tables(body)); - let body = self.tcx.hir.body(body); + let body = self.tcx.hir().body(body); self.visit_body(body); self.tables = orig_tables; } @@ -657,19 +660,19 @@ struct TypePrivacyVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> { fn def_id_visibility(&self, did: DefId) -> ty::Visibility { - match self.tcx.hir.as_local_node_id(did) { + match self.tcx.hir().as_local_node_id(did) { Some(node_id) => { - let vis = match self.tcx.hir.get(node_id) { + let vis = match self.tcx.hir().get(node_id) { Node::Item(item) => &item.vis, Node::ForeignItem(foreign_item) => &foreign_item.vis, Node::ImplItem(impl_item) => &impl_item.vis, Node::TraitItem(..) | Node::Variant(..) => { - return self.def_id_visibility(self.tcx.hir.get_parent_did(node_id)); + return self.def_id_visibility(self.tcx.hir().get_parent_did(node_id)); } Node::StructCtor(vdata) => { - let struct_node_id = self.tcx.hir.get_parent(node_id); - let struct_vis = match self.tcx.hir.get(struct_node_id) { + let struct_node_id = self.tcx.hir().get_parent(node_id); + let struct_vis = match self.tcx.hir().get(struct_node_id) { Node::Item(item) => &item.vis, node => bug!("unexpected node kind: {:?}", node), }; @@ -684,7 +687,7 @@ impl<'a, 'tcx> TypePrivacyVisitor<'a, 'tcx> { // If the structure is marked as non_exhaustive then lower the // visibility to within the crate. - let struct_def_id = self.tcx.hir.get_parent_did(node_id); + let struct_def_id = self.tcx.hir().get_parent_did(node_id); let adt_def = self.tcx.adt_def(struct_def_id); if adt_def.non_enum_variant().is_field_list_non_exhaustive() && ctor_vis == ty::Visibility::Public @@ -741,13 +744,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'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.hir) + NestedVisitorMap::All(&self.tcx.hir()) } fn visit_nested_body(&mut self, body: hir::BodyId) { let orig_tables = replace(&mut self.tables, self.tcx.body_tables(body)); let orig_in_body = replace(&mut self.in_body, true); - let body = self.tcx.hir.body(body); + let body = self.tcx.hir().body(body); self.visit_body(body); self.tables = orig_tables; self.in_body = orig_in_body; @@ -888,7 +891,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { &mut self.tables, self.empty_tables); let orig_in_body = replace(&mut self.in_body, false); - self.current_item = self.tcx.hir.local_def_id(item.id); + self.current_item = self.tcx.hir().local_def_id(item.id); intravisit::walk_item(self, item); self.tables = orig_tables; self.in_body = orig_in_body; @@ -1036,10 +1039,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.hir.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.hir.find(node_id) { + match self.tcx.hir().find(node_id) { Some(Node::Item(ref item)) => !item.vis.node.is_pub(), Some(_) | None => false, } @@ -1098,7 +1101,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.hir) + NestedVisitorMap::All(&self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -1154,7 +1157,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.hir.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 @@ -1173,7 +1176,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.hir.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(..) => { @@ -1198,7 +1201,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.hir.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(..) @@ -1231,7 +1234,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.hir.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); } @@ -1244,7 +1247,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.hir.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; @@ -1427,8 +1430,8 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> { fn check_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>) { // Non-local means public (private items can't leave their crate, modulo bugs) - 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); + 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) { self.min_visibility = vis; @@ -1476,8 +1479,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.hir.as_local_node_id(def_id) { - let hir_vis = match self.tcx.hir.find(node_id) { + if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) { + let hir_vis = match self.tcx.hir().find(node_id) { Some(Node::Item(item)) => &item.vis, Some(Node::ForeignItem(item)) => &item.vis, _ => bug!("expected item of foreign item"), @@ -1537,7 +1540,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { has_old_errors = true; break; } - let parent = self.tcx.hir.get_parent_node(id); + let parent = self.tcx.hir().get_parent_node(id); if parent == id { break; } @@ -1551,8 +1554,8 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { SearchInterfaceForPrivateItemsVisitor { tcx: self.tcx, - item_def_id: self.tcx.hir.local_def_id(item_id), - span: self.tcx.hir.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, has_pub_restricted: self.has_pub_restricted, @@ -1564,7 +1567,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.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -1656,7 +1659,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.hir.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); let mut check = self.check(impl_item.id, min(impl_item_vis, ty_vis)); check.in_assoc_ty = impl_item_ref.kind == hir::AssociatedItemKind::Type; @@ -1674,7 +1677,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> .ty().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.hir.impl_item(impl_item_ref.id); + let impl_item = self.tcx.hir().impl_item(impl_item_ref.id); let mut check = self.check(impl_item.id, vis); check.in_assoc_ty = impl_item_ref.kind == hir::AssociatedItemKind::Type; check.generics().predicates().ty(); @@ -1713,7 +1716,7 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> Lrc { assert_eq!(krate, LOCAL_CRATE); - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let empty_tables = ty::TypeckTables::empty(None); // Check privacy of names not checked in previous compilation stages. diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 15c8861eb3f1f..b1c1c9635bfa6 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -126,7 +126,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, O>), { - let item_def_id = self.tcx.hir.local_def_id(item_id); + let item_def_id = self.tcx.hir().local_def_id(item_id); if self.tcx.has_typeck_tables(item_def_id) { let tables = self.tcx.typeck_tables_of(item_def_id); let old_tables = self.save_ctxt.tables; @@ -249,7 +249,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { collector.visit_pat(&arg.pat); for (id, ident, ..) in collector.collected_idents { - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); let typ = match self.save_ctxt.tables.node_id_to_type_opt(hir_id) { Some(s) => s.to_string(), None => continue, @@ -673,7 +673,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { } self.process_generic_params(type_parameters, "", item.id); for impl_item in impl_items { - let map = &self.tcx.hir; + let map = &self.tcx.hir(); self.process_impl_item(impl_item, map.local_def_id(item.id)); } } @@ -752,7 +752,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { // walk generics and methods self.process_generic_params(generics, &qualname, item.id); for method in methods { - let map = &self.tcx.hir; + let map = &self.tcx.hir(); self.process_trait_item(method, map.local_def_id(item.id)) } } @@ -866,7 +866,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { match p.node { PatKind::Struct(ref _path, ref fields, _) => { // FIXME do something with _path? - let hir_id = self.tcx.hir.node_to_hir_id(p.id); + let hir_id = self.tcx.hir().node_to_hir_id(p.id); let adt = match self.save_ctxt.tables.node_id_to_type_opt(hir_id) { Some(ty) => ty.ty_adt_def().unwrap(), None => { @@ -911,7 +911,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { } else { "".to_owned() }; - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); let typ = self.save_ctxt .tables .node_id_to_type_opt(hir_id) @@ -982,7 +982,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { ast::Mutability::Immutable => value.to_string(), _ => String::new(), }; - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); let typ = match self.save_ctxt.tables.node_id_to_type_opt(hir_id) { Some(typ) => { let typ = typ.to_string(); @@ -1204,7 +1204,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { let access = access_from!(self.save_ctxt, root_item.vis, id); // The parent def id of a given use tree is always the enclosing item. - let parent = self.save_ctxt.tcx.hir.opt_local_def_id(id) + let parent = self.save_ctxt.tcx.hir().opt_local_def_id(id) .and_then(|id| self.save_ctxt.tcx.parent_def_id(id)) .map(::id_from_def_id); @@ -1357,7 +1357,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc let name_span = item.ident.span; if !self.span.filter_generated(name_span) { let span = self.span_from_span(name_span); - let parent = self.save_ctxt.tcx.hir.opt_local_def_id(item.id) + let parent = self.save_ctxt.tcx.hir().opt_local_def_id(item.id) .and_then(|id| self.save_ctxt.tcx.parent_def_id(id)) .map(::id_from_def_id); self.dumper.import( @@ -1510,7 +1510,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc self.process_macro_use(ex.span); match ex.node { ast::ExprKind::Struct(ref path, ref fields, ref base) => { - let hir_expr = self.save_ctxt.tcx.hir.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) if ty.ty_adt_def().is_some() => ty.ty_adt_def().unwrap(), _ => { diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 82c4795a29d4b..85ffd3eb1c277 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -383,7 +383,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { let name = ident.to_string(); let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident); filter!(self.span_utils, ident.span); - let def_id = self.tcx.hir.local_def_id(field.id); + let def_id = self.tcx.hir().local_def_id(field.id); let typ = self.tcx.type_of(def_id).to_string(); @@ -415,18 +415,18 @@ 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, docs, attributes) = - 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) { + 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::Item(item)) => match item.node { hir::ItemKind::Impl(.., ref ty, _) => { let mut qualname = String::from("<"); - qualname.push_str(&self.tcx.hir.node_to_pretty_string(ty.id)); + qualname.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; let mut docs = String::new(); let mut attrs = vec![]; - if let Some(Node::ImplItem(item)) = self.tcx.hir.find(id) { + if let Some(Node::ImplItem(item)) = self.tcx.hir().find(id) { docs = self.docs_for_attrs(&item.attrs); attrs = item.attrs.to_vec(); } @@ -463,12 +463,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { ); } }, - None => match self.tcx.trait_of_item(self.tcx.hir.local_def_id(id)) { + None => match self.tcx.trait_of_item(self.tcx.hir().local_def_id(id)) { Some(def_id) => { let mut docs = String::new(); let mut attrs = vec![]; - if let Some(Node::TraitItem(item)) = self.tcx.hir.find(id) { + if let Some(Node::TraitItem(item)) = self.tcx.hir().find(id) { docs = self.docs_for_attrs(&item.attrs); attrs = item.attrs.to_vec(); } @@ -529,14 +529,14 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } pub fn get_expr_data(&self, expr: &ast::Expr) -> Option { - let hir_node = self.tcx.hir.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::Error { return None; } match expr.node { ast::ExprKind::Field(ref sub_ex, ident) => { - let hir_node = match self.tcx.hir.find(sub_ex.id) { + let hir_node = match self.tcx.hir().find(sub_ex.id) { Some(Node::Expr(expr)) => expr, _ => { debug!( @@ -587,7 +587,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } ast::ExprKind::MethodCall(ref seg, ..) => { - let expr_hir_id = self.tcx.hir.definitions().node_to_hir_id(expr.id); + let expr_hir_id = self.tcx.hir().definitions().node_to_hir_id(expr.id); let method_id = match self.tables.type_dependent_defs().get(expr_hir_id) { Some(id) => id.def_id(), None => { @@ -622,7 +622,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } pub fn get_path_def(&self, id: NodeId) -> HirDef { - match self.tcx.hir.get(id) { + match self.tcx.hir().get(id) { Node::TraitRef(tr) => tr.path.def, Node::Item(&hir::Item { @@ -656,7 +656,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { node: hir::PatKind::TupleStruct(ref qpath, ..), .. }) => { - let hir_id = self.tcx.hir.node_to_hir_id(id); + let hir_id = self.tcx.hir().node_to_hir_id(id); self.tables.qpath_def(qpath, hir_id) } @@ -1183,7 +1183,7 @@ fn id_from_def_id(id: DefId) -> rls_data::Id { } fn id_from_node_id(id: NodeId, scx: &SaveContext) -> rls_data::Id { - let def_id = scx.tcx.hir.opt_local_def_id(id); + let def_id = scx.tcx.hir().opt_local_def_id(id); def_id.map(|id| id_from_def_id(id)).unwrap_or_else(|| { // Create a *fake* `DefId` out of a `NodeId` by subtracting the `NodeId` // out of the maximum u32 value. This will work unless you have *billions* diff --git a/src/librustc_traits/lowering/environment.rs b/src/librustc_traits/lowering/environment.rs index 519b0ac61058e..ad034bfff5a32 100644 --- a/src/librustc_traits/lowering/environment.rs +++ b/src/librustc_traits/lowering/environment.rs @@ -228,8 +228,8 @@ crate fn environment<'a, 'tcx>( // could bound lifetimes. .map(Clause::ForAll); - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let node = tcx.hir.get(node_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let node = tcx.hir().get(node_id); let mut is_fn = false; let mut is_impl = false; diff --git a/src/librustc_traits/lowering/mod.rs b/src/librustc_traits/lowering/mod.rs index 2d8e5b48aac7b..8024ec96db050 100644 --- a/src/librustc_traits/lowering/mod.rs +++ b/src/librustc_traits/lowering/mod.rs @@ -615,7 +615,7 @@ pub fn dump_program_clauses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { } let mut visitor = ClauseDumper { tcx }; - tcx.hir + tcx.hir() .krate() .visit_all_item_likes(&mut visitor.as_deep_visitor()); } @@ -626,7 +626,7 @@ struct ClauseDumper<'a, 'tcx: 'a> { impl<'a, 'tcx> ClauseDumper<'a, 'tcx> { fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) { - let def_id = self.tcx.hir.local_def_id(node_id); + let def_id = self.tcx.hir().local_def_id(node_id); for attr in attrs { let mut clauses = None; @@ -664,7 +664,7 @@ impl<'a, 'tcx> ClauseDumper<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for ClauseDumper<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item) { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 4fbbe58445254..752e0a5fac68b 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -114,10 +114,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { { let tcx = self.tcx(); let lifetime_name = |def_id| { - tcx.hir.name(tcx.hir.as_local_node_id(def_id).unwrap()).as_interned_str() + tcx.hir().name(tcx.hir().as_local_node_id(def_id).unwrap()).as_interned_str() }; - let hir_id = tcx.hir.node_to_hir_id(lifetime.id); + let hir_id = tcx.hir().node_to_hir_id(lifetime.id); let r = match tcx.named_region(hir_id) { Some(rl::Region::Static) => { tcx.types.re_static @@ -1135,7 +1135,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { self.ast_region_to_region(lifetime, None) } else { self.compute_object_lifetime_bound(span, existential_predicates).unwrap_or_else(|| { - let hir_id = tcx.hir.node_to_hir_id(lifetime.id); + let hir_id = tcx.hir().node_to_hir_id(lifetime.id); if tcx.named_region(hir_id).is_some() { self.ast_region_to_region(lifetime, None) } else { @@ -1190,8 +1190,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { let suitable_bounds = traits::transitive_bounds(tcx, bounds) .filter(|b| self.trait_defines_associated_type_named(b.def_id(), assoc_name)); - let param_node_id = tcx.hir.as_local_node_id(ty_param_def_id).unwrap(); - let param_name = tcx.hir.ty_param_name(param_node_id); + let param_node_id = tcx.hir().as_local_node_id(ty_param_def_id).unwrap(); + let param_name = tcx.hir().ty_param_name(param_node_id); self.one_bound_for_assoc_type(suitable_bounds, ¶m_name.as_str(), assoc_name, @@ -1235,7 +1235,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { item.kind == ty::AssociatedKind::Type && self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id()) }) - .and_then(|item| self.tcx().hir.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 `{}`", @@ -1485,12 +1485,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { assert_eq!(opt_self_ty, None); self.prohibit_generics(&path.segments); - let node_id = tcx.hir.as_local_node_id(did).unwrap(); - let item_id = tcx.hir.get_parent_node(node_id); - let item_def_id = tcx.hir.local_def_id(item_id); + let node_id = tcx.hir().as_local_node_id(did).unwrap(); + let item_id = tcx.hir().get_parent_node(node_id); + let item_def_id = tcx.hir().local_def_id(item_id); let generics = tcx.generics_of(item_def_id); - let index = generics.param_def_id_to_index[&tcx.hir.local_def_id(node_id)]; - tcx.mk_ty_param(index, tcx.hir.name(node_id).as_interned_str()) + let index = generics.param_def_id_to_index[&tcx.hir().local_def_id(node_id)]; + tcx.mk_ty_param(index, tcx.hir().name(node_id).as_interned_str()) } Def::SelfTy(_, Some(def_id)) => { // `Self` in impl (we know the concrete type) @@ -1579,7 +1579,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { self.def_to_ty(opt_self_ty, path, false) } hir::TyKind::Def(item_id, ref lifetimes) => { - let did = tcx.hir.local_def_id(item_id.id); + let did = tcx.hir().local_def_id(item_id.id); self.impl_trait_ty_to_ty(did, lifetimes) }, hir::TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { @@ -1594,7 +1594,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { self.associated_path_def_to_ty(ast_ty.id, ast_ty.span, ty, def, segment).0 } hir::TyKind::Array(ref ty, ref length) => { - let length_def_id = tcx.hir.local_def_id(length.id); + let length_def_id = tcx.hir().local_def_id(length.id); let substs = Substs::identity_for_item(tcx, length_def_id); let length = ty::Const::unevaluated(tcx, length_def_id, substs, tcx.types.usize); let array_ty = tcx.mk_ty(ty::Array(self.ast_ty_to_ty(&ty), length)); diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index a477df6ae2d56..bc9ba0e005464 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -750,7 +750,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); span_err!(tcx.sess, pat.span, E0533, "expected unit struct/variant or constant, found {} `{}`", def.kind_name(), - hir::print::to_string(&tcx.hir, |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. @@ -794,7 +794,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); let report_unexpected_def = |def: Def| { let msg = format!("expected tuple struct/variant, found {} `{}`", def.kind_name(), - hir::print::to_string(&tcx.hir, |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, "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 7a71cf57a2f27..ad4afb0d1a37b 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -206,7 +206,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { -> Ty<'tcx> { let (fn_sig, def_span) = match callee_ty.sty { ty::FnDef(def_id, _) => { - (callee_ty.fn_sig(self.tcx), self.tcx.hir.span_if_local(def_id)) + (callee_ty.fn_sig(self.tcx), self.tcx.hir().span_if_local(def_id)) } ty::FnPtr(sig) => (sig, None), ref t => { @@ -214,7 +214,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let &ty::Adt(adt_def, ..) = t { if adt_def.is_enum() { if let hir::ExprKind::Call(ref expr, _) = call_expr.node { - unit_variant = Some(self.tcx.hir.node_to_pretty_string(expr.id)) + unit_variant = Some(self.tcx.hir().node_to_pretty_string(expr.id)) } } } @@ -278,9 +278,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let def_span = match def { Def::Err => None, Def::Local(id) | Def::Upvar(id, ..) => { - Some(self.tcx.hir.span(id)) + Some(self.tcx.hir().span(id)) } - _ => self.tcx.hir.span_if_local(def.def_id()) + _ => self.tcx.hir().span_if_local(def.def_id()) }; if let Some(span) = def_span { let label = match (unit_variant, inner_callee_path) { diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 10ac2448d007b..629a31a7e1f85 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -64,7 +64,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.hir.body(body_id); + let body = self.tcx.hir().body(body_id); self.check_closure(expr, expected_kind, decl, body, gen, expected_sig) } @@ -82,7 +82,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { opt_kind, expected_sig ); - let expr_def_id = self.tcx.hir.local_def_id(expr.id); + let expr_def_id = self.tcx.hir().local_def_id(expr.id); let ClosureSignatures { bound_sig, @@ -496,7 +496,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { body: &hir::Body, expected_sig: ExpectedSig<'tcx>, ) -> ClosureSignatures<'tcx> { - let expr_map_node = self.tcx.hir.get_if_local(expr_def_id).unwrap(); + let expr_map_node = self.tcx.hir().get_if_local(expr_def_id).unwrap(); let expected_args: Vec<_> = expected_sig .sig .inputs() diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 3bdd038bff19c..f7072a6395b8c 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -696,7 +696,7 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { let b = self.shallow_resolve(b); - let node_id_a = self.tcx.hir.as_local_node_id(def_id_a).unwrap(); + let node_id_a = self.tcx.hir().as_local_node_id(def_id_a).unwrap(); match b.sty { ty::FnPtr(_) if self.tcx.with_freevars(node_id_a, |v| v.is_empty()) => { // We coerce the closure, which has fn type diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index e30ebe07e5418..a8291b5ddb15c 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -93,7 +93,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // This node-id should be used for the `body_id` field on each // `ObligationCause` (and the `FnCtxt`). This is what // `regionck_item` expects. - let impl_m_node_id = tcx.hir.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 cause = ObligationCause { span: impl_m_span, @@ -391,7 +391,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // the moment, give a kind of vague error message. if trait_params != impl_params { let def_span = tcx.sess.source_map().def_span(span); - let span = tcx.hir.get_generics_span(impl_m.def_id).unwrap_or(def_span); + let span = tcx.hir().get_generics_span(impl_m.def_id).unwrap_or(def_span); let mut err = struct_span_err!( tcx.sess, span, @@ -400,9 +400,9 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_m.ident, ); err.span_label(span, "lifetimes do not match method in trait"); - if let Some(sp) = tcx.hir.span_if_local(trait_m.def_id) { + if let Some(sp) = tcx.hir().span_if_local(trait_m.def_id) { let def_sp = tcx.sess.source_map().def_span(sp); - let sp = tcx.hir.get_generics_span(trait_m.def_id).unwrap_or(def_sp); + let sp = tcx.hir().get_generics_span(trait_m.def_id).unwrap_or(def_sp); err.span_label(sp, "lifetimes in impl do not match this method in trait"); } err.emit(); @@ -422,8 +422,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.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 { + 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()) } @@ -432,8 +432,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.hir.as_local_node_id(trait_m.def_id) { - let trait_m_iter = match tcx.hir.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() } @@ -451,15 +451,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), tcx.hir.span_if_local(trait_m.def_id))) + .unwrap_or_else(|| (cause.span(&tcx), tcx.hir().span_if_local(trait_m.def_id))) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span(&tcx), tcx.hir().span_if_local(trait_m.def_id)) } } TypeError::Sorts(ExpectedFound { .. }) => { - if let Some(trait_m_node_id) = tcx.hir.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.hir.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()) } @@ -486,14 +486,14 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a { (impl_m_output.span(), Some(trait_m_output.span())) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span(&tcx), tcx.hir().span_if_local(trait_m.def_id)) } ) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span(&tcx), tcx.hir().span_if_local(trait_m.def_id)) } } - _ => (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)), + _ => (cause.span(&tcx), tcx.hir().span_if_local(trait_m.def_id)), } } @@ -548,7 +548,7 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_m.ident, self_descr); err.span_label(impl_m_span, format!("`{}` used in impl", self_descr)); - if let Some(span) = tcx.hir.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 method declared without `{}`", self_descr)); } else { err.note_trait_signature(trait_m.ident.to_string(), @@ -568,7 +568,7 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_m.ident, self_descr); err.span_label(impl_m_span, format!("expected `{}` in impl", self_descr)); - if let Some(span) = tcx.hir.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)); } else { err.note_trait_signature(trait_m.ident.to_string(), @@ -594,8 +594,8 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let num_trait_m_type_params = trait_m_generics.own_counts().types; if num_impl_m_type_params != num_trait_m_type_params { - let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap(); - let impl_m_item = tcx.hir.expect_impl_item(impl_m_node_id); + let impl_m_node_id = tcx.hir().as_local_node_id(impl_m.def_id).unwrap(); + let impl_m_item = tcx.hir().expect_impl_item(impl_m_node_id); let span = if impl_m_item.generics.params.is_empty() || impl_m_item.generics.span.is_dummy() // impl Trait in argument position (#55374) { @@ -644,9 +644,9 @@ fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let trait_number_args = trait_m_fty.inputs().skip_binder().len(); let impl_number_args = impl_m_fty.inputs().skip_binder().len(); if trait_number_args != impl_number_args { - let trait_m_node_id = tcx.hir.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.hir.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 @@ -663,8 +663,8 @@ fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } else { trait_item_span }; - 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 { + 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 @@ -729,8 +729,8 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, in impl_m_type_params.zip(trait_m_type_params) { if impl_synthetic != trait_synthetic { - let impl_node_id = tcx.hir.as_local_node_id(impl_def_id).unwrap(); - let impl_span = tcx.hir.span(impl_node_id); + let impl_node_id = tcx.hir().as_local_node_id(impl_def_id).unwrap(); + let impl_span = tcx.hir().span(impl_node_id); let trait_span = tcx.def_span(trait_def_id); let mut err = struct_span_err!(tcx.sess, impl_span, @@ -752,11 +752,11 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .source_map() .span_to_snippet(trait_span) .ok()?; - let trait_m = tcx.hir.as_local_node_id(trait_m.def_id)?; - let trait_m = tcx.hir.trait_item(hir::TraitItemId { node_id: trait_m }); + let trait_m = tcx.hir().as_local_node_id(trait_m.def_id)?; + let trait_m = tcx.hir().trait_item(hir::TraitItemId { node_id: trait_m }); - let impl_m = tcx.hir.as_local_node_id(impl_m.def_id)?; - let impl_m = tcx.hir.impl_item(hir::ImplItemId { node_id: impl_m }); + let impl_m = tcx.hir().as_local_node_id(impl_m.def_id)?; + let impl_m = tcx.hir().impl_item(hir::ImplItemId { node_id: impl_m }); // in case there are no generics, take the spot between the function name // and the opening paren of the argument list @@ -797,8 +797,8 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, (None, Some(hir::SyntheticTyParamKind::ImplTrait)) => { err.span_label(impl_span, "expected `impl Trait`, found generic parameter"); (|| { - let impl_m = tcx.hir.as_local_node_id(impl_m.def_id)?; - let impl_m = tcx.hir.impl_item(hir::ImplItemId { node_id: impl_m }); + let impl_m = tcx.hir().as_local_node_id(impl_m.def_id)?; + let impl_m = tcx.hir().impl_item(hir::ImplItemId { node_id: impl_m }); let input_tys = match impl_m.node { hir::ImplItemKind::Method(ref sig, _) => &sig.decl.inputs, _ => unreachable!(), @@ -895,7 +895,7 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Create a parameter environment that represents the implementation's // method. - let impl_c_node_id = tcx.hir.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(); // Compute placeholder form of impl and trait const tys. let impl_ty = tcx.type_of(impl_c.def_id); @@ -927,7 +927,7 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_ty); // Locate the Span containing just the type of the offending impl - match tcx.hir.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), } @@ -939,10 +939,10 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait", trait_c.ident); - let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id); + let trait_c_node_id = tcx.hir().as_local_node_id(trait_c.def_id); let trait_c_span = trait_c_node_id.map(|trait_c_node_id| { // Add a label to the Span containing just the type of the const - match tcx.hir.expect_trait_item(trait_c_node_id).node { + 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/demand.rs b/src/librustc_typeck/check/demand.rs index 0a196834cb494..fb83d169d39a5 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -203,17 +203,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn can_use_as_ref(&self, expr: &hir::Expr) -> Option<(Span, &'static str, String)> { if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.node { if let hir::def::Def::Local(id) = path.def { - let parent = self.tcx.hir.get_parent_node(id); + let parent = self.tcx.hir().get_parent_node(id); if let Some(Node::Expr(hir::Expr { id, node: hir::ExprKind::Closure(_, decl, ..), .. - })) = self.tcx.hir.find(parent) { - let parent = self.tcx.hir.get_parent_node(*id); + })) = self.tcx.hir().find(parent) { + let parent = self.tcx.hir().get_parent_node(*id); if let (Some(Node::Expr(hir::Expr { node: hir::ExprKind::MethodCall(path, span, expr), .. - })), 1) = (self.tcx.hir.find(parent), decl.inputs.len()) { + })), 1) = (self.tcx.hir().find(parent), decl.inputs.len()) { let self_ty = self.tables.borrow().node_id_to_type(expr[0].hir_id); let self_ty = format!("{:?}", self_ty); let name = path.ident.as_str(); @@ -450,8 +450,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { checked_ty: Ty<'tcx>, expected_ty: Ty<'tcx>) -> bool { - let parent_id = self.tcx.hir.get_parent_node(expr.id); - if let Some(parent) = self.tcx.hir.find(parent_id) { + let parent_id = self.tcx.hir().get_parent_node(expr.id); + if let Some(parent) = self.tcx.hir().find(parent_id) { // Shouldn't suggest `.into()` on `const`s. if let Node::Item(Item { node: ItemKind::Const(_, _), .. }) = parent { // FIXME(estebank): modify once we decide to suggest `as` casts diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index b8544177bbbbe..aae99addfcd76 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -80,7 +80,7 @@ fn ensure_drop_params_and_item_params_correspond<'a, 'tcx>( drop_impl_ty: Ty<'tcx>, self_type_did: DefId, ) -> Result<(), ErrorReported> { - let drop_impl_node_id = tcx.hir.as_local_node_id(drop_impl_did).unwrap(); + let drop_impl_node_id = tcx.hir().as_local_node_id(drop_impl_did).unwrap(); // check that the impl type can be made to match the trait type. @@ -194,7 +194,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>( // absent. So we report an error that the Drop impl injected a // predicate that is not present on the struct definition. - let self_type_node_id = tcx.hir.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); @@ -226,7 +226,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.hir.span(self_type_node_id); + let item_span = tcx.hir().span(self_type_node_id); struct_span_err!( tcx.sess, drop_impl_span, diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index b4ad9cfbc6d51..55fceda1a5151 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -86,7 +86,7 @@ pub fn resolve_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, def_id: DefId, body_id: hir::BodyId, interior: Ty<'tcx>) { - let body = fcx.tcx.hir.body(body_id); + let body = fcx.tcx.hir().body(body_id); let mut visitor = InteriorVisitor { fcx, types: FxHashMap::default(), diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 2af21f547445e..b1382057c5262 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -36,7 +36,7 @@ fn equate_intrinsic_type<'a, 'tcx>( inputs: Vec>, output: Ty<'tcx>, ) { - let def_id = tcx.hir.local_def_id(it.id); + let def_id = tcx.hir().local_def_id(it.id); match it.node { hir::ForeignItemKind::Fn(..) => {} @@ -401,7 +401,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.mk_ty_param(n, name) }; - let def_id = tcx.hir.local_def_id(it.id); + let def_id = tcx.hir().local_def_id(it.id); let i_n_tps = tcx.generics_of(def_id).own_counts().types; let name = it.name.as_str(); diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 37f4ae56779b2..209ad45ff34f6 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -171,7 +171,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { )?; if let Some(import_id) = pick.import_id { - let import_def_id = self.tcx.hir.local_def_id(import_id); + let import_def_id = self.tcx.hir().local_def_id(import_id); debug!("used_trait_import: {:?}", import_def_id); Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports) .unwrap().insert(import_def_id); @@ -380,7 +380,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self_ty, expr_id, ProbeScope::TraitsInScope)?; if let Some(import_id) = pick.import_id { - let import_def_id = self.tcx.hir.local_def_id(import_id); + let import_def_id = self.tcx.hir().local_def_id(import_id); debug!("used_trait_import: {:?}", import_def_id); Lrc::get_mut(&mut self.tables.borrow_mut().used_trait_imports) .unwrap().insert(import_def_id); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 5b67116cb511e..c794910e6ef9c 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -720,7 +720,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { return Ok(()) } let mut duplicates = FxHashSet::default(); - let expr_hir_id = self.tcx.hir.node_to_hir_id(expr_id); + let expr_hir_id = self.tcx.hir().node_to_hir_id(expr_id); let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id); if let Some(applicable_traits) = opt_applicable_traits { for trait_candidate in applicable_traits.iter() { diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index cd243d4144394..ab7e71a2870a1 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -107,8 +107,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Namespace::Value, ) }).unwrap(); - let note_span = self.tcx.hir.span_if_local(item.def_id).or_else(|| { - self.tcx.hir.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; @@ -265,13 +265,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::ExprKind::Path(ref qpath) => { // local binding if let &hir::QPath::Resolved(_, ref path) = &qpath { if let hir::def::Def::Local(node_id) = path.def { - let span = tcx.hir.span(node_id); + let span = tcx.hir().span(node_id); let snippet = tcx.sess.source_map().span_to_snippet(span) .unwrap(); let filename = tcx.sess.source_map().span_to_filename(span); - let parent_node = self.tcx.hir.get( - self.tcx.hir.get_parent_node(node_id), + let parent_node = self.tcx.hir().get( + self.tcx.hir().get_parent_node(node_id), ); let msg = format!( "you must specify a type for this binding, like `{}`", @@ -325,7 +325,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; if let Some(def) = actual.ty_adt_def() { - if let Some(full_sp) = tcx.hir.span_if_local(def.did) { + if let Some(full_sp) = tcx.hir().span_if_local(def.did) { let def_sp = tcx.sess.source_map().def_span(full_sp); err.span_label(def_sp, format!("{} `{}` not found {}", item_kind, @@ -356,7 +356,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; let field_ty = field.ty(tcx, substs); - let scope = self.tcx.hir.get_module_parent(self.body_id); + let scope = self.tcx.hir().get_module_parent(self.body_id); if field.vis.is_accessible_from(scope, self.tcx) { if self.is_fn_ty(&field_ty, span) { err.help(&format!("use `({0}.{1})(...)` if you \ @@ -503,9 +503,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { err: &mut DiagnosticBuilder, mut msg: String, candidates: Vec) { - let module_did = self.tcx.hir.get_module_parent(self.body_id); - let module_id = self.tcx.hir.as_local_node_id(module_did).unwrap(); - let krate = self.tcx.hir.krate(); + let module_did = self.tcx.hir().get_module_parent(self.body_id); + let module_id = self.tcx.hir().as_local_node_id(module_did).unwrap(); + let krate = self.tcx.hir().krate(); let (span, found_use) = UsePlacementFinder::check(self.tcx, krate, module_id); if let Some(span) = span { let path_strings = candidates.iter().map(|did| { @@ -744,8 +744,8 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) { } } - tcx.hir.krate().visit_all_item_likes(&mut Visitor { - map: &tcx.hir, + tcx.hir().krate().visit_all_item_likes(&mut Visitor { + map: &tcx.hir(), traits: &mut traits, }); @@ -829,7 +829,7 @@ impl<'a, 'tcx, 'gcx> hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'a, ' } // find a use statement for item_id in &module.item_ids { - let item = self.tcx.hir.expect_item(item_id.id); + let item = self.tcx.hir().expect_item(item_id.id); match item.node { hir::ItemKind::Use(..) => { // don't suggest placing a use before the prelude diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index e30a79b25de7f..01fb52bd8ac2c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -605,8 +605,8 @@ impl<'a, 'gcx, 'tcx> Inherited<'a, 'gcx, 'tcx> { pub fn build(tcx: TyCtxt<'a, 'gcx, 'gcx>, def_id: DefId) -> InheritedBuilder<'a, 'gcx, 'tcx> { let hir_id_root = if def_id.is_local() { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let hir_id = tcx.hir.definitions().node_to_hir_id(node_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let hir_id = tcx.hir().definitions().node_to_hir_id(node_id); DefId::local(hir_id.owner) } else { def_id @@ -631,10 +631,10 @@ impl<'a, 'gcx, 'tcx> InheritedBuilder<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> Inherited<'a, 'gcx, 'tcx> { fn new(infcx: InferCtxt<'a, 'gcx, 'tcx>, def_id: DefId) -> Self { let tcx = infcx.tcx; - let item_id = tcx.hir.as_local_node_id(def_id); - let body_id = item_id.and_then(|id| tcx.hir.maybe_body_owned_by(id)); + let item_id = tcx.hir().as_local_node_id(def_id); + let body_id = item_id.and_then(|id| tcx.hir().maybe_body_owned_by(id)); let implicit_region_bound = body_id.map(|body_id| { - let body = tcx.hir.body(body_id); + let body = tcx.hir().body(body_id); tcx.mk_region(ty::ReScope(region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::CallSite @@ -707,13 +707,13 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> { pub fn check_wf_new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), ErrorReported> { tcx.sess.track_errors(|| { let mut visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx); - tcx.hir.krate().visit_all_item_likes(&mut visit.as_deep_visitor()); + tcx.hir().krate().visit_all_item_likes(&mut visit.as_deep_visitor()); }) } pub fn check_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), ErrorReported> { tcx.sess.track_errors(|| { - tcx.hir.krate().visit_all_item_likes(&mut CheckItemTypesVisitor { tcx }); + tcx.hir().krate().visit_all_item_likes(&mut CheckItemTypesVisitor { tcx }); }) } @@ -778,7 +778,7 @@ fn primary_body_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: ast::NodeId) -> Option<(hir::BodyId, Option<&'tcx hir::FnDecl>)> { - match tcx.hir.get(id) { + match tcx.hir().get(id) { Node::Item(item) => { match item.node { hir::ItemKind::Const(_, body) | @@ -825,7 +825,7 @@ fn has_typeck_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, return tcx.has_typeck_tables(outer_def_id); } - let id = tcx.hir.as_local_node_id(def_id).unwrap(); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); primary_body_of(tcx, id).is_some() } @@ -845,14 +845,14 @@ fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, return tcx.typeck_tables_of(outer_def_id); } - let id = tcx.hir.as_local_node_id(def_id).unwrap(); - let span = tcx.hir.span(id); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); + let span = tcx.hir().span(id); // Figure out what primary body this item has. let (body_id, fn_decl) = primary_body_of(tcx, id).unwrap_or_else(|| { span_bug!(span, "can't type-check body of {:?}", def_id); }); - let body = tcx.hir.body(body_id); + let body = tcx.hir().body(body_id); let tables = Inherited::build(tcx, def_id).enter(|inh| { let param_env = tcx.param_env(def_id); @@ -930,7 +930,7 @@ fn typeck_tables_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Consistency check our TypeckTables instance can hold all ItemLocalIds // it will need to hold. assert_eq!(tables.local_id_root, - Some(DefId::local(tcx.hir.definitions().node_to_hir_id(id).owner))); + Some(DefId::local(tcx.hir().definitions().node_to_hir_id(id).owner))); tables } @@ -1087,8 +1087,8 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, fcx.yield_ty = Some(yield_ty); } - let outer_def_id = fcx.tcx.closure_base_def_id(fcx.tcx.hir.local_def_id(fn_id)); - let outer_node_id = fcx.tcx.hir.as_local_node_id(outer_def_id).unwrap(); + let outer_def_id = fcx.tcx.closure_base_def_id(fcx.tcx.hir().local_def_id(fn_id)); + let outer_node_id = fcx.tcx.hir().as_local_node_id(outer_def_id).unwrap(); GatherLocalsVisitor { fcx: &fcx, parent_id: outer_node_id, }.visit_body(body); // Add formal parameters. @@ -1108,7 +1108,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, fcx.write_ty(arg.hir_id, arg_ty); } - let fn_hir_id = fcx.tcx.hir.node_to_hir_id(fn_id); + let fn_hir_id = fcx.tcx.hir().node_to_hir_id(fn_id); inherited.tables.borrow_mut().liberated_fn_sigs_mut().insert(fn_hir_id, fn_sig); fcx.check_return_expr(&body.value); @@ -1180,7 +1180,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, // Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !` if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() { - if panic_impl_did == fcx.tcx.hir.local_def_id(fn_id) { + if panic_impl_did == fcx.tcx.hir().local_def_id(fn_id) { if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() { // at this point we don't care if there are duplicate handlers or if the handler has // the wrong signature as this value we'll be used when writing metadata and that @@ -1195,7 +1195,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } let inputs = fn_sig.inputs(); - let span = fcx.tcx.hir.span(fn_id); + let span = fcx.tcx.hir().span(fn_id); if inputs.len() == 1 { let arg_is_panic_info = match inputs[0].sty { ty::Ref(region, ty, mutbl) => match ty.sty { @@ -1216,7 +1216,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, ); } - if let Node::Item(item) = fcx.tcx.hir.get(fn_id) { + if let Node::Item(item) = fcx.tcx.hir().get(fn_id) { if let ItemKind::Fn(_, _, ref generics, _) = item.node { if !generics.params.is_empty() { fcx.tcx.sess.span_err( @@ -1238,7 +1238,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, // Check that a function marked as `#[alloc_error_handler]` has signature `fn(Layout) -> !` if let Some(alloc_error_handler_did) = fcx.tcx.lang_items().oom() { - if alloc_error_handler_did == fcx.tcx.hir.local_def_id(fn_id) { + if alloc_error_handler_did == fcx.tcx.hir().local_def_id(fn_id) { if let Some(alloc_layout_did) = fcx.tcx.lang_items().alloc_layout() { if declared_ret_ty.sty != ty::Never { fcx.tcx.sess.span_err( @@ -1248,7 +1248,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, } let inputs = fn_sig.inputs(); - let span = fcx.tcx.hir.span(fn_id); + let span = fcx.tcx.hir().span(fn_id); if inputs.len() == 1 { let arg_is_alloc_layout = match inputs[0].sty { ty::Adt(ref adt, _) => { @@ -1264,7 +1264,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, ); } - if let Node::Item(item) = fcx.tcx.hir.get(fn_id) { + if let Node::Item(item) = fcx.tcx.hir().get(fn_id) { if let ItemKind::Fn(_, _, ref generics, _) = item.node { if !generics.params.is_empty() { fcx.tcx.sess.span_err( @@ -1291,7 +1291,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, fn check_struct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: ast::NodeId, span: Span) { - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); let def = tcx.adt_def(def_id); def.destructor(tcx); // force the destructor to be evaluated check_representable(tcx, span, def_id); @@ -1307,7 +1307,7 @@ fn check_struct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn check_union<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: ast::NodeId, span: Span) { - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); let def = tcx.adt_def(def_id); def.destructor(tcx); // force the destructor to be evaluated check_representable(tcx, span, def_id); @@ -1319,18 +1319,18 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite debug!( "check_item_type(it.id={}, it.name={})", it.id, - tcx.item_path_str(tcx.hir.local_def_id(it.id)) + tcx.item_path_str(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. hir::ItemKind::Static(..) => { - let def_id = tcx.hir.local_def_id(it.id); + let def_id = tcx.hir().local_def_id(it.id); tcx.typeck_tables_of(def_id); maybe_check_static_with_link_section(tcx, def_id, it.span); } hir::ItemKind::Const(..) => { - tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); + tcx.typeck_tables_of(tcx.hir().local_def_id(it.id)); } hir::ItemKind::Enum(ref enum_definition, _) => { check_enum(tcx, it.span, &enum_definition.variants, it.id); @@ -1338,7 +1338,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite hir::ItemKind::Fn(..) => {} // entirely within check_item_body hir::ItemKind::Impl(.., ref impl_item_refs) => { debug!("ItemKind::Impl {} with id {}", it.name, it.id); - let impl_def_id = tcx.hir.local_def_id(it.id); + let impl_def_id = tcx.hir().local_def_id(it.id); if let Some(impl_trait_ref) = tcx.impl_trait_ref(impl_def_id) { check_impl_items_against_trait( tcx, @@ -1352,7 +1352,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite } } hir::ItemKind::Trait(..) => { - let def_id = tcx.hir.local_def_id(it.id); + let def_id = tcx.hir().local_def_id(it.id); check_on_unimplemented(tcx, def_id, it); } hir::ItemKind::Struct(..) => { @@ -1362,7 +1362,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite check_union(tcx, it.id, it.span); } hir::ItemKind::Existential(..) | hir::ItemKind::Ty(..) => { - let def_id = tcx.hir.local_def_id(it.id); + let def_id = tcx.hir().local_def_id(it.id); let pty_ty = tcx.type_of(def_id); let generics = tcx.generics_of(def_id); check_bounds_are_used(tcx, &generics, pty_ty); @@ -1380,7 +1380,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite } } else { for item in &m.items { - let generics = tcx.generics_of(tcx.hir.local_def_id(item.id)); + let generics = tcx.generics_of(tcx.hir().local_def_id(item.id)); if generics.params.len() - generics.own_counts().lifetimes != 0 { let mut err = struct_span_err!( tcx.sess, @@ -1449,7 +1449,7 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt, id: DefId, span: Span) { fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId, item: &hir::Item) { - let item_def_id = tcx.hir.local_def_id(item.id); + let item_def_id = tcx.hir().local_def_id(item.id); // an error would be reported if this fails. let _ = traits::OnUnimplementedDirective::of_item(tcx, trait_def_id, item_def_id); } @@ -1522,12 +1522,12 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let trait_def = tcx.trait_def(impl_trait_ref.def_id); let mut overridden_associated_type = None; - let impl_items = || impl_item_refs.iter().map(|iiref| tcx.hir.impl_item(iiref.id)); + let impl_items = || impl_item_refs.iter().map(|iiref| 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.hir.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| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) && tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id)) @@ -1557,14 +1557,14 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, err.span_label(impl_item.span, "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.hir.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, "item in trait"); } err.emit() } } hir::ImplItemKind::Method(..) => { - let trait_span = tcx.hir.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 { compare_impl_method(tcx, &ty_impl_item, @@ -1579,7 +1579,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty_impl_item.ident, impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); - if let Some(trait_span) = tcx.hir.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, "item in trait"); } err.emit() @@ -1598,7 +1598,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty_impl_item.ident, impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); - if let Some(trait_span) = tcx.hir.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, "item in trait"); } err.emit() @@ -1641,7 +1641,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .map(|trait_item| trait_item.ident.to_string()) .collect::>().join("`, `"))); for trait_item in missing_items { - if let Some(span) = tcx.hir.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.ident)); } else { err.note_trait_signature(trait_item.ident.to_string(), @@ -1786,7 +1786,7 @@ fn check_transparent<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: De let param_env = tcx.param_env(field.did); let layout = tcx.layout_of(param_env.and(ty)); // We are currently checking the type this field came from, so it must be local - let span = tcx.hir.span_if_local(field.did).unwrap(); + let span = tcx.hir().span_if_local(field.did).unwrap(); let zst = layout.map(|layout| layout.is_zst()).unwrap_or(false); let align1 = layout.map(|layout| layout.align.abi.bytes() == 1).unwrap_or(false); (span, zst, align1) @@ -1815,7 +1815,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, vs: &'tcx [hir::Variant], id: ast::NodeId) { - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); let def = tcx.adt_def(def_id); def.destructor(tcx); // force the destructor to be evaluated @@ -1843,7 +1843,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, for v in vs { if let Some(ref e) = v.node.disr_expr { - tcx.typeck_tables_of(tcx.hir.local_def_id(e.id)); + tcx.typeck_tables_of(tcx.hir().local_def_id(e.id)); } } @@ -1852,14 +1852,14 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Check for duplicate discriminant values if let Some(i) = disr_vals.iter().position(|&x| x.val == discr.val) { let variant_did = def.variants[VariantIdx::new(i)].did; - let variant_i_node_id = tcx.hir.as_local_node_id(variant_did).unwrap(); - let variant_i = tcx.hir.expect_variant(variant_i_node_id); + let variant_i_node_id = tcx.hir().as_local_node_id(variant_did).unwrap(); + let variant_i = tcx.hir().expect_variant(variant_i_node_id); let i_span = match variant_i.node.disr_expr { - Some(ref expr) => tcx.hir.span(expr.id), - None => tcx.hir.span(variant_i_node_id) + Some(ref expr) => tcx.hir().span(expr.id), + None => tcx.hir().span(variant_i_node_id) }; let span = match v.node.disr_expr { - Some(ref expr) => tcx.hir.span(expr.id), + Some(ref expr) => tcx.hir().span(expr.id), None => v.span }; struct_span_err!(tcx.sess, span, E0081, @@ -1881,9 +1881,9 @@ impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> { -> Lrc> { let tcx = self.tcx; - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let item_id = tcx.hir.ty_param_owner(node_id); - let item_def_id = tcx.hir.local_def_id(item_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let item_id = tcx.hir().ty_param_owner(node_id); + let item_def_id = tcx.hir().local_def_id(item_id); let generics = tcx.generics_of(item_def_id); let index = generics.param_def_id_to_index[&def_id]; Lrc::new(ty::GenericPredicates { @@ -2089,7 +2089,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> LocalTy<'tcx> { self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| span_bug!(span, "no type for local variable {}", - self.tcx.hir.node_to_string(nid)) + self.tcx.hir().node_to_string(nid)) ) } @@ -2106,7 +2106,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } pub fn write_field_index(&self, node_id: ast::NodeId, index: usize) { - let hir_id = self.tcx.hir.node_to_hir_id(node_id); + let hir_id = self.tcx.hir().node_to_hir_id(node_id); self.tables.borrow_mut().field_indices_mut().insert(hir_id, index); } @@ -2294,7 +2294,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { parent_id: ast::NodeId, value: &T, ) -> T { - let parent_def_id = self.tcx.hir.local_def_id(parent_id); + let parent_def_id = self.tcx.hir().local_def_id(parent_id); debug!("instantiate_opaque_types_from_value(parent_def_id={:?}, value={:?})", parent_def_id, value); @@ -2400,9 +2400,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Some(&t) => t, None if self.is_tainted_by_errors() => self.tcx.types.err, None => { - let node_id = self.tcx.hir.hir_to_node_id(id); + let node_id = self.tcx.hir().hir_to_node_id(id); bug!("no type for node {}: {} in fcx {}", - node_id, self.tcx.hir.node_to_string(node_id), + node_id, self.tcx.hir().node_to_string(node_id), self.tag()); } } @@ -2730,7 +2730,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ); self.check_argument_types(sp, expr_sp, &method.sig.inputs()[1..], &expected_arg_tys[..], args_no_rcvr, method.sig.variadic, tuple_arguments, - self.tcx.hir.span_if_local(method.def_id)); + self.tcx.hir().span_if_local(method.def_id)); method.sig.output() } @@ -3375,7 +3375,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { len.assert_usize(self.tcx), field.as_str().parse::() ) { - let base = self.tcx.hir.node_to_pretty_string(base.id); + let base = self.tcx.hir().node_to_pretty_string(base.id); let help = "instead of using tuple indexing, use array indexing"; let suggestion = format!("{}[{}]", base, field); let applicability = if len < user_index { @@ -3389,7 +3389,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } ty::RawPtr(..) => { - let base = self.tcx.hir.node_to_pretty_string(base.id); + let base = self.tcx.hir().node_to_pretty_string(base.id); let msg = format!("`{}` is a native pointer; try dereferencing it", base); let suggestion = format!("(*{}).{}", base, field); err.span_suggestion_with_applicability( @@ -3665,7 +3665,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some((variant, did, substs)) = variant { debug!("check_struct_path: did={:?} substs={:?}", did, substs); - let hir_id = self.tcx.hir.node_to_hir_id(node_id); + let hir_id = self.tcx.hir().node_to_hir_id(node_id); self.write_user_substs_from_substs(hir_id, substs, None); // Check bounds on type arguments used in the path. @@ -3796,7 +3796,7 @@ 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.hir.node_to_string(expr.id)); + debug!("type of {} is...", self.tcx.hir().node_to_string(expr.id)); debug!("... {:?}, expected is {:?}", ty, expected); ty @@ -4267,7 +4267,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { tcx.mk_array(element_ty, args.len() as u64) } hir::ExprKind::Repeat(ref element, ref count) => { - let count_def_id = tcx.hir.local_def_id(count.id); + let count_def_id = tcx.hir().local_def_id(count.id); let param_env = ty::ParamEnv::empty(); let substs = Substs::identity_for_item(tcx.global_tcx(), count_def_id); let instance = ty::Instance::resolve( @@ -4450,7 +4450,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ty, def, segment); // Write back the new resolution. - let hir_id = self.tcx.hir.node_to_hir_id(node_id); + let hir_id = self.tcx.hir().node_to_hir_id(node_id); self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, def); (def, ty) @@ -4476,7 +4476,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { (self.to_ty(qself), segment) } }; - let hir_id = self.tcx.hir.node_to_hir_id(node_id); + let hir_id = self.tcx.hir().node_to_hir_id(node_id); if let Some(cached_def) = self.tables.borrow().type_dependent_defs().get(hir_id) { // Return directly on cache hit. This is useful to avoid doubly reporting // errors with default match binding modes. See #44614. @@ -4717,8 +4717,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> { // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or // `while` before reaching it, as block tail returns are not available in them. - if let Some(fn_id) = self.tcx.hir.get_return_block(blk_id) { - let parent = self.tcx.hir.get(fn_id); + if let Some(fn_id) = self.tcx.hir().get_return_block(blk_id) { + let parent = self.tcx.hir().get(fn_id); if let Node::Item(&hir::Item { name, node: hir::ItemKind::Fn(ref decl, ..), .. @@ -5109,7 +5109,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { Def::Local(nid) | Def::Upvar(nid, ..) => { let ty = self.local_ty(span, nid).decl_ty; let ty = self.normalize_associated_types_in(span, &ty); - self.write_ty(self.tcx.hir.node_to_hir_id(node_id), ty); + self.write_ty(self.tcx.hir().node_to_hir_id(node_id), ty); return (ty, def); } _ => {} @@ -5237,7 +5237,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { assert!(!ty.has_escaping_bound_vars()); // Write the "user substs" down first thing for later. - let hir_id = self.tcx.hir.node_to_hir_id(node_id); + let hir_id = self.tcx.hir().node_to_hir_id(node_id); self.write_user_substs_from_substs(hir_id, substs, user_self_ty); // Add all the obligations that are required, substituting and @@ -5292,7 +5292,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If our calling expression is indeed the function itself, we're good! // If not, generate an error that this can only be called directly. - if let Node::Expr(expr) = self.tcx.hir.get(self.tcx.hir.get_parent_node(node_id)) { + if let Node::Expr(expr) = self.tcx.hir().get(self.tcx.hir().get_parent_node(node_id)) { if let hir::ExprKind::Call(ref callee, ..) = expr.node { if callee.id == node_id { return @@ -5373,8 +5373,8 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }); for (&used, param) in types_used.iter().zip(types) { if !used { - let id = tcx.hir.as_local_node_id(param.def_id).unwrap(); - let span = tcx.hir.span(id); + let id = tcx.hir().as_local_node_id(param.def_id).unwrap(); + let span = tcx.hir().span(id); struct_span_err!(tcx.sess, span, E0091, "type parameter `{}` is unused", param.name) .span_label(span, "unused type parameter") .emit(); diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 212ee2698e012..7960d743de5e4 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -121,7 +121,7 @@ macro_rules! ignore_err { impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn regionck_expr(&self, body: &'gcx hir::Body) { - let subject = self.tcx.hir.body_owner_def_id(body.id()); + let subject = self.tcx.hir().body_owner_def_id(body.id()); let id = body.value.id; let mut rcx = RegionCtxt::new( self, @@ -150,7 +150,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// types from which we should derive implied bounds, if any. pub fn regionck_item(&self, item_id: ast::NodeId, span: Span, wf_tys: &[Ty<'tcx>]) { debug!("regionck_item(item.id={:?}, wf_tys={:?})", item_id, wf_tys); - let subject = self.tcx.hir.local_def_id(item_id); + let subject = self.tcx.hir().local_def_id(item_id); let mut rcx = RegionCtxt::new( self, RepeatingScope(item_id), @@ -175,7 +175,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// constraints to add. pub fn regionck_fn(&self, fn_id: ast::NodeId, body: &'gcx hir::Body) { debug!("regionck_fn(id={})", fn_id); - let subject = self.tcx.hir.body_owner_def_id(body.id()); + let subject = self.tcx.hir().body_owner_def_id(body.id()); let node_id = body.value.id; let mut rcx = RegionCtxt::new( self, @@ -187,7 +187,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.hir.span(fn_id)); + rcx.visit_fn_body(fn_id, body, self.tcx.hir().span(fn_id)); } rcx.resolve_regions_and_report_errors(SuppressRegionErrors::when_nll_is_enabled(self.tcx)); @@ -328,7 +328,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { self.call_site_scope = Some(call_site); let fn_sig = { - let fn_hir_id = self.tcx.hir.node_to_hir_id(id); + let fn_hir_id = self.tcx.hir().node_to_hir_id(id); match self.tables.borrow().liberated_fn_sigs().get(fn_hir_id) { Some(f) => f.clone(), None => { @@ -375,7 +375,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { ); let call_site_region = self.tcx.mk_region(ty::ReScope(call_site_scope)); - let body_hir_id = self.tcx.hir.node_to_hir_id(body_id.node_id); + let body_hir_id = self.tcx.hir().node_to_hir_id(body_id.node_id); self.type_of_node_must_outlive(infer::CallReturn(span), body_hir_id, call_site_region); self.constrain_opaque_types( @@ -483,7 +483,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> { let old_call_site_scope = self.call_site_scope; let env_snapshot = self.outlives_environment.push_snapshot_pre_closure(); - let body = self.tcx.hir.body(body_id); + let body = self.tcx.hir().body(body_id); self.visit_fn_body(id, body, span); // Restore state from previous function. diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 312ce402775d2..562022cefa806 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -74,7 +74,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for InferBorrowKindVisitor<'a, 'gcx, 'tcx> { fn visit_expr(&mut self, expr: &'gcx hir::Expr) { if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.node { - let body = self.fcx.tcx.hir.body(body_id); + let body = self.fcx.tcx.hir().body(body_id); self.visit_body(body); self.fcx .analyze_closure(expr.id, expr.hir_id, expr.span, body, cc); @@ -135,7 +135,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { for freevar in freevars { let upvar_id = ty::UpvarId { var_path: ty::UpvarPath { - hir_id : self.tcx.hir.node_to_hir_id(freevar.var_id()), + hir_id : self.tcx.hir().node_to_hir_id(freevar.var_id()), }, closure_expr_id: LocalDefId::from_def_id(closure_def_id), }; @@ -161,7 +161,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } }); - let body_owner_def_id = self.tcx.hir.body_owner_def_id(body.id()); + let body_owner_def_id = self.tcx.hir().body_owner_def_id(body.id()); let region_scope_tree = &self.tcx.region_scope_tree(body_owner_def_id); let mut delegate = InferBorrowKind { fcx: self, @@ -240,14 +240,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // This may change if abstract return types of some sort are // implemented. let tcx = self.tcx; - let closure_def_index = tcx.hir.local_def_id(closure_id); + let closure_def_index = tcx.hir().local_def_id(closure_id); tcx.with_freevars(closure_id, |freevars| { freevars .iter() .map(|freevar| { let var_node_id = freevar.var_id(); - let var_hir_id = tcx.hir.node_to_hir_id(var_node_id); + let var_hir_id = tcx.hir().node_to_hir_id(var_node_id); let freevar_ty = self.node_ty(var_hir_id); let upvar_id = ty::UpvarId { var_path: ty::UpvarPath { @@ -647,6 +647,6 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> { } fn var_name(tcx: TyCtxt, var_hir_id: hir::HirId) -> ast::Name { - let var_node_id = tcx.hir.hir_to_node_id(var_hir_id); - tcx.hir.name(var_node_id) + let var_node_id = tcx.hir().hir_to_node_id(var_hir_id); + tcx.hir().name(var_node_id) } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index e5fe74f23056f..6471e745aa6fd 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -73,8 +73,8 @@ impl<'a, 'gcx, 'tcx> CheckWfFcxBuilder<'a, 'gcx, 'tcx> { /// not included it frequently leads to confusing errors in fn bodies. So it's better to check /// the types first. pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let item = tcx.hir.expect_item(node_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let item = tcx.hir().expect_item(node_id); debug!("check_item_well_formed(it.id={}, it.name={})", item.id, @@ -99,7 +99,7 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def // won't be allowed unless there's an *explicit* implementation of `Send` // for `T` hir::ItemKind::Impl(_, polarity, defaultness, _, ref trait_ref, ref self_ty, _) => { - let is_auto = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id)) + let is_auto = tcx.impl_trait_ref(tcx.hir().local_def_id(item.id)) .map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id)); if let (hir::Defaultness::Default { .. }, true) = (defaultness, is_auto) { tcx.sess.span_err(item.span, "impls of auto traits cannot be default"); @@ -161,8 +161,8 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def } pub fn check_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let trait_item = tcx.hir.expect_trait_item(node_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let trait_item = tcx.hir().expect_trait_item(node_id); let method_sig = match trait_item.node { hir::TraitItemKind::Method(ref sig, _) => Some(sig), @@ -172,8 +172,8 @@ pub fn check_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { } pub fn check_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let impl_item = tcx.hir.expect_impl_item(node_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let impl_item = tcx.hir().expect_impl_item(node_id); let method_sig = match impl_item.node { hir::ImplItemKind::Method(ref sig, _) => Some(sig), @@ -190,7 +190,7 @@ fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let code = ObligationCauseCode::MiscObligation; for_id(tcx, item_id, span).with_fcx(|fcx, tcx| { - let item = fcx.tcx.associated_item(fcx.tcx.hir.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()), @@ -236,7 +236,7 @@ fn for_item<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, item: &hir::Item) fn for_id<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, id: ast::NodeId, span: Span) -> CheckWfFcxBuilder<'a, 'gcx, 'tcx> { - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); CheckWfFcxBuilder { inherited: Inherited::build(tcx, def_id), id, @@ -252,7 +252,7 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>, { for_item(tcx, item).with_fcx(|fcx, fcx_tcx| { let variants = lookup_fields(fcx); - let def_id = fcx.tcx.hir.local_def_id(item.id); + let def_id = fcx.tcx.hir().local_def_id(item.id); let packed = fcx.tcx.adt_def(def_id).repr.packed(); for variant in &variants { @@ -315,7 +315,7 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) { debug!("check_trait: {:?}", item.id); - let trait_def_id = tcx.hir.local_def_id(item.id); + let trait_def_id = tcx.hir().local_def_id(item.id); let trait_def = tcx.trait_def(trait_def_id); if trait_def.is_marker { @@ -337,7 +337,7 @@ fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) { fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) { for_item(tcx, item).with_fcx(|fcx, tcx| { - let def_id = fcx.tcx.hir.local_def_id(item.id); + let def_id = fcx.tcx.hir().local_def_id(item.id); let sig = fcx.tcx.fn_sig(def_id); let sig = fcx.normalize_associated_types_in(item.span, &sig); let mut implied_bounds = vec![]; @@ -356,7 +356,7 @@ fn check_item_type<'a, 'tcx>( debug!("check_item_type: {:?}", item_id); for_id(tcx, item_id, ty_span).with_fcx(|fcx, gcx| { - let ty = gcx.type_of(gcx.hir.local_def_id(item_id)); + let ty = gcx.type_of(gcx.hir().local_def_id(item_id)); let item_ty = fcx.normalize_associated_types_in(ty_span, &ty); let mut forbid_unsized = true; @@ -387,7 +387,7 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, debug!("check_impl: {:?}", item); for_item(tcx, item).with_fcx(|fcx, tcx| { - let item_def_id = fcx.tcx.hir.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) => { @@ -621,7 +621,7 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>( let generics = tcx.generics_of(def_id); // only check named existential types if generics.parent.is_none() { - let opaque_node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let opaque_node_id = tcx.hir().as_local_node_id(def_id).unwrap(); if may_define_existential_type(tcx, fn_def_id, opaque_node_id) { trace!("check_existential_types may define. Generics: {:#?}", generics); let mut seen: FxHashMap<_, Vec<_>> = FxHashMap::default(); @@ -821,7 +821,7 @@ fn check_variances_for_type_defn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item, hir_generics: &hir::Generics) { - let item_def_id = tcx.hir.local_def_id(item.id); + let item_def_id = tcx.hir().local_def_id(item.id); let ty = tcx.type_of(item_def_id); if tcx.has_error_field(ty) { return; @@ -908,7 +908,7 @@ fn check_false_global_bounds<'a, 'gcx, 'tcx>( let empty_env = ty::ParamEnv::empty(); - let def_id = fcx.tcx.hir.local_def_id(id); + let def_id = fcx.tcx.hir().local_def_id(id); let predicates = fcx.tcx.predicates_of(def_id).predicates .iter() .map(|(p, _)| *p) @@ -956,21 +956,21 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'a, 'tcx> { fn visit_item(&mut self, i: &hir::Item) { debug!("visit_item: {:?}", i); - let def_id = self.tcx.hir.local_def_id(i.id); + let def_id = self.tcx.hir().local_def_id(i.id); ty::query::queries::check_item_well_formed::ensure(self.tcx, def_id); intravisit::walk_item(self, i); } fn visit_trait_item(&mut self, trait_item: &'v hir::TraitItem) { debug!("visit_trait_item: {:?}", trait_item); - let def_id = self.tcx.hir.local_def_id(trait_item.id); + let def_id = self.tcx.hir().local_def_id(trait_item.id); ty::query::queries::check_trait_item_well_formed::ensure(self.tcx, def_id); intravisit::walk_trait_item(self, trait_item) } fn visit_impl_item(&mut self, impl_item: &'v hir::ImplItem) { debug!("visit_impl_item: {:?}", impl_item); - let def_id = self.tcx.hir.local_def_id(impl_item.id); + let def_id = self.tcx.hir().local_def_id(impl_item.id); ty::query::queries::check_impl_item_well_formed::ensure(self.tcx, def_id); intravisit::walk_impl_item(self, impl_item) } @@ -991,7 +991,7 @@ struct AdtField<'tcx> { impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn non_enum_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> { let fields = struct_def.fields().iter().map(|field| { - let field_ty = self.tcx.type_of(self.tcx.hir.local_def_id(field.id)); + let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id(field.id)); let field_ty = self.normalize_associated_types_in(field.span, &field_ty); AdtField { ty: field_ty, span: field.span } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 669f2bcb77c4d..8d7fc008fb0d0 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -32,8 +32,8 @@ use syntax_pos::Span; impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) -> &'gcx ty::TypeckTables<'gcx> { - let item_id = self.tcx.hir.body_owner(body.id()); - let item_def_id = self.tcx.hir.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); // This attribute causes us to dump some writeback information // in the form of errors, which is used for unit tests. @@ -99,7 +99,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { body: &'gcx hir::Body, rustc_dump_user_substs: bool, ) -> WritebackCx<'cx, 'gcx, 'tcx> { - let owner = fcx.tcx.hir.definitions().node_to_hir_id(body.id().node_id); + let owner = fcx.tcx.hir().definitions().node_to_hir_id(body.id().node_id); WritebackCx { fcx, @@ -233,7 +233,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { match e.node { hir::ExprKind::Closure(_, _, body, _, _) => { - let body = self.fcx.tcx.hir.body(body); + let body = self.fcx.tcx.hir().body(body); for arg in &body.arguments { self.visit_node_id(e.span, arg.hir_id); } @@ -398,7 +398,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { c_sig } else { span_bug!( - self.fcx.tcx.hir.span_if_local(def_id).unwrap(), + self.fcx.tcx.hir().span_if_local(def_id).unwrap(), "writeback: `{:?}` missing from the global type context", c_sig ); @@ -412,7 +412,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { fn visit_opaque_types(&mut self, span: Span) { for (&def_id, opaque_defn) in self.fcx.opaque_types.borrow().iter() { - let node_id = self.tcx().hir.as_local_node_id(def_id).unwrap(); + let node_id = self.tcx().hir().as_local_node_id(def_id).unwrap(); let instantiated_ty = self.resolve(&opaque_defn.concrete_ty, &node_id); let generics = self.tcx().generics_of(def_id); @@ -545,7 +545,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } fn visit_field_id(&mut self, node_id: ast::NodeId) { - let hir_id = self.tcx().hir.node_to_hir_id(node_id); + let hir_id = self.tcx().hir().node_to_hir_id(node_id); if let Some(index) = self.fcx .tables .borrow_mut() @@ -591,8 +591,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { // Unit-testing mechanism: if self.rustc_dump_user_substs { - let node_id = self.tcx().hir.hir_to_node_id(hir_id); - let span = self.tcx().hir.span(node_id); + let node_id = self.tcx().hir().hir_to_node_id(hir_id); + let span = self.tcx().hir().span(node_id); self.tcx().sess.span_err( span, &format!("user substs: {:?}", user_substs), @@ -710,21 +710,21 @@ impl Locatable for Span { impl Locatable for ast::NodeId { fn to_span(&self, tcx: &TyCtxt) -> Span { - tcx.hir.span(*self) + tcx.hir().span(*self) } } impl Locatable for DefIndex { fn to_span(&self, tcx: &TyCtxt) -> Span { - let node_id = tcx.hir.def_index_to_node_id(*self); - tcx.hir.span(node_id) + let node_id = tcx.hir().def_index_to_node_id(*self); + tcx.hir().span(node_id) } } impl Locatable for hir::HirId { fn to_span(&self, tcx: &TyCtxt) -> Span { - let node_id = tcx.hir.hir_to_node_id(*self); - tcx.hir.span(node_id) + let node_id = tcx.hir().hir_to_node_id(*self); + tcx.hir().span(node_id) } } diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 9c1860fb82ee4..e6171e9da3bd5 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -25,15 +25,15 @@ use rustc_data_structures::fx::FxHashMap; pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut used_trait_imports = DefIdSet::default(); - for &body_id in tcx.hir.krate().bodies.keys() { - let item_def_id = tcx.hir.body_owner_def_id(body_id); + for &body_id in tcx.hir().krate().bodies.keys() { + let item_def_id = tcx.hir().body_owner_def_id(body_id); let imports = tcx.used_trait_imports(item_def_id); debug!("GatherVisitor: item_def_id={:?} with imports {:#?}", item_def_id, imports); used_trait_imports.extend(imports.iter()); } let mut visitor = CheckVisitor { tcx, used_trait_imports }; - tcx.hir.krate().visit_all_item_likes(&mut visitor); + tcx.hir().krate().visit_all_item_likes(&mut visitor); unused_crates_lint(tcx); } @@ -62,12 +62,12 @@ struct CheckVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> CheckVisitor<'a, 'tcx> { fn check_import(&self, id: ast::NodeId, span: Span) { - let def_id = self.tcx.hir.local_def_id(id); + let def_id = self.tcx.hir().local_def_id(id); if !self.tcx.maybe_unused_trait_import(def_id) { return; } - let import_def_id = self.tcx.hir.local_def_id(id); + let import_def_id = self.tcx.hir().local_def_id(id); if self.used_trait_imports.contains(&import_def_id) { return; } @@ -105,8 +105,8 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) { // Note that if we carry through to the `extern_mod_stmt_cnum` query // below it'll cause a panic because `def_id` is actually bogus at this // point in time otherwise. - if let Some(id) = tcx.hir.as_local_node_id(def_id) { - if tcx.hir.find(id).is_none() { + if let Some(id) = tcx.hir().as_local_node_id(def_id) { + if tcx.hir().find(id).is_none() { return false; } } @@ -125,14 +125,14 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) { // Collect all the extern crates (in a reliable order). let mut crates_to_lint = vec![]; - tcx.hir.krate().visit_all_item_likes(&mut CollectExternCrateVisitor { + tcx.hir().krate().visit_all_item_likes(&mut CollectExternCrateVisitor { tcx, crates_to_lint: &mut crates_to_lint, }); for extern_crate in &crates_to_lint { - let id = tcx.hir.as_local_node_id(extern_crate.def_id).unwrap(); - let item = tcx.hir.expect_item(id); + let id = tcx.hir().as_local_node_id(extern_crate.def_id).unwrap(); + let item = tcx.hir().expect_item(id); // If the crate is fully unused, we suggest removing it altogether. // We do this in any edition. @@ -223,7 +223,7 @@ struct ExternCrateToLint { impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for CollectExternCrateVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { if let hir::ItemKind::ExternCrate(orig_name) = item.node { - let extern_crate_def_id = self.tcx.hir.local_def_id(item.id); + let extern_crate_def_id = self.tcx.hir().local_def_id(item.id); self.crates_to_lint.push( ExternCrateToLint { def_id: extern_crate_def_id, diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs index a5ad31e0b6b5f..bdb2a9a8af134 100644 --- a/src/librustc_typeck/coherence/builtin.rs +++ b/src/librustc_typeck/coherence/builtin.rs @@ -46,8 +46,8 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { where F: FnMut(TyCtxt<'a, 'tcx, 'tcx>, DefId) { if Some(self.trait_def_id) == trait_def_id { - for &impl_id in self.tcx.hir.trait_impls(self.trait_def_id) { - let impl_def_id = self.tcx.hir.local_def_id(impl_id); + for &impl_id in self.tcx.hir().trait_impls(self.trait_def_id) { + let impl_def_id = self.tcx.hir().local_def_id(impl_id); f(self.tcx, impl_def_id); } } @@ -60,8 +60,8 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: /* do nothing */ } else { // Destructors only work on nominal types. - if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_did) { - if let Some(Node::Item(item)) = tcx.hir.find(impl_node_id) { + if let Some(impl_node_id) = tcx.hir().as_local_node_id(impl_did) { + if let Some(Node::Item(item)) = tcx.hir().find(impl_node_id) { let span = match item.node { ItemKind::Impl(.., ref ty, _) => ty.span, _ => item.span, @@ -86,7 +86,7 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: 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.hir.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 crate"); @@ -97,7 +97,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: debug!("visit_implementation_of_copy: self_type={:?} (bound)", self_type); - let span = tcx.hir.span(impl_node_id); + let span = tcx.hir().span(impl_node_id); let param_env = tcx.param_env(impl_did); assert!(!self_type.has_escaping_bound_vars()); @@ -107,7 +107,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: match param_env.can_type_implement_copy(tcx, self_type) { Ok(()) => {} Err(CopyImplementationError::InfrigingFields(fields)) => { - let item = tcx.hir.expect_item(impl_node_id); + let item = tcx.hir().expect_item(impl_node_id); let span = if let ItemKind::Impl(.., Some(ref tr), _, _) = item.node { tr.path.span } else { @@ -124,7 +124,7 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: err.emit() } Err(CopyImplementationError::NotAnAdt) => { - let item = tcx.hir.expect_item(impl_node_id); + let item = tcx.hir().expect_item(impl_node_id); let span = if let ItemKind::Impl(.., ref ty, _) = item.node { ty.span } else { @@ -172,8 +172,8 @@ fn visit_implementation_of_dispatch_from_dyn<'a, 'tcx>( if impl_did.is_local() { let dispatch_from_dyn_trait = tcx.lang_items().dispatch_from_dyn_trait().unwrap(); - let impl_node_id = tcx.hir.as_local_node_id(impl_did).unwrap(); - let span = tcx.hir.span(impl_node_id); + let impl_node_id = tcx.hir().as_local_node_id(impl_did).unwrap(); + let span = tcx.hir().span(impl_node_id); let source = tcx.type_of(impl_did); assert!(!source.has_escaping_bound_vars()); @@ -342,7 +342,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, }); // this provider should only get invoked for local def-ids - let impl_node_id = gcx.hir.as_local_node_id(impl_did).unwrap_or_else(|| { + let impl_node_id = gcx.hir().as_local_node_id(impl_did).unwrap_or_else(|| { bug!("coerce_unsized_info: invoked for non-local def-id {:?}", impl_did) }); @@ -354,7 +354,7 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, source, target); - let span = gcx.hir.span(impl_node_id); + let span = gcx.hir().span(impl_node_id); let param_env = gcx.param_env(impl_did); assert!(!source.has_escaping_bound_vars()); @@ -491,11 +491,11 @@ pub fn coerce_unsized_info<'a, 'gcx>(gcx: TyCtxt<'a, 'gcx, 'gcx>, being coerced, none found"); return err_info; } else if diff_fields.len() > 1 { - let item = gcx.hir.expect_item(impl_node_id); + let item = gcx.hir().expect_item(impl_node_id); let span = if let ItemKind::Impl(.., Some(ref t), _, _) = item.node { t.path.span } else { - gcx.hir.span(impl_node_id) + gcx.hir().span(impl_node_id) }; let mut err = struct_span_err!(gcx.sess, diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs index d9dff1441296d..59989a65d4f91 100644 --- a/src/librustc_typeck/coherence/inherent_impls.rs +++ b/src/librustc_typeck/coherence/inherent_impls.rs @@ -33,7 +33,7 @@ pub fn crate_inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> Lrc { assert_eq!(crate_num, LOCAL_CRATE); - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let mut collect = InherentCollect { tcx, impls_map: Default::default(), @@ -95,7 +95,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> { _ => return }; - let def_id = self.tcx.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); let self_ty = self.tcx.type_of(def_id); let lang_items = self.tcx.lang_items(); match self_ty.sty { @@ -298,7 +298,7 @@ impl<'a, 'tcx> InherentCollect<'a, 'tcx> { // Add the implementation to the mapping from implementation to base // type def ID, if there is a base type for this implementation and // the implementation does not have any associated traits. - let impl_def_id = self.tcx.hir.local_def_id(item.id); + let impl_def_id = self.tcx.hir().local_def_id(item.id); let mut rc_vec = self.impls_map.inherent_impls .entry(def_id) .or_default(); diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index c0260d6714d05..ec1a43991f6aa 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -20,7 +20,7 @@ use lint; pub fn crate_inherent_impls_overlap_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) { assert_eq!(crate_num, LOCAL_CRATE); - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); krate.visit_all_item_likes(&mut InherentOverlapChecker { tcx }); } @@ -46,7 +46,7 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> { for &item2 in &impl_items2[..] { if (name, namespace) == name_and_namespace(item2) { - let node_id = self.tcx.hir.as_local_node_id(impl1); + let node_id = self.tcx.hir().as_local_node_id(impl1); let mut err = if used_to_be_allowed && node_id.is_some() { self.tcx.struct_span_lint_node( lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS, @@ -126,7 +126,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentOverlapChecker<'a, 'tcx> { hir::ItemKind::Struct(..) | hir::ItemKind::Trait(..) | hir::ItemKind::Union(..) => { - let type_def_id = self.tcx.hir.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); } _ => {} diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 9b17654d4690c..b92916d9c81c1 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -29,7 +29,7 @@ mod orphan; mod unsafety; fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) { - let impl_def_id = tcx.hir.local_def_id(node_id); + let impl_def_id = tcx.hir().local_def_id(node_id); // If there are no traits, then this implementation must have a // base type. @@ -135,7 +135,7 @@ pub fn provide(providers: &mut Providers) { } fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { - let impls = tcx.hir.trait_impls(def_id); + let impls = tcx.hir().trait_impls(def_id); for &impl_id in impls { check_impl(tcx, impl_id); } @@ -146,7 +146,7 @@ fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) { } pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - for &trait_def_id in tcx.hir.krate().trait_impls.keys() { + for &trait_def_id in tcx.hir().krate().trait_impls.keys() { ty::query::queries::coherent_trait::ensure(tcx, trait_def_id); } @@ -162,7 +162,7 @@ pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { /// same type. Likewise, no two inherent impls for a given type /// constructor provide a method with the same name. fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) { - let impl_def_id = tcx.hir.local_def_id(node_id); + let impl_def_id = tcx.hir().local_def_id(node_id); let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); let trait_def_id = trait_ref.def_id; diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 14c6864434fcf..47edf59f0ad98 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -18,7 +18,7 @@ use rustc::hir; pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut orphan = OrphanChecker { tcx }; - tcx.hir.krate().visit_all_item_likes(&mut orphan); + tcx.hir().krate().visit_all_item_likes(&mut orphan); } struct OrphanChecker<'cx, 'tcx: 'cx> { @@ -32,11 +32,11 @@ 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.hir.local_def_id(item.id); + let def_id = self.tcx.hir().local_def_id(item.id); // "Trait" impl if let hir::ItemKind::Impl(.., Some(_), _, _) = item.node { debug!("coherence2::orphan check: trait impl {}", - self.tcx.hir.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; let cm = self.tcx.sess.source_map(); diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index 0894c1d49e80e..b4196b572b4b2 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.hir.krate().visit_all_item_likes(&mut unsafety); + tcx.hir().krate().visit_all_item_likes(&mut unsafety); } struct UnsafetyChecker<'cx, 'tcx: 'cx> { @@ -31,7 +31,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> { unsafety: hir::Unsafety, polarity: hir::ImplPolarity) { - if let Some(trait_ref) = self.tcx.impl_trait_ref(self.tcx.hir.local_def_id(item.id)) { + if let Some(trait_ref) = self.tcx.impl_trait_ref(self.tcx.hir().local_def_id(item.id)) { let trait_def = self.tcx.trait_def(trait_ref.def_id); let unsafe_attr = impl_generics.and_then(|generics| { generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle") diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 5682a73bed573..9104c15bdd5a2 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -66,7 +66,7 @@ struct OnlySelfBounds(bool); pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut visitor = CollectItemTypesVisitor { tcx }; - tcx.hir + tcx.hir() .krate() .visit_all_item_likes(&mut visitor.as_deep_visitor()); } @@ -115,7 +115,7 @@ struct CollectItemTypesVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir) + NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item) { @@ -130,7 +130,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { hir::GenericParamKind::Type { default: Some(_), .. } => { - let def_id = self.tcx.hir.local_def_id(param.id); + let def_id = self.tcx.hir().local_def_id(param.id); self.tcx.type_of(def_id); } hir::GenericParamKind::Type { .. } => {} @@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr) { if let hir::ExprKind::Closure(..) = expr.node { - let def_id = self.tcx.hir.local_def_id(expr.id); + let def_id = self.tcx.hir().local_def_id(expr.id); self.tcx.generics_of(def_id); self.tcx.type_of(def_id); } @@ -252,12 +252,12 @@ fn type_param_predicates<'a, 'tcx>( // written inline like `` or in a where clause like // `where T : Foo`. - let param_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let param_owner = tcx.hir.ty_param_owner(param_id); - let param_owner_def_id = tcx.hir.local_def_id(param_owner); + let param_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let param_owner = tcx.hir().ty_param_owner(param_id); + let param_owner_def_id = tcx.hir().local_def_id(param_owner); let generics = tcx.generics_of(param_owner_def_id); let index = generics.param_def_id_to_index[&def_id]; - let ty = tcx.mk_ty_param(index, tcx.hir.ty_param_name(param_id).as_interned_str()); + let ty = tcx.mk_ty_param(index, tcx.hir().ty_param_name(param_id).as_interned_str()); // Don't look for bounds where the type parameter isn't in scope. let parent = if item_def_id == param_owner_def_id { @@ -277,8 +277,8 @@ fn type_param_predicates<'a, 'tcx>( }, ); - let item_node_id = tcx.hir.as_local_node_id(item_def_id).unwrap(); - let ast_generics = match tcx.hir.get(item_node_id) { + let item_node_id = tcx.hir().as_local_node_id(item_def_id).unwrap(); + let ast_generics = match tcx.hir().get(item_node_id) { Node::TraitItem(item) => &item.generics, Node::ImplItem(item) => &item.generics, @@ -384,7 +384,7 @@ fn is_param<'a, 'tcx>( if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node { match path.def { Def::SelfTy(Some(def_id), None) | Def::TyParam(def_id) => { - def_id == tcx.hir.local_def_id(param_id) + def_id == tcx.hir().local_def_id(param_id) } _ => false, } @@ -394,9 +394,9 @@ fn is_param<'a, 'tcx>( } fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { - let it = tcx.hir.expect_item(item_id); + let it = tcx.hir().expect_item(item_id); debug!("convert: item {} with id {}", it.name, it.id); - let def_id = tcx.hir.local_def_id(item_id); + let def_id = tcx.hir().local_def_id(item_id); match it.node { // These don't define types. hir::ItemKind::ExternCrate(_) @@ -405,7 +405,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { | hir::ItemKind::GlobalAsm(_) => {} hir::ItemKind::ForeignMod(ref foreign_mod) => { for item in &foreign_mod.items { - let def_id = tcx.hir.local_def_id(item.id); + let def_id = tcx.hir().local_def_id(item.id); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); @@ -443,7 +443,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { tcx.predicates_of(def_id); for f in struct_def.fields() { - let def_id = tcx.hir.local_def_id(f.id); + let def_id = tcx.hir().local_def_id(f.id); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); @@ -476,8 +476,8 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { } fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: ast::NodeId) { - let trait_item = tcx.hir.expect_trait_item(trait_item_id); - let def_id = tcx.hir.local_def_id(trait_item.id); + let trait_item = tcx.hir().expect_trait_item(trait_item_id); + let def_id = tcx.hir().local_def_id(trait_item.id); tcx.generics_of(def_id); match trait_item.node { @@ -497,17 +497,17 @@ fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: ast: } fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: ast::NodeId) { - let def_id = tcx.hir.local_def_id(impl_item_id); + let def_id = tcx.hir().local_def_id(impl_item_id); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); - if let hir::ImplItemKind::Method(..) = tcx.hir.expect_impl_item(impl_item_id).node { + if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).node { tcx.fn_sig(def_id); } } fn convert_variant_ctor<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ctor_id: ast::NodeId) { - let def_id = tcx.hir.local_def_id(ctor_id); + let def_id = tcx.hir().local_def_id(ctor_id); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); @@ -528,7 +528,7 @@ fn convert_enum_variant_types<'a, 'tcx>( let wrapped_discr = prev_discr.map_or(initial, |d| d.wrap_incr(tcx)); prev_discr = Some( if let Some(ref e) = variant.node.disr_expr { - let expr_did = tcx.hir.local_def_id(e.id); + let expr_did = tcx.hir().local_def_id(e.id); def.eval_explicit_discr(tcx, expr_did) } else if let Some(discr) = repr_type.disr_incr(tcx, prev_discr) { Some(discr) @@ -551,7 +551,7 @@ fn convert_enum_variant_types<'a, 'tcx>( ); for f in variant.node.data.fields() { - let def_id = tcx.hir.local_def_id(f.id); + let def_id = tcx.hir().local_def_id(f.id); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); @@ -573,12 +573,12 @@ fn convert_variant<'a, 'tcx>( attribute_def_id: DefId ) -> ty::VariantDef { let mut seen_fields: FxHashMap = Default::default(); - let node_id = tcx.hir.as_local_node_id(did).unwrap(); + let node_id = tcx.hir().as_local_node_id(did).unwrap(); let fields = def .fields() .iter() .map(|f| { - let fid = tcx.hir.local_def_id(f.id); + let fid = tcx.hir().local_def_id(f.id); let dup_span = seen_fields.get(&f.ident.modern()).cloned(); if let Some(prev_span) = dup_span { struct_span_err!( @@ -614,8 +614,8 @@ fn convert_variant<'a, 'tcx>( fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::AdtDef { use rustc::hir::*; - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let item = match tcx.hir.get(node_id) { + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let item = match tcx.hir().get(node_id) { Node::Item(item) => item, _ => bug!(), }; @@ -629,10 +629,10 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad def.variants .iter() .map(|v| { - let did = tcx.hir.local_def_id(v.node.data.id()); + let did = tcx.hir().local_def_id(v.node.data.id()); let discr = if let Some(ref e) = v.node.disr_expr { distance_from_explicit = 0; - ty::VariantDiscr::Explicit(tcx.hir.local_def_id(e.id)) + ty::VariantDiscr::Explicit(tcx.hir().local_def_id(e.id)) } else { ty::VariantDiscr::Relative(distance_from_explicit) }; @@ -647,7 +647,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad ItemKind::Struct(ref def, _) => { // Use separate constructor id for unit/tuple structs and reuse did for braced structs. let ctor_id = if !def.is_struct() { - Some(tcx.hir.local_def_id(def.id())) + Some(tcx.hir().local_def_id(def.id())) } else { None }; @@ -689,9 +689,9 @@ fn super_predicates_of<'a, 'tcx>( trait_def_id: DefId, ) -> Lrc> { debug!("super_predicates(trait_def_id={:?})", trait_def_id); - let trait_node_id = tcx.hir.as_local_node_id(trait_def_id).unwrap(); + let trait_node_id = tcx.hir().as_local_node_id(trait_def_id).unwrap(); - let item = match tcx.hir.get(trait_node_id) { + let item = match tcx.hir().get(trait_node_id) { Node::Item(item) => item, _ => bug!("trait_node_id {} is not an item", trait_node_id), }; @@ -738,8 +738,8 @@ fn super_predicates_of<'a, 'tcx>( } fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::TraitDef { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let item = tcx.hir.expect_item(node_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let item = tcx.hir().expect_item(node_id); let (is_auto, unsafety) = match item.node { hir::ItemKind::Trait(is_auto, unsafety, ..) => (is_auto == hir::IsAuto::Yes, unsafety), @@ -815,7 +815,7 @@ fn has_late_bound_regions<'a, 'tcx>( return; } - let hir_id = self.tcx.hir.node_to_hir_id(lt.id); + let hir_id = self.tcx.hir().node_to_hir_id(lt.id); match self.tcx.named_region(hir_id) { Some(rl::Region::Static) | Some(rl::Region::EarlyBound(..)) => {} Some(rl::Region::LateBound(debruijn, _, _)) @@ -842,7 +842,7 @@ fn has_late_bound_regions<'a, 'tcx>( }; for param in &generics.params { if let GenericParamKind::Lifetime { .. } = param.kind { - let hir_id = tcx.hir.node_to_hir_id(param.id); + let hir_id = tcx.hir().node_to_hir_id(param.id); if tcx.is_late_bound(hir_id) { return Some(param.span); } @@ -884,14 +884,14 @@ fn has_late_bound_regions<'a, 'tcx>( fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Generics { use rustc::hir::*; - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); - let node = tcx.hir.get(node_id); + let node = tcx.hir().get(node_id); let parent_def_id = match node { Node::ImplItem(_) | Node::TraitItem(_) | Node::Variant(_) | Node::StructCtor(_) | Node::Field(_) => { - let parent_id = tcx.hir.get_parent(node_id); - Some(tcx.hir.local_def_id(parent_id)) + let parent_id = tcx.hir().get_parent(node_id); + Some(tcx.hir().local_def_id(parent_id)) } Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(..), @@ -939,7 +939,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty opt_self = Some(ty::GenericParamDef { index: 0, name: keywords::SelfUpper.name().as_interned_str(), - def_id: tcx.hir.local_def_id(param_id), + def_id: tcx.hir().local_def_id(param_id), pure_wrt_drop: false, kind: ty::GenericParamDefKind::Type { has_default: false, @@ -985,13 +985,13 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty .map(|(i, param)| ty::GenericParamDef { name: param.name.ident().as_interned_str(), index: own_start + i as u32, - def_id: tcx.hir.local_def_id(param.id), + def_id: tcx.hir().local_def_id(param.id), pure_wrt_drop: param.pure_wrt_drop, kind: ty::GenericParamDefKind::Lifetime, }), ); - let hir_id = tcx.hir.node_to_hir_id(node_id); + let hir_id = tcx.hir().node_to_hir_id(node_id); let object_lifetime_defaults = tcx.object_lifetime_defaults(hir_id); // Now create the real type parameters. @@ -1031,7 +1031,7 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty let ty_param = ty::GenericParamDef { index: type_start + i as u32, name: param.name.ident().as_interned_str(), - def_id: tcx.hir.local_def_id(param.id), + def_id: tcx.hir().local_def_id(param.id), pure_wrt_drop: param.pure_wrt_drop, kind: ty::GenericParamDefKind::Type { has_default: default.is_some(), @@ -1123,11 +1123,11 @@ fn report_assoc_ty_on_inherent_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { use rustc::hir::*; - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); let icx = ItemCtxt::new(tcx, def_id); - match tcx.hir.get(node_id) { + match tcx.hir().get(node_id) { Node::TraitItem(item) => match item.node { TraitItemKind::Method(..) => { let substs = Substs::identity_for_item(tcx, def_id); @@ -1147,7 +1147,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { ImplItemKind::Const(ref ty, _) => icx.to_ty(ty), ImplItemKind::Existential(_) => { if tcx - .impl_trait_ref(tcx.hir.get_parent_did(node_id)) + .impl_trait_ref(tcx.hir().get_parent_did(node_id)) .is_none() { report_assoc_ty_on_inherent_impl(tcx, item.span); @@ -1157,7 +1157,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { } ImplItemKind::Type(ref ty) => { if tcx - .impl_trait_ref(tcx.hir.get_parent_did(node_id)) + .impl_trait_ref(tcx.hir().get_parent_did(node_id)) .is_none() { report_assoc_ty_on_inherent_impl(tcx, item.span); @@ -1240,7 +1240,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { .. }) => match *def { VariantData::Unit(..) | VariantData::Struct(..) => { - tcx.type_of(tcx.hir.get_parent_did(node_id)) + tcx.type_of(tcx.hir().get_parent_did(node_id)) } VariantData::Tuple(..) => { let substs = Substs::identity_for_item(tcx, def_id); @@ -1255,7 +1255,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { .. }) => { if gen.is_some() { - let hir_id = tcx.hir.node_to_hir_id(node_id); + let hir_id = tcx.hir().node_to_hir_id(node_id); return tcx.typeck_tables_of(def_id).node_id_to_type(hir_id); } @@ -1266,7 +1266,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { tcx.mk_closure(def_id, substs) } - Node::AnonConst(_) => match tcx.hir.get(tcx.hir.get_parent_node(node_id)) { + Node::AnonConst(_) => match tcx.hir().get(tcx.hir().get_parent_node(node_id)) { Node::Ty(&hir::Ty { node: hir::TyKind::Array(_, ref constant), .. @@ -1292,7 +1292,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> { .. }) if e.id == node_id => { - tcx.adt_def(tcx.hir.get_parent_did(node_id)) + tcx.adt_def(tcx.hir().get_parent_did(node_id)) .repr .discr_type() .to_ty(tcx) @@ -1365,10 +1365,10 @@ fn find_existential_constraints<'a, 'tcx>( impl<'a, 'tcx> intravisit::Visitor<'tcx> for ConstraintLocator<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { - intravisit::NestedVisitorMap::All(&self.tcx.hir) + intravisit::NestedVisitorMap::All(&self.tcx.hir()) } fn visit_item(&mut self, it: &'tcx Item) { - let def_id = self.tcx.hir.local_def_id(it.id); + let def_id = self.tcx.hir().local_def_id(it.id); // the existential type itself or its children are not within its reveal scope if def_id != self.def_id { self.check(def_id); @@ -1376,7 +1376,7 @@ fn find_existential_constraints<'a, 'tcx>( } } fn visit_impl_item(&mut self, it: &'tcx ImplItem) { - let def_id = self.tcx.hir.local_def_id(it.id); + let def_id = self.tcx.hir().local_def_id(it.id); // the existential type itself or its children are not within its reveal scope if def_id != self.def_id { self.check(def_id); @@ -1384,7 +1384,7 @@ fn find_existential_constraints<'a, 'tcx>( } } fn visit_trait_item(&mut self, it: &'tcx TraitItem) { - let def_id = self.tcx.hir.local_def_id(it.id); + let def_id = self.tcx.hir().local_def_id(it.id); self.check(def_id); intravisit::walk_trait_item(self, it); } @@ -1395,16 +1395,16 @@ fn find_existential_constraints<'a, 'tcx>( tcx, found: None, }; - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let parent = tcx.hir.get_parent(node_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let parent = tcx.hir().get_parent(node_id); trace!("parent_id: {:?}", parent); if parent == ast::CRATE_NODE_ID { - intravisit::walk_crate(&mut locator, tcx.hir.krate()); + intravisit::walk_crate(&mut locator, tcx.hir().krate()); } else { - trace!("parent: {:?}", tcx.hir.get(parent)); - match tcx.hir.get(parent) { + trace!("parent: {:?}", tcx.hir().get(parent)); + match tcx.hir().get(parent) { Node::Item(ref it) => intravisit::walk_item(&mut locator, it), Node::ImplItem(ref it) => intravisit::walk_impl_item(&mut locator, it), Node::TraitItem(ref it) => intravisit::walk_trait_item(&mut locator, it), @@ -1429,11 +1429,11 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig use rustc::hir::*; use rustc::hir::Node::*; - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); let icx = ItemCtxt::new(tcx, def_id); - match tcx.hir.get(node_id) { + match tcx.hir().get(node_id) { TraitItem(hir::TraitItem { node: TraitItemKind::Method(sig, _), .. @@ -1452,7 +1452,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig node: ForeignItemKind::Fn(ref fn_decl, _, _), .. }) => { - let abi = tcx.hir.get_foreign_abi(node_id); + let abi = tcx.hir().get_foreign_abi(node_id); compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi) } @@ -1465,10 +1465,10 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig }, .. }) => { - let ty = tcx.type_of(tcx.hir.get_parent_did(node_id)); + let ty = tcx.type_of(tcx.hir().get_parent_did(node_id)); let inputs = fields .iter() - .map(|f| tcx.type_of(tcx.hir.local_def_id(f.id))); + .map(|f| tcx.type_of(tcx.hir().local_def_id(f.id))); ty::Binder::bind(tcx.mk_fn_sig( inputs, ty, @@ -1512,8 +1512,8 @@ fn impl_trait_ref<'a, 'tcx>( ) -> Option> { let icx = ItemCtxt::new(tcx, def_id); - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - match tcx.hir.expect_item(node_id).node { + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + match tcx.hir().expect_item(node_id).node { hir::ItemKind::Impl(.., ref opt_trait_ref, _, _) => { opt_trait_ref.as_ref().map(|ast_trait_ref| { let selfty = tcx.type_of(def_id); @@ -1525,8 +1525,8 @@ fn impl_trait_ref<'a, 'tcx>( } fn impl_polarity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> hir::ImplPolarity { - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - match tcx.hir.expect_item(node_id).node { + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + match tcx.hir().expect_item(node_id).node { hir::ItemKind::Impl(_, polarity, ..) => polarity, ref item => bug!("impl_polarity: {:?} not an impl", item), } @@ -1597,7 +1597,7 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx>( .iter() .filter(move |param| match param.kind { GenericParamKind::Lifetime { .. } => { - let hir_id = tcx.hir.node_to_hir_id(param.id); + let hir_id = tcx.hir().node_to_hir_id(param.id); !tcx.is_late_bound(hir_id) } _ => false, @@ -1695,8 +1695,8 @@ fn explicit_predicates_of<'a, 'tcx>( } } - let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); - let node = tcx.hir.get(node_id); + let node_id = tcx.hir().as_local_node_id(def_id).unwrap(); + let node = tcx.hir().get(node_id); let mut is_trait = None; let mut is_default_impl_trait = None; @@ -1825,7 +1825,7 @@ fn explicit_predicates_of<'a, 'tcx>( let mut index = parent_count + has_own_self as u32; for param in early_bound_lifetimes_from_generics(tcx, ast_generics) { let region = tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion { - def_id: tcx.hir.local_def_id(param.id), + def_id: tcx.hir().local_def_id(param.id), index, name: param.name.ident().as_interned_str(), })); @@ -1938,14 +1938,14 @@ fn explicit_predicates_of<'a, 'tcx>( // Add predicates from associated type bounds. if let Some((self_trait_ref, trait_items)) = is_trait { predicates.extend(trait_items.iter().flat_map(|trait_item_ref| { - let trait_item = tcx.hir.trait_item(trait_item_ref.id); + let trait_item = tcx.hir().trait_item(trait_item_ref.id); let bounds = match trait_item.node { hir::TraitItemKind::Type(ref bounds, _) => bounds, _ => return vec![].into_iter() }; let assoc_ty = - tcx.mk_projection(tcx.hir.local_def_id(trait_item.id), self_trait_ref.substs); + tcx.mk_projection(tcx.hir().local_def_id(trait_item.id), self_trait_ref.substs); let bounds = compute_bounds( &ItemCtxt::new(tcx, def_id), @@ -2108,7 +2108,7 @@ fn compute_sig_of_foreign_fn_decl<'a, 'tcx>( &format!( "use of SIMD type `{}` in FFI is highly experimental and \ may result in invalid code", - tcx.hir.node_to_pretty_string(ast_ty.id) + tcx.hir().node_to_pretty_string(ast_ty.id) ), ) .help("add #![feature(simd_ffi)] to the crate attributes to enable") @@ -2127,7 +2127,7 @@ fn compute_sig_of_foreign_fn_decl<'a, 'tcx>( } fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { - match tcx.hir.get_if_local(def_id) { + match tcx.hir().get_if_local(def_id) { Some(Node::ForeignItem(..)) => true, Some(_) => false, _ => bug!("is_foreign_item applied to non-local def-id {:?}", def_id), @@ -2249,7 +2249,7 @@ fn linkage_by_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, name: & "weak" => WeakAny, "weak_odr" => WeakODR, _ => { - let span = tcx.hir.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 { diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 74a53f7fca273..a2071fd6d47e0 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -62,7 +62,7 @@ pub fn impl_wf_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { // We will tag this as part of the WF check -- logically, it is, // but it's one that we must perform earlier than the rest of // WfCheck. - tcx.hir.krate().visit_all_item_likes(&mut ImplWfCheck { tcx }); + tcx.hir().krate().visit_all_item_likes(&mut ImplWfCheck { tcx }); } struct ImplWfCheck<'a, 'tcx: 'a> { @@ -72,7 +72,7 @@ struct ImplWfCheck<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { if let hir::ItemKind::Impl(.., ref impl_item_refs) = item.node { - let impl_def_id = self.tcx.hir.local_def_id(item.id); + let impl_def_id = self.tcx.hir().local_def_id(item.id); enforce_impl_params_are_constrained(self.tcx, impl_def_id, impl_item_refs); @@ -101,7 +101,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, '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| tcx.hir.local_def_id(item_ref.id.node_id)) + .map(|item_ref| tcx.hir().local_def_id(item_ref.id.node_id)) .filter(|&def_id| { let item = tcx.associated_item(def_id); item.kind == ty::AssociatedKind::Type && item.defaultness.has_value() @@ -176,7 +176,7 @@ fn enforce_impl_items_are_distinct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut seen_type_items = FxHashMap::default(); let mut seen_value_items = FxHashMap::default(); for impl_item_ref in impl_item_refs { - let impl_item = tcx.hir.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 0fba311d7f7d5..ae3cfbb9b3716 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -182,11 +182,11 @@ fn require_same_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, main_id: ast::NodeId, main_span: Span) { - let main_def_id = tcx.hir.local_def_id(main_id); + let main_def_id = tcx.hir().local_def_id(main_id); let main_t = tcx.type_of(main_def_id); match main_t.sty { ty::FnDef(..) => { - if let Some(Node::Item(it)) = tcx.hir.find(main_id) { + if let Some(Node::Item(it)) = tcx.hir().find(main_id) { if let hir::ItemKind::Fn(.., ref generics, _) = it.node { let mut error = false; if !generics.params.is_empty() { @@ -248,11 +248,11 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, start_id: ast::NodeId, start_span: Span) { - let start_def_id = tcx.hir.local_def_id(start_id); + let start_def_id = tcx.hir().local_def_id(start_id); let start_t = tcx.type_of(start_def_id); match start_t.sty { ty::FnDef(..) => { - if let Some(Node::Item(it)) = tcx.hir.find(start_id) { + if let Some(Node::Item(it)) = tcx.hir().find(start_id) { if let hir::ItemKind::Fn(.., ref generics, _) = it.node { let mut error = false; if !generics.params.is_empty() { @@ -373,8 +373,8 @@ pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) -> // In case there are any projections etc, find the "environment" // def-id that will be used to determine the traits/predicates in // scope. This is derived from the enclosing item-like thing. - let env_node_id = tcx.hir.get_parent(hir_ty.id); - let env_def_id = tcx.hir.local_def_id(env_node_id); + let env_node_id = tcx.hir().get_parent(hir_ty.id); + let env_def_id = tcx.hir().local_def_id(env_node_id); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id); astconv::AstConv::ast_ty_to_ty(&item_cx, hir_ty) @@ -385,8 +385,8 @@ pub fn hir_trait_to_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_trait: // In case there are any projections etc, find the "environment" // def-id that will be used to determine the traits/predicates in // scope. This is derived from the enclosing item-like thing. - let env_node_id = tcx.hir.get_parent(hir_trait.ref_id); - let env_def_id = tcx.hir.local_def_id(env_node_id); + let env_node_id = tcx.hir().get_parent(hir_trait.ref_id); + let env_def_id = tcx.hir().local_def_id(env_node_id); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id); let mut projections = Vec::new(); let (principal, _) = astconv::AstConv::instantiate_poly_trait_ref_inner( diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index 30e304375fe0e..5f01087584286 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -48,7 +48,7 @@ pub fn infer_predicates<'tcx>( }; // Visit all the crates and infer predicates - tcx.hir.krate().visit_all_item_likes(&mut visitor); + tcx.hir().krate().visit_all_item_likes(&mut visitor); } global_inferred_outlives @@ -63,16 +63,16 @@ pub struct InferVisitor<'cx, 'tcx: 'cx> { impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { - let item_did = self.tcx.hir.local_def_id(item.id); + let item_did = self.tcx.hir().local_def_id(item.id); debug!("InferVisitor::visit_item(item={:?})", item_did); let node_id = self .tcx - .hir + .hir() .as_local_node_id(item_did) .expect("expected local def-id"); - let item = match self.tcx.hir.get(node_id) { + let item = match self.tcx.hir().get(node_id) { Node::Item(item) => item, _ => bug!(), }; diff --git a/src/librustc_typeck/outlives/mod.rs b/src/librustc_typeck/outlives/mod.rs index 1eb53ffc730f6..5796df2744b2b 100644 --- a/src/librustc_typeck/outlives/mod.rs +++ b/src/librustc_typeck/outlives/mod.rs @@ -35,11 +35,11 @@ fn inferred_outlives_of<'a, 'tcx>( item_def_id: DefId, ) -> Lrc>> { let id = tcx - .hir + .hir() .as_local_node_id(item_def_id) .expect("expected local def-id"); - match tcx.hir.get(id) { + match tcx.hir().get(id) { Node::Item(item) => match item.node { hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Union(..) => { let crate_map = tcx.inferred_outlives_crate(LOCAL_CRATE); diff --git a/src/librustc_typeck/outlives/test.rs b/src/librustc_typeck/outlives/test.rs index 48c495e1c9317..d855675d39019 100644 --- a/src/librustc_typeck/outlives/test.rs +++ b/src/librustc_typeck/outlives/test.rs @@ -13,7 +13,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::ty::TyCtxt; pub fn test_inferred_outlives<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - tcx.hir + tcx.hir() .krate() .visit_all_item_likes(&mut OutlivesTest { tcx }); } @@ -24,7 +24,7 @@ struct OutlivesTest<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for OutlivesTest<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { - let item_def_id = self.tcx.hir.local_def_id(item.id); + let item_def_id = self.tcx.hir().local_def_id(item.id); // For unit testing: check for a special "rustc_outlives" // attribute and report an error with various results if found. diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index ed32e5a8d9b38..ee554ee684d12 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -72,7 +72,7 @@ pub fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>) constraints: Vec::new(), }; - tcx.hir.krate().visit_all_item_likes(&mut constraint_cx); + tcx.hir().krate().visit_all_item_likes(&mut constraint_cx); constraint_cx } @@ -131,7 +131,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { fn visit_node_helper(&mut self, id: ast::NodeId) { let tcx = self.terms_cx.tcx; - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); self.build_constraints_for_item(def_id); } @@ -148,7 +148,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { return; } - let id = tcx.hir.as_local_node_id(def_id).unwrap(); + let id = tcx.hir().as_local_node_id(def_id).unwrap(); let inferred_start = self.terms_cx.inferred_starts[&id]; let current_item = &CurrentItem { inferred_start }; match tcx.type_of(def_id).sty { @@ -365,7 +365,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { return; } - let (local, remote) = if let Some(id) = self.tcx().hir.as_local_node_id(def_id) { + let (local, remote) = if let Some(id) = self.tcx().hir().as_local_node_id(def_id) { (Some(self.terms_cx.inferred_starts[&id]), None) } else { (None, Some(self.tcx().variances_of(def_id))) diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index e3c82d50a8d9b..4039281ffb780 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -56,12 +56,12 @@ fn crate_variances<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) -> Lrc> { - let id = tcx.hir.as_local_node_id(item_def_id).expect("expected local def-id"); + let id = tcx.hir().as_local_node_id(item_def_id).expect("expected local def-id"); let unsupported = || { // Variance not relevant. - span_bug!(tcx.hir.span(id), "asked to compute variance for wrong kind of item") + span_bug!(tcx.hir().span(id), "asked to compute variance for wrong kind of item") }; - match tcx.hir.get(id) { + match tcx.hir().get(id) { Node::Item(item) => match item.node { hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) | diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index 7116a42cead83..365c65bc04888 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -93,7 +93,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { let solutions = &self.solutions; self.terms_cx.inferred_starts.iter().map(|(&id, &InferredIndex(start))| { - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); let generics = tcx.generics_of(def_id); let mut variances = solutions[start..start+generics.count()].to_vec(); diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index 3692221a3fc3f..6d45b1876244e 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -91,7 +91,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx> // // - https://rust-lang.github.io/rustc-guide/query.html // - https://rust-lang.github.io/rustc-guide/variance.html - tcx.hir.krate().visit_all_item_likes(&mut terms_cx); + tcx.hir().krate().visit_all_item_likes(&mut terms_cx); terms_cx } @@ -106,14 +106,14 @@ 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.hir.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() } impl<'a, 'tcx> TermsContext<'a, 'tcx> { fn add_inferreds_for_item(&mut self, id: ast::NodeId) { let tcx = self.tcx; - let def_id = tcx.hir.local_def_id(id); + let def_id = tcx.hir().local_def_id(id); let count = tcx.generics_of(def_id).count(); if count == 0 { @@ -139,7 +139,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.hir.node_to_string(item.id)); + self.tcx.hir().node_to_string(item.id)); match item.node { hir::ItemKind::Struct(ref struct_def, _) | diff --git a/src/librustc_typeck/variance/test.rs b/src/librustc_typeck/variance/test.rs index 1acadb7e77236..7ae90e953e474 100644 --- a/src/librustc_typeck/variance/test.rs +++ b/src/librustc_typeck/variance/test.rs @@ -13,7 +13,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::ty::TyCtxt; pub fn test_variance<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - tcx.hir.krate().visit_all_item_likes(&mut VarianceTest { tcx }); + tcx.hir().krate().visit_all_item_likes(&mut VarianceTest { tcx }); } struct VarianceTest<'a, 'tcx: 'a> { @@ -22,7 +22,7 @@ struct VarianceTest<'a, 'tcx: 'a> { impl<'a, 'tcx> ItemLikeVisitor<'tcx> for VarianceTest<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { - let item_def_id = self.tcx.hir.local_def_id(item.id); + let item_def_id = self.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. diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index fde8648c0c40a..543df844cb86e 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -37,7 +37,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> { pub fn get_with_node_id(&self, id: ast::NodeId, name: String) -> Vec { get_def_from_node_id(&self.cx, id, name, &|def_ctor, name| { - let did = self.cx.tcx.hir.local_def_id(id); + let did = self.cx.tcx.hir().local_def_id(id); self.get_auto_trait_impls(did, &def_ctor, Some(name)) }) } diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index 8246c7bab27af..ed0056ed26251 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -38,7 +38,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> BlanketImplFinder <'a, 'tcx, 'rcx, 'cstore> { pub fn get_with_node_id(&self, id: ast::NodeId, name: String) -> Vec { get_def_from_node_id(&self.cx, id, name, &|def_ctor, name| { - let did = self.cx.tcx.hir.local_def_id(id); + let did = self.cx.tcx.hir().local_def_id(id); self.get_blanket_impls(did, &def_ctor, Some(name)) }) } diff --git a/src/librustdoc/clean/def_ctor.rs b/src/librustdoc/clean/def_ctor.rs index cd9f4eb42dfc6..b14c36a59e844 100644 --- a/src/librustdoc/clean/def_ctor.rs +++ b/src/librustdoc/clean/def_ctor.rs @@ -54,7 +54,7 @@ pub fn get_def_from_node_id(cx: &DocContext, callback: &F, ) -> Vec where F: Fn(& dyn Fn(DefId) -> Def, String) -> Vec { - let item = &cx.tcx.hir.expect_item(id).node; + let item = &cx.tcx.hir().expect_item(id).node; callback(&match *item { hir::ItemKind::Struct(_, _) => Def::Struct, diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 49cecd5b04bbc..217345548c8c9 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -303,8 +303,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec) { } } - let for_ = if let Some(nodeid) = tcx.hir.as_local_node_id(did) { - match tcx.hir.expect_item(nodeid).node { + let for_ = if let Some(nodeid) = tcx.hir().as_local_node_id(did) { + match tcx.hir().expect_item(nodeid).node { hir::ItemKind::Impl(.., ref t, _) => { t.clean(cx) } @@ -325,12 +325,12 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec) { } let predicates = tcx.predicates_of(did); - let (trait_items, generics) = if let Some(nodeid) = tcx.hir.as_local_node_id(did) { - match tcx.hir.expect_item(nodeid).node { + let (trait_items, generics) = if let Some(nodeid) = tcx.hir().as_local_node_id(did) { + match tcx.hir().expect_item(nodeid).node { hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => { ( item_ids.iter() - .map(|ii| tcx.hir.impl_item(ii.id).clean(cx)) + .map(|ii| tcx.hir().impl_item(ii.id).clean(cx)) .collect::>(), gen.clean(cx), ) @@ -420,8 +420,8 @@ fn build_module(cx: &DocContext, did: DefId, visited: &mut FxHashSet) -> } pub fn print_inlined_const(cx: &DocContext, did: DefId) -> String { - if let Some(node_id) = cx.tcx.hir.as_local_node_id(did) { - cx.tcx.hir.node_to_pretty_string(node_id) + if let Some(node_id) = cx.tcx.hir().as_local_node_id(did) { + cx.tcx.hir().node_to_pretty_string(node_id) } else { cx.tcx.rendered_const(did) } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 310c369a4d092..ce7de0e312854 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -282,17 +282,17 @@ impl Clean for CrateNum { None }; let primitives = if root.is_local() { - cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| { - let item = cx.tcx.hir.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::ItemKind::Mod(_) => { - as_primitive(Def::Mod(cx.tcx.hir.local_def_id(id.id))) + as_primitive(Def::Mod(cx.tcx.hir().local_def_id(id.id))) } hir::ItemKind::Use(ref path, hir::UseKind::Single) if item.vis.node.is_pub() => { as_primitive(path.def).map(|(_, prim, attrs)| { // Pretend the primitive is local. - (cx.tcx.hir.local_def_id(id.id), prim, attrs) + (cx.tcx.hir().local_def_id(id.id), prim, attrs) }) } _ => None @@ -324,16 +324,16 @@ impl Clean for CrateNum { None }; let keywords = if root.is_local() { - cx.tcx.hir.krate().module.item_ids.iter().filter_map(|&id| { - let item = cx.tcx.hir.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::ItemKind::Mod(_) => { - as_keyword(Def::Mod(cx.tcx.hir.local_def_id(id.id))) + as_keyword(Def::Mod(cx.tcx.hir().local_def_id(id.id))) } hir::ItemKind::Use(ref path, hir::UseKind::Single) if item.vis.node.is_pub() => { as_keyword(path.def).map(|(_, prim, attrs)| { - (cx.tcx.hir.local_def_id(id.id), prim, attrs) + (cx.tcx.hir().local_def_id(id.id), prim, attrs) }) } _ => None @@ -629,7 +629,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.hir.local_def_id(self.id), + def_id: cx.tcx.hir().local_def_id(self.id), inner: ModuleItem(Module { is_crate: self.is_crate, items, @@ -1215,7 +1215,7 @@ impl Lifetime { impl Clean for hir::Lifetime { fn clean(&self, cx: &DocContext) -> Lifetime { if self.id != ast::DUMMY_NODE_ID { - let hir_id = cx.tcx.hir.node_to_hir_id(self.id); + let hir_id = cx.tcx.hir().node_to_hir_id(self.id); let def = cx.tcx.named_region(hir_id); match def { Some(rl::Region::EarlyBound(_, node_id, _)) | @@ -1473,7 +1473,7 @@ impl Clean for hir::GenericParam { } hir::GenericParamKind::Type { ref default, synthetic, .. } => { (self.name.ident().name.clean(cx), GenericParamDefKind::Type { - did: cx.tcx.hir.local_def_id(self.id), + did: cx.tcx.hir().local_def_id(self.id), bounds: self.bounds.clean(cx), default: default.clean(cx), synthetic: synthetic, @@ -1684,7 +1684,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.hir.local_def_id(self.id), + def_id: cx.tcx.hir().local_def_id(self.id), inner: FunctionItem(Function { decl, generics, @@ -1733,7 +1733,7 @@ impl<'a> Clean for (&'a [hir::Ty], &'a [ast::Ident]) { impl<'a> Clean for (&'a [hir::Ty], hir::BodyId) { fn clean(&self, cx: &DocContext) -> Arguments { - let body = cx.tcx.hir.body(self.1); + let body = cx.tcx.hir().body(self.1); Arguments { values: self.0.iter().enumerate().map(|(i, ty)| { @@ -1762,7 +1762,7 @@ impl<'a, A: Copy> Clean for (&'a hir::FnDecl, A) impl<'a, 'tcx> Clean for (DefId, ty::PolyFnSig<'tcx>) { fn clean(&self, cx: &DocContext) -> FnDecl { let (did, sig) = *self; - let mut names = if cx.tcx.hir.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.fn_arg_names(did).into_iter() @@ -1857,7 +1857,7 @@ impl Clean for doctree::Trait { name: Some(self.name.clean(cx)), attrs: attrs, source: self.whence.clean(cx), - def_id: cx.tcx.hir.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), @@ -1926,10 +1926,10 @@ impl Clean for hir::TraitItem { name: Some(self.ident.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.span.clean(cx), - def_id: cx.tcx.hir.local_def_id(self.id), + def_id: cx.tcx.hir().local_def_id(self.id), visibility: None, - stability: get_stability(cx, cx.tcx.hir.local_def_id(self.id)), - deprecation: get_deprecation(cx, cx.tcx.hir.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, } } @@ -1958,10 +1958,10 @@ impl Clean for hir::ImplItem { name: Some(self.ident.name.clean(cx)), source: self.span.clean(cx), attrs: self.attrs.clean(cx), - def_id: cx.tcx.hir.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.hir.local_def_id(self.id)), - deprecation: get_deprecation(cx, cx.tcx.hir.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, } } @@ -2411,7 +2411,7 @@ impl Clean for hir::Ty { } TyKind::Slice(ref ty) => Slice(box ty.clean(cx)), TyKind::Array(ref ty, ref length) => { - let def_id = cx.tcx.hir.local_def_id(length.id); + let def_id = cx.tcx.hir().local_def_id(length.id); let param_env = cx.tcx.param_env(def_id); let substs = Substs::identity_for_item(cx.tcx, def_id); let cid = GlobalId { @@ -2426,7 +2426,7 @@ impl Clean for hir::Ty { }, TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), TyKind::Def(item_id, _) => { - let item = cx.tcx.hir.expect_item(item_id.id); + let item = cx.tcx.hir().expect_item(item_id.id); if let hir::ItemKind::Existential(ref ty) = item.node { ImplTrait(ty.bounds.clean(cx)) } else { @@ -2447,9 +2447,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.hir.as_local_node_id(def_id) { + if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) { if !cx.renderinfo.borrow().access_levels.is_exported(def_id) { - alias = Some(&cx.tcx.hir.expect_item(node_id).node); + alias = Some(&cx.tcx.hir().expect_item(node_id).node); } } }; @@ -2479,7 +2479,7 @@ impl Clean for hir::Ty { if let Some(lt) = lifetime.cloned() { if !lt.is_elided() { let lt_def_id = - cx.tcx.hir.local_def_id(param.id); + cx.tcx.hir().local_def_id(param.id); lt_substs.insert(lt_def_id, lt.clean(cx)); } } @@ -2487,7 +2487,7 @@ impl Clean for hir::Ty { } hir::GenericParamKind::Type { ref default, .. } => { let ty_param_def = - Def::TyParam(cx.tcx.hir.local_def_id(param.id)); + Def::TyParam(cx.tcx.hir().local_def_id(param.id)); let mut j = 0; let type_ = generic_args.args.iter().find_map(|arg| { match arg { @@ -2608,7 +2608,7 @@ impl<'tcx> Clean for Ty<'tcx> { BareFunction(box BareFunctionDecl { unsafety: sig.unsafety(), generic_params: Vec::new(), - decl: (cx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), sig).clean(cx), + decl: (cx.tcx.hir().local_def_id(ast::CRATE_NODE_ID), sig).clean(cx), abi: sig.abi(), }) } @@ -2760,9 +2760,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.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), + 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)), } } @@ -2834,7 +2834,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.hir.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), @@ -2854,7 +2854,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.hir.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), @@ -2901,7 +2901,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.hir.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), @@ -2928,7 +2928,7 @@ impl Clean for doctree::Variant { visibility: None, stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), - def_id: cx.tcx.hir.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), }), @@ -3205,7 +3205,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.hir.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), @@ -3229,7 +3229,7 @@ impl Clean for doctree::Existential { name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.hir.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), @@ -3280,7 +3280,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.hir.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), @@ -3305,7 +3305,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.hir.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), @@ -3405,7 +3405,7 @@ impl Clean> for doctree::Impl { name: None, attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.hir.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), @@ -3548,7 +3548,7 @@ impl Clean> for doctree::Import { name: None, attrs: self.attrs.clean(cx), source: self.whence.clean(cx), - def_id: cx.tcx.hir.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, @@ -3617,10 +3617,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.hir.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.hir.local_def_id(self.id)), - deprecation: get_deprecation(cx, cx.tcx.hir.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, } } @@ -3683,8 +3683,8 @@ fn name_from_pat(p: &hir::Pat) -> String { fn print_const(cx: &DocContext, n: &ty::Const) -> String { match n.val { ConstValue::Unevaluated(def_id, _) => { - if let Some(node_id) = cx.tcx.hir.as_local_node_id(def_id) { - print_const_expr(cx, cx.tcx.hir.body_owned_by(node_id)) + if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) { + print_const_expr(cx, cx.tcx.hir().body_owned_by(node_id)) } else { inline::print_inlined_const(cx, def_id) } @@ -3703,7 +3703,7 @@ fn print_const(cx: &DocContext, n: &ty::Const) -> String { } fn print_const_expr(cx: &DocContext, body: hir::BodyId) -> String { - cx.tcx.hir.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 @@ -3829,7 +3829,7 @@ impl Clean for doctree::ProcMacro { visibility: Some(Public), stability: self.stab.clean(cx), deprecation: self.depr.clean(cx), - def_id: cx.tcx.hir.local_def_id(self.id), + def_id: cx.tcx.hir().local_def_id(self.id), inner: ProcMacroItem(ProcMacro { kind: self.kind, helpers: self.helpers.clean(cx), @@ -3943,7 +3943,7 @@ where // Start of code copied from rust-clippy pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option { - let krate = tcx.hir.krate(); + let krate = tcx.hir().krate(); let mut items = krate.module.item_ids.clone(); let mut path_it = path.iter().peekable(); @@ -3951,10 +3951,10 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option { let segment = path_it.next()?; for item_id in mem::replace(&mut items, HirVec::new()).iter() { - let item = tcx.hir.expect_item(item_id.id); + let item = tcx.hir().expect_item(item_id.id); if item.name == *segment { if path_it.peek().is_none() { - return Some(tcx.hir.local_def_id(item_id.id)) + return Some(tcx.hir().local_def_id(item_id.id)) } items = match &item.node { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index aac0f9f94e329..047d35579444f 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -121,7 +121,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> DocContext<'a, 'tcx, 'rcx, 'cstore> { let start_def_id = { let next_id = if crate_num == LOCAL_CRATE { self.tcx - .hir + .hir() .definitions() .def_path_table() .next_id(DefIndexAddressSpace::Low) @@ -168,7 +168,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> DocContext<'a, 'tcx, 'rcx, 'cstore> { if self.all_fake_def_ids.borrow().contains(&def_id) { None } else { - self.tcx.hir.as_local_node_id(def_id) + self.tcx.hir().as_local_node_id(def_id) } } @@ -515,7 +515,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt // to the map from defid -> nodeid let access_levels = AccessLevels { map: access_levels.map.iter() - .map(|(&k, &v)| (tcx.hir.local_def_id(k), v)) + .map(|(&k, &v)| (tcx.hir().local_def_id(k), v)) .collect() }; @@ -545,11 +545,11 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt generated_synthetics: Default::default(), all_traits: tcx.all_traits(LOCAL_CRATE).to_vec(), }; - debug!("crate: {:?}", tcx.hir.krate()); + debug!("crate: {:?}", tcx.hir().krate()); let mut krate = { let mut v = RustdocVisitor::new(&ctxt); - v.visit(tcx.hir.krate()); + v.visit(tcx.hir().krate()); v.clean(&ctxt) }; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 7183cfe571192..cbbcf92c6aa9e 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -217,7 +217,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> LinkCollector<'a, 'tcx, 'rcx, 'cstore> { impl<'a, 'tcx, 'rcx, 'cstore> DocFolder for LinkCollector<'a, 'tcx, 'rcx, 'cstore> { fn fold_item(&mut self, mut item: Item) -> Option { let item_node_id = if item.is_mod() { - if let Some(id) = self.cx.tcx.hir.as_local_node_id(item.def_id) { + if let Some(id) = self.cx.tcx.hir().as_local_node_id(item.def_id) { Some(id) } else { debug!("attempting to fold on a non-local item: {:?}", item); @@ -231,7 +231,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> DocFolder for LinkCollector<'a, 'tcx, 'rcx, 'cstor let parent_node = self.cx.as_local_node_id(item.def_id).and_then(|node_id| { // FIXME: this fails hard for impls in non-module scope, but is necessary for the // current resolve() implementation - match self.cx.tcx.hir.get_module_parent_node(node_id) { + match self.cx.tcx.hir().get_module_parent_node(node_id) { id if id != node_id => Some(id), _ => None, } @@ -253,7 +253,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> DocFolder for LinkCollector<'a, 'tcx, 'rcx, 'cstor match parent_node.or(self.mod_ids.last().cloned()) { Some(parent) if parent != NodeId::from_u32(0) => { //FIXME: can we pull the parent module's name from elsewhere? - Some(self.cx.tcx.hir.name(parent).to_string()) + Some(self.cx.tcx.hir().name(parent).to_string()) } _ => None, } diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index 70e1a9b0ebc9d..8847fb8128eec 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -127,8 +127,8 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext) -> Crate { // `tcx.crates()` doesn't include the local crate, and `tcx.all_trait_implementations` // doesn't work with it anyway, so pull them from the HIR map instead for &trait_did in cx.all_traits.iter() { - for &impl_node in cx.tcx.hir.trait_impls(trait_did) { - let impl_did = cx.tcx.hir.local_def_id(impl_node); + for &impl_node in cx.tcx.hir().trait_impls(trait_did) { + let impl_did = cx.tcx.hir().local_def_id(impl_node); inline::build_impl(cx, impl_did, &mut new_items); } } @@ -165,7 +165,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> DocFolder for SyntheticImplCollector<'a, 'tcx, 'rc fn fold_item(&mut self, i: Item) -> Option { if i.is_struct() || i.is_enum() || i.is_union() { if let (Some(node_id), Some(name)) = - (self.cx.tcx.hir.as_local_node_id(i.def_id), i.name.clone()) + (self.cx.tcx.hir().as_local_node_id(i.def_id), i.name.clone()) { self.impls.extend(get_auto_traits_with_node_id(self.cx, node_id, name.clone())); self.impls.extend(get_blanket_impls_with_node_id(self.cx, node_id, name)); diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 31adb2e0369c9..fc7e8d72d6997 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -79,12 +79,12 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { } fn stability(&self, id: ast::NodeId) -> Option { - self.cx.tcx.hir.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.hir.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)) } @@ -257,7 +257,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { let orig_inside_public_path = self.inside_public_path; self.inside_public_path &= vis.node.is_pub(); for i in &m.item_ids { - let item = self.cx.tcx.hir.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; @@ -282,9 +282,9 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { please_inline: bool) -> bool { fn inherits_doc_hidden(cx: &core::DocContext, mut node: ast::NodeId) -> bool { - while let Some(id) = cx.tcx.hir.get_enclosing_scope(node) { + while let Some(id) = cx.tcx.hir().get_enclosing_scope(node) { node = id; - if cx.tcx.hir.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 { @@ -302,7 +302,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { } let def_did = def.def_id(); - let use_attrs = tcx.hir.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"); @@ -335,7 +335,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { return false } - let def_node_id = match tcx.hir.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 }; @@ -349,11 +349,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { if !self.view_item_stack.insert(def_node_id) { return false } - let ret = match tcx.hir.get(def_node_id) { + let ret = match tcx.hir().get(def_node_id) { Node::Item(&hir::Item { node: hir::ItemKind::Mod(ref m), .. }) if glob => { let prev = mem::replace(&mut self.inlining, true); for i in &m.item_ids { - let i = self.cx.tcx.hir.expect_item(i.id); + let i = self.cx.tcx.hir().expect_item(i.id); self.visit_item(i, None, om); } self.inlining = prev; @@ -368,7 +368,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { Node::ForeignItem(it) if !glob => { // generate a fresh `extern {}` block if we want to inline a foreign item. om.foreigns.push(hir::ForeignMod { - abi: tcx.hir.get_foreign_abi(it.id), + abi: tcx.hir().get_foreign_abi(it.id), items: vec![hir::ForeignItem { name: renamed.unwrap_or(it.name), .. it.clone() @@ -392,7 +392,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { let name = renamed.unwrap_or(item.name); if item.vis.node.is_pub() { - let def_id = self.cx.tcx.hir.local_def_id(item.id); + let def_id = self.cx.tcx.hir().local_def_id(item.id); self.store_path(def_id); } @@ -412,7 +412,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { _ if self.inlining && !item.vis.node.is_pub() => {} hir::ItemKind::GlobalAsm(..) => {} hir::ItemKind::ExternCrate(orig_name) => { - let def_id = self.cx.tcx.hir.local_def_id(item.id); + let def_id = self.cx.tcx.hir().local_def_id(item.id); om.extern_crates.push(ExternCrate { cnum: self.cx.tcx.extern_mod_stmt_cnum(def_id) .unwrap_or(LOCAL_CRATE), @@ -540,7 +540,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { }, hir::ItemKind::Trait(is_auto, unsafety, ref gen, ref b, ref item_ids) => { let items = item_ids.iter() - .map(|ti| self.cx.tcx.hir.trait_item(ti.id).clone()) + .map(|ti| self.cx.tcx.hir().trait_item(ti.id).clone()) .collect(); let t = Trait { is_auto, @@ -573,7 +573,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { // them up regardless of where they're located. if !self.inlining && tr.is_none() { let items = item_ids.iter() - .map(|ii| self.cx.tcx.hir.impl_item(ii.id).clone()) + .map(|ii| self.cx.tcx.hir().impl_item(ii.id).clone()) .collect(); let i = Impl { unsafety, @@ -608,7 +608,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { let matchers = tts.chunks(4).map(|arm| arm[0].span()).collect(); Macro { - def_id: self.cx.tcx.hir.local_def_id(def.id), + def_id: self.cx.tcx.hir().local_def_id(def.id), attrs: def.attrs.clone(), name: renamed.unwrap_or(def.name), whence: def.span, diff --git a/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs index f4d3f2c94caf1..7a7dd963e0d23 100644 --- a/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs @@ -56,9 +56,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass { span: source_map::Span, id: ast::NodeId) { - let item = match cx.tcx.hir.get(id) { + let item = match cx.tcx.hir().get(id) { Node::Item(item) => item, - _ => cx.tcx.hir.expect_item(cx.tcx.hir.get_parent(id)), + _ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent(id)), }; if !attr::contains_name(&item.attrs, "whitelisted_attr") {