]> git.lizzy.rs Git - rust.git/commitdiff
make blocks::Code work with HirId
authorljedrz <ljedrz@gmail.com>
Thu, 20 Jun 2019 08:15:07 +0000 (10:15 +0200)
committerljedrz <ljedrz@gmail.com>
Thu, 20 Jun 2019 10:47:26 +0000 (12:47 +0200)
src/librustc/hir/map/blocks.rs
src/librustc_driver/pretty.rs

index f50037a746d9774bfc03953c977c42411bc910c6..dd11bd15db8455d708a1199cd3b591a9b75ab48a 100644 (file)
@@ -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)
index eb89b5c1e63709e14483fb0753393ed407c05136..13f179f037ff3afea202a1ce8fdf69c9aa7d2464 100644 (file)
@@ -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);