make blocks::Code work with HirId
This commit is contained in:
parent
fe044a8bc2
commit
ae72c91247
@ -15,7 +15,7 @@
|
||||
use crate::hir::map;
|
||||
use crate::hir::{Expr, FnDecl, Node};
|
||||
use crate::hir::intravisit::FnKind;
|
||||
use syntax::ast::{Attribute, Ident, NodeId};
|
||||
use syntax::ast::{Attribute, Ident};
|
||||
use syntax_pos::Span;
|
||||
|
||||
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
|
||||
@ -83,11 +83,11 @@ pub fn id(&self) -> ast::HirId {
|
||||
}
|
||||
|
||||
/// Attempts to construct a Code from presumed FnLike or Expr node input.
|
||||
pub fn from_node(map: &map::Map<'a>, id: NodeId) -> Option<Code<'a>> {
|
||||
match map.get(id) {
|
||||
pub fn from_node(map: &map::Map<'a>, id: ast::HirId) -> Option<Code<'a>> {
|
||||
match map.get_by_hir_id(id) {
|
||||
map::Node::Block(_) => {
|
||||
// Use the parent, hopefully an expression node.
|
||||
Code::from_node(map, map.get_parent_node(id))
|
||||
Code::from_node(map, map.get_parent_node_by_hir_id(id))
|
||||
}
|
||||
map::Node::Expr(expr) => Some(Code::Expr(expr)),
|
||||
node => FnLikeNode::from_node(node).map(Code::FnLike)
|
||||
|
@ -909,7 +909,8 @@ fn print_with_analysis<'tcx>(
|
||||
tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid))
|
||||
});
|
||||
|
||||
match blocks::Code::from_node(&tcx.hir(), nodeid) {
|
||||
let hir_id = tcx.hir().node_to_hir_id(nodeid);
|
||||
match blocks::Code::from_node(&tcx.hir(), hir_id) {
|
||||
Some(code) => {
|
||||
let variants = gather_flowgraph_variants(tcx.sess);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user