]> git.lizzy.rs Git - rust.git/commitdiff
revert the NodeId to HirId parameter change to get_path_res
authorljedrz <ljedrz@gmail.com>
Fri, 21 Jun 2019 06:57:34 +0000 (08:57 +0200)
committerljedrz <ljedrz@gmail.com>
Fri, 21 Jun 2019 06:57:34 +0000 (08:57 +0200)
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/sig.rs

index 4719965da8d66975de92c7d193f8ba75b8a18275..f67241ef23efcbf6d6ca4d5246c62869c0d52d06 100644 (file)
@@ -233,8 +233,7 @@ fn write_sub_paths_truncated(&mut self, path: &ast::Path) {
     }
 
     fn lookup_def_id(&self, ref_id: NodeId) -> Option<DefId> {
-        let hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(ref_id);
-        match self.save_ctxt.get_path_res(hir_id) {
+        match self.save_ctxt.get_path_res(ref_id) {
             Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => None,
             def => Some(def.def_id()),
         }
@@ -887,8 +886,7 @@ fn process_pat(&mut self, p: &'l ast::Pat) {
                         return;
                     }
                 };
-                let hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(p.id);
-                let variant = adt.variant_of_res(self.save_ctxt.get_path_res(hir_id));
+                let variant = adt.variant_of_res(self.save_ctxt.get_path_res(p.id));
 
                 for &Spanned { node: ref field, .. } in fields {
                     if let Some(index) = self.tcx.find_field_index(field.ident, variant) {
@@ -918,8 +916,7 @@ fn process_var_decl_multi(&mut self, pats: &'l [P<ast::Pat>]) {
 
         // process collected paths
         for (id, ident, immut) in collector.collected_idents {
-            let hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(id);
-            match self.save_ctxt.get_path_res(hir_id) {
+            match self.save_ctxt.get_path_res(id) {
                 Res::Local(hir_id) => {
                     let mut value = if immut == ast::Mutability::Immutable {
                         self.span.snippet(ident.span)
@@ -1543,7 +1540,8 @@ fn visit_expr(&mut self, ex: &'l ast::Expr) {
                         return;
                     }
                 };
-                let res = self.save_ctxt.get_path_res(hir_expr.hir_id);
+                let node_id = self.save_ctxt.tcx.hir().hir_to_node_id(hir_expr.hir_id);
+                let res = self.save_ctxt.get_path_res(node_id);
                 self.process_struct_lit(ex, path, fields, adt.variant_of_res(res), base)
             }
             ast::ExprKind::MethodCall(ref seg, ref args) => self.process_method_call(ex, seg, args),
index 27e312f65ce24d02255ab9d77680893703ba7868..23fe150c6ff6515f2431cce37dc89c01e99a04b3 100644 (file)
@@ -606,7 +606,8 @@ pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
         }
     }
 
-    pub fn get_path_res(&self, hir_id: hir::HirId) -> Res {
+    pub fn get_path_res(&self, id: NodeId) -> Res {
+        let hir_id = self.tcx.hir().node_to_hir_id(id);
         match self.tcx.hir().get(hir_id) {
             Node::TraitRef(tr) => tr.path.res,
 
@@ -620,7 +621,7 @@ pub fn get_path_res(&self, hir_id: hir::HirId) -> Res {
             Node::PathSegment(seg) => {
                 match seg.res {
                     Some(res) if res != Res::Err => res,
-                    _ => self.get_path_res(self.tcx.hir().get_parent_node_by_hir_id(hir_id)),
+                    _ => self.get_path_res(self.tcx.hir().get_parent_node(id)),
                 }
             }
 
@@ -695,8 +696,7 @@ fn fn_type(seg: &ast::PathSegment) -> bool {
             return None;
         }
 
-        let hir_id = self.tcx.hir().node_to_hir_id(id);
-        let res = self.get_path_res(hir_id);
+        let res = self.get_path_res(id);
         let span = path_seg.ident.span;
         filter!(self.span_utils, span);
         let span = self.span_from_span(span);
@@ -868,8 +868,7 @@ pub fn get_macro_use_data(&self, span: Span) -> Option<MacroRef> {
     }
 
     fn lookup_ref_id(&self, ref_id: NodeId) -> Option<DefId> {
-        let hir_id = self.tcx.hir().node_to_hir_id(ref_id);
-        match self.get_path_res(hir_id) {
+        match self.get_path_res(ref_id) {
             Res::PrimTy(_) | Res::SelfTy(..) | Res::Err => None,
             def => Some(def.def_id()),
         }
index 7af18a8676abb9c7eef8e5905e01b47cb6c74bc9..db8b5eacd94d9321f2f7e7b9b1175f927590e693 100644 (file)
@@ -273,8 +273,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_,
                 };
 
                 let name = pprust::path_segment_to_string(path.segments.last().ok_or("Bad path")?);
-                let hir_id = id.map(|node_id| scx.tcx.hir().node_to_hir_id(node_id));
-                let res = scx.get_path_res(hir_id.ok_or("Missing id for Path")?);
+                let res = scx.get_path_res(id.ok_or("Missing id for Path")?);
                 let id = id_from_def_id(res.def_id());
                 if path.segments.len() - qself.position == 1 {
                     let start = offset + prefix.len();
@@ -577,8 +576,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_,
 
 impl Sig for ast::Path {
     fn make(&self, offset: usize, id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
-        let hir_id = id.map(|node_id| scx.tcx.hir().node_to_hir_id(node_id));
-        let res = scx.get_path_res(hir_id.ok_or("Missing id for Path")?);
+        let res = scx.get_path_res(id.ok_or("Missing id for Path")?);
 
         let (name, start, end) = match res {
             Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => {