From 75651e5f3b0f53123e790328e3251b3b291f305d Mon Sep 17 00:00:00 2001 From: Ethan Brierley Date: Tue, 10 Oct 2023 17:13:05 +0100 Subject: [PATCH] recommend `unpretty=hir` alongside `unpretty=hir-tree` Previously at no point in the guide did we recommend `unpretty=hir`, only `unpretty=hir-tree`. I'm not sure if `unpretty=hir-tree` existed when this chapter was written. related: https://github.com/rust-lang/rustc-dev-guide/issues/1159 I noticed that there's some duplicate information between here and the parent chapter https://rustc-dev-guide.rust-lang.org/hir.html I may try to merge https://rustc-dev-guide.rust-lang.org/hir-debugging.html into its parent in another PR. --- src/hir-debugging.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hir-debugging.md b/src/hir-debugging.md index c25a558a0..5a0bda208 100644 --- a/src/hir-debugging.md +++ b/src/hir-debugging.md @@ -1,6 +1,13 @@ # HIR Debugging -The `-Z unpretty=hir-tree` flag will dump out the HIR. +Use the `-Z unpretty=hir` flag to produce a human-readable representation of the HIR. +For cargo projects this can be done with `cargo rustc -- -Z unpretty=hir`. +This output is useful when you need to see at a glance how your code was desugared and transformed +during AST lowering. + +For a full `Debug` dump of the data in the HIR, use the `-Z unpretty=hir-tree` flag. +This may be useful when you need to see the full structure of the HIR from the perspective of the +compiler. If you are trying to correlate `NodeId`s or `DefId`s with source code, the `-Z unpretty=expanded,identified` flag may be useful.