Skip to content

Commit 171c2ae

Browse files
committed
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.
1 parent 93c4ffe commit 171c2ae

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/librustc_driver/pretty.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,24 +423,28 @@ impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
423423
pprust_hir::NodeName(_) => Ok(()),
424424
pprust_hir::NodeItem(item) => {
425425
s.s.space()?;
426-
s.synth_comment(item.id.to_string())
426+
s.synth_comment(format!("node_id: {} hir local_id: {}",
427+
item.id, item.hir_id.local_id.0))
427428
}
428429
pprust_hir::NodeSubItem(id) => {
429430
s.s.space()?;
430431
s.synth_comment(id.to_string())
431432
}
432433
pprust_hir::NodeBlock(blk) => {
433434
s.s.space()?;
434-
s.synth_comment(format!("block {}", blk.id))
435+
s.synth_comment(format!("block node_id: {} hir local_id: {}",
436+
blk.id, blk.hir_id.local_id.0))
435437
}
436438
pprust_hir::NodeExpr(expr) => {
437439
s.s.space()?;
438-
s.synth_comment(expr.id.to_string())?;
440+
s.synth_comment(format!("node_id: {} hir local_id: {}",
441+
expr.id, expr.hir_id.local_id.0))?;
439442
s.pclose()
440443
}
441444
pprust_hir::NodePat(pat) => {
442445
s.s.space()?;
443-
s.synth_comment(format!("pat {}", pat.id))
446+
s.synth_comment(format!("pat node_id: {} hir local_id: {}",
447+
pat.id, pat.hir_id.local_id.0))
444448
}
445449
}
446450
}

0 commit comments

Comments
 (0)