Skip to content

Commit 90de9ed

Browse files
committed
HIR: remove the NodeId find
1 parent d08bd72 commit 90de9ed

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/librustc/hir/map/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,6 @@ impl<'hir> Map<'hir> {
595595
}
596596

597597
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
598-
pub fn find(&self, id: NodeId) -> Option<Node<'hir>> {
599-
let hir_id = self.node_to_hir_id(id);
600-
self.find_by_hir_id(hir_id)
601-
}
602-
603-
// FIXME(@ljedrz): replace the `NodeId` variant.
604598
pub fn find_by_hir_id(&self, hir_id: HirId) -> Option<Node<'hir>> {
605599
let result = self.find_entry(hir_id).and_then(|entry| {
606600
if let Node::Crate = entry.node {

src/librustc_driver/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -907,11 +907,11 @@ fn print_with_analysis<'tcx>(
907907
let nodeid =
908908
nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \
909909
suffix (b::c::d)");
910-
let node = tcx.hir().find(nodeid).unwrap_or_else(|| {
910+
let hir_id = tcx.hir().node_to_hir_id(nodeid);
911+
let node = tcx.hir().find_by_hir_id(hir_id).unwrap_or_else(|| {
911912
tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid))
912913
});
913914

914-
let hir_id = tcx.hir().node_to_hir_id(nodeid);
915915
match blocks::Code::from_node(&tcx.hir(), hir_id) {
916916
Some(code) => {
917917
let variants = gather_flowgraph_variants(tcx.sess);

src/librustc_mir/build/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ where
552552
.into_iter()
553553
.flatten()
554554
.map(|(&var_hir_id, &upvar_id)| {
555-
let var_node_id = tcx_hir.hir_to_node_id(var_hir_id);
556555
let capture = hir_tables.upvar_capture(upvar_id);
557556
let by_ref = match capture {
558557
ty::UpvarCapture::ByValue => false,
@@ -563,7 +562,7 @@ where
563562
by_ref,
564563
};
565564
let mut mutability = Mutability::Not;
566-
if let Some(Node::Binding(pat)) = tcx_hir.find(var_node_id) {
565+
if let Some(Node::Binding(pat)) = tcx_hir.find_by_hir_id(var_hir_id) {
567566
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
568567
debuginfo.debug_name = ident.name;
569568
if let Some(&bm) = hir.tables.pat_binding_modes().get(pat.hir_id) {

src/librustc_save_analysis/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,10 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
410410
let mut decl_id = None;
411411
let mut docs = String::new();
412412
let mut attrs = vec![];
413-
if let Some(Node::ImplItem(item)) = self.tcx.hir().find(id) {
413+
let hir_id = self.tcx.hir().node_to_hir_id(id);
414+
if let Some(Node::ImplItem(item)) =
415+
self.tcx.hir().find_by_hir_id(hir_id)
416+
{
414417
docs = self.docs_for_attrs(&item.attrs);
415418
attrs = item.attrs.to_vec();
416419
}
@@ -451,8 +454,9 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
451454
Some(def_id) => {
452455
let mut docs = String::new();
453456
let mut attrs = vec![];
457+
let hir_id = self.tcx.hir().node_to_hir_id(id);
454458

455-
if let Some(Node::TraitItem(item)) = self.tcx.hir().find(id) {
459+
if let Some(Node::TraitItem(item)) = self.tcx.hir().find_by_hir_id(hir_id) {
456460
docs = self.docs_for_attrs(&item.attrs);
457461
attrs = item.attrs.to_vec();
458462
}
@@ -521,7 +525,8 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
521525
}
522526
match expr.node {
523527
ast::ExprKind::Field(ref sub_ex, ident) => {
524-
let hir_node = match self.tcx.hir().find(sub_ex.id) {
528+
let sub_ex_hir_id = self.tcx.hir().node_to_hir_id(sub_ex.id);
529+
let hir_node = match self.tcx.hir().find_by_hir_id(sub_ex_hir_id) {
525530
Some(Node::Expr(expr)) => expr,
526531
_ => {
527532
debug!(

0 commit comments

Comments
 (0)