about summary refs log tree commit diff
path: root/compiler/rustc_driver
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-01-29 20:03:37 +0100
committerGitHub <noreply@github.com>2023-01-29 20:03:37 +0100
commit45446824e3226c9270a8eb6e3554edbca5187fd2 (patch)
tree55839c7a93c0e92fd53b0ca8413fe5501bda0dbf /compiler/rustc_driver
parent782da867c801441212a00f20bf75bc312c815460 (diff)
parent92f2d27d1b5ec6b81299edf0e55bb1f0fc45ae9b (diff)
downloadrust-45446824e3226c9270a8eb6e3554edbca5187fd2.tar.gz
rust-45446824e3226c9270a8eb6e3554edbca5187fd2.zip
Rollup merge of #107006 - b-naber:thir-tree, r=jackh726
Output tree representation on thir-tree

The current output of `-Zunpretty=thir-tree` is really cumbersome to work with, using an actual tree representation should make it easier to see what the thir looks like.
Diffstat (limited to 'compiler/rustc_driver')
-rw-r--r--compiler/rustc_driver/src/pretty.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_driver/src/pretty.rs b/compiler/rustc_driver/src/pretty.rs
index 022051e008e..446c6832cb7 100644
--- a/compiler/rustc_driver/src/pretty.rs
+++ b/compiler/rustc_driver/src/pretty.rs
@@ -498,6 +498,21 @@ fn print_with_analysis(tcx: TyCtxt<'_>, ppm: PpMode) -> Result<(), ErrorGuarante
             out
         }
 
+        ThirFlat => {
+            let mut out = String::new();
+            abort_on_err(rustc_hir_analysis::check_crate(tcx), tcx.sess);
+            debug!("pretty printing THIR flat");
+            for did in tcx.hir().body_owners() {
+                let _ = writeln!(
+                    out,
+                    "{:?}:\n{}\n",
+                    did,
+                    tcx.thir_flat(ty::WithOptConstParam::unknown(did))
+                );
+            }
+            out
+        }
+
         _ => unreachable!(),
     };