Skip to content

Commit 0a511cc

Browse files
committed
revert the NodeId to HirId parameter change to get_path_res
1 parent 73cb9ab commit 0a511cc

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

src/librustc_save_analysis/dump_visitor.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
233233
}
234234

235235
fn lookup_def_id(&self, ref_id: NodeId) -> Option<DefId> {
236-
let hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(ref_id);
237-
match self.save_ctxt.get_path_res(hir_id) {
236+
match self.save_ctxt.get_path_res(ref_id) {
238237
Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => None,
239238
def => Some(def.def_id()),
240239
}
@@ -887,8 +886,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
887886
return;
888887
}
889888
};
890-
let hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(p.id);
891-
let variant = adt.variant_of_res(self.save_ctxt.get_path_res(hir_id));
889+
let variant = adt.variant_of_res(self.save_ctxt.get_path_res(p.id));
892890

893891
for &Spanned { node: ref field, .. } in fields {
894892
if let Some(index) = self.tcx.find_field_index(field.ident, variant) {
@@ -918,8 +916,7 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
918916

919917
// process collected paths
920918
for (id, ident, immut) in collector.collected_idents {
921-
let hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(id);
922-
match self.save_ctxt.get_path_res(hir_id) {
919+
match self.save_ctxt.get_path_res(id) {
923920
Res::Local(hir_id) => {
924921
let mut value = if immut == ast::Mutability::Immutable {
925922
self.span.snippet(ident.span)
@@ -1543,7 +1540,8 @@ impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, '
15431540
return;
15441541
}
15451542
};
1546-
let res = self.save_ctxt.get_path_res(hir_expr.hir_id);
1543+
let node_id = self.save_ctxt.tcx.hir().hir_to_node_id(hir_expr.hir_id);
1544+
let res = self.save_ctxt.get_path_res(node_id);
15471545
self.process_struct_lit(ex, path, fields, adt.variant_of_res(res), base)
15481546
}
15491547
ast::ExprKind::MethodCall(ref seg, ref args) => self.process_method_call(ex, seg, args),

src/librustc_save_analysis/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
606606
}
607607
}
608608

609-
pub fn get_path_res(&self, hir_id: hir::HirId) -> Res {
609+
pub fn get_path_res(&self, id: NodeId) -> Res {
610+
let hir_id = self.tcx.hir().node_to_hir_id(id);
610611
match self.tcx.hir().get(hir_id) {
611612
Node::TraitRef(tr) => tr.path.res,
612613

@@ -620,7 +621,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
620621
Node::PathSegment(seg) => {
621622
match seg.res {
622623
Some(res) if res != Res::Err => res,
623-
_ => self.get_path_res(self.tcx.hir().get_parent_node_by_hir_id(hir_id)),
624+
_ => self.get_path_res(self.tcx.hir().get_parent_node(id)),
624625
}
625626
}
626627

@@ -695,8 +696,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
695696
return None;
696697
}
697698

698-
let hir_id = self.tcx.hir().node_to_hir_id(id);
699-
let res = self.get_path_res(hir_id);
699+
let res = self.get_path_res(id);
700700
let span = path_seg.ident.span;
701701
filter!(self.span_utils, span);
702702
let span = self.span_from_span(span);
@@ -868,8 +868,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
868868
}
869869

870870
fn lookup_ref_id(&self, ref_id: NodeId) -> Option<DefId> {
871-
let hir_id = self.tcx.hir().node_to_hir_id(ref_id);
872-
match self.get_path_res(hir_id) {
871+
match self.get_path_res(ref_id) {
873872
Res::PrimTy(_) | Res::SelfTy(..) | Res::Err => None,
874873
def => Some(def.def_id()),
875874
}

src/librustc_save_analysis/sig.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ impl Sig for ast::Ty {
273273
};
274274

275275
let name = pprust::path_segment_to_string(path.segments.last().ok_or("Bad path")?);
276-
let hir_id = id.map(|node_id| scx.tcx.hir().node_to_hir_id(node_id));
277-
let res = scx.get_path_res(hir_id.ok_or("Missing id for Path")?);
276+
let res = scx.get_path_res(id.ok_or("Missing id for Path")?);
278277
let id = id_from_def_id(res.def_id());
279278
if path.segments.len() - qself.position == 1 {
280279
let start = offset + prefix.len();
@@ -577,8 +576,7 @@ impl Sig for ast::Item {
577576

578577
impl Sig for ast::Path {
579578
fn make(&self, offset: usize, id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
580-
let hir_id = id.map(|node_id| scx.tcx.hir().node_to_hir_id(node_id));
581-
let res = scx.get_path_res(hir_id.ok_or("Missing id for Path")?);
579+
let res = scx.get_path_res(id.ok_or("Missing id for Path")?);
582580

583581
let (name, start, end) = match res {
584582
Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => {

0 commit comments

Comments
 (0)