From 171c2aeb25539c5bb1a1a3b231c8a17c6e6b05cc Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 24 Nov 2017 13:44:36 +0100 Subject: [PATCH] Expanded HIR `--unpretty hir,identified` to include HIR local id. Having the HIR local id is useful for cases like understanding the ReScope identifiers, which are now derived from the HIR local id, and thus one can map an ReScope back to the HIR node, once one knows what those local ids are. --- src/librustc_driver/pretty.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index d930739c9f0..7fdcbfc4d29 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -423,7 +423,8 @@ impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> { pprust_hir::NodeName(_) => Ok(()), pprust_hir::NodeItem(item) => { s.s.space()?; - s.synth_comment(item.id.to_string()) + s.synth_comment(format!("node_id: {} hir local_id: {}", + item.id, item.hir_id.local_id.0)) } pprust_hir::NodeSubItem(id) => { s.s.space()?; @@ -431,16 +432,19 @@ impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> { } pprust_hir::NodeBlock(blk) => { s.s.space()?; - s.synth_comment(format!("block {}", blk.id)) + s.synth_comment(format!("block node_id: {} hir local_id: {}", + blk.id, blk.hir_id.local_id.0)) } pprust_hir::NodeExpr(expr) => { s.s.space()?; - s.synth_comment(expr.id.to_string())?; + s.synth_comment(format!("node_id: {} hir local_id: {}", + expr.id, expr.hir_id.local_id.0))?; s.pclose() } pprust_hir::NodePat(pat) => { s.s.space()?; - s.synth_comment(format!("pat {}", pat.id)) + s.synth_comment(format!("pat node_id: {} hir local_id: {}", + pat.id, pat.hir_id.local_id.0)) } } }