about summary refs log tree commit diff
path: root/src/librustc_save_analysis
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-12-04 13:45:36 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-12-06 17:24:36 +0100
commita70babed03d58d042024e41f0a46f7e33e34d0d1 (patch)
tree78f557eea7a424eba2c1fa75da9a6845c2607bd8 /src/librustc_save_analysis
parent367e783e6f66a4dba32decdc68a262953d2f3f1b (diff)
downloadrust-a70babed03d58d042024e41f0a46f7e33e34d0d1.tar.gz
rust-a70babed03d58d042024e41f0a46f7e33e34d0d1.zip
Use a function to access the Hir map to be able to turn it into a query later
Diffstat (limited to 'src/librustc_save_analysis')
-rw-r--r--src/librustc_save_analysis/dump_visitor.rs20
-rw-r--r--src/librustc_save_analysis/lib.rs26
2 files changed, 23 insertions, 23 deletions
diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs
index 15c8861eb3f..b1c1c9635bf 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 {
                         "<mutable>".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 82c4795a29d..85ffd3eb1c2 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<Data> {
-        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*