Skip to content

Commit ae72c91

Browse files
committed
make blocks::Code work with HirId
1 parent fe044a8 commit ae72c91

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/librustc/hir/map/blocks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::hir as ast;
1515
use crate::hir::map;
1616
use crate::hir::{Expr, FnDecl, Node};
1717
use crate::hir::intravisit::FnKind;
18-
use syntax::ast::{Attribute, Ident, NodeId};
18+
use syntax::ast::{Attribute, Ident};
1919
use syntax_pos::Span;
2020

2121
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
@@ -83,11 +83,11 @@ impl<'a> Code<'a> {
8383
}
8484

8585
/// Attempts to construct a Code from presumed FnLike or Expr node input.
86-
pub fn from_node(map: &map::Map<'a>, id: NodeId) -> Option<Code<'a>> {
87-
match map.get(id) {
86+
pub fn from_node(map: &map::Map<'a>, id: ast::HirId) -> Option<Code<'a>> {
87+
match map.get_by_hir_id(id) {
8888
map::Node::Block(_) => {
8989
// Use the parent, hopefully an expression node.
90-
Code::from_node(map, map.get_parent_node(id))
90+
Code::from_node(map, map.get_parent_node_by_hir_id(id))
9191
}
9292
map::Node::Expr(expr) => Some(Code::Expr(expr)),
9393
node => FnLikeNode::from_node(node).map(Code::FnLike)

src/librustc_driver/pretty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,8 @@ fn print_with_analysis<'tcx>(
909909
tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid))
910910
});
911911

912-
match blocks::Code::from_node(&tcx.hir(), nodeid) {
912+
let hir_id = tcx.hir().node_to_hir_id(nodeid);
913+
match blocks::Code::from_node(&tcx.hir(), hir_id) {
913914
Some(code) => {
914915
let variants = gather_flowgraph_variants(tcx.sess);
915916

0 commit comments

Comments
 (0)