diff options
| author | bors <bors@rust-lang.org> | 2021-07-28 09:01:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-28 09:01:11 +0000 |
| commit | eba3228b2a9875d268ff3990903d04e19f6cdb0c (patch) | |
| tree | dff9e4c1c59e7d7dde4e79bd203eb34d83807f1c /compiler/rustc_mir_build/src | |
| parent | aea2e446f09b923d513013743b37b43fca7282dc (diff) | |
| parent | 51df26eb5637ddd0012929fb21c3e51385434dd5 (diff) | |
| download | rust-eba3228b2a9875d268ff3990903d04e19f6cdb0c.tar.gz rust-eba3228b2a9875d268ff3990903d04e19f6cdb0c.zip | |
Auto merge of #86251 - Smittyvb:thir-tree-again, r=oli-obk
Support -Z unpretty=thir-tree again Currently `-Z unpretty=thir-tree` is broken after some THIR refactorings. This re-implements it, making it easier to debug THIR-related issues. We have to do analyzes before getting the THIR, since trying to create THIR from invalid HIR can ICE. But doing those analyzes requires the THIR to be built and stolen. We work around this by creating a separate query to construct the THIR tree string representation. Closes https://github.com/rust-lang/project-thir-unsafeck/issues/8, fixes #85552.
Diffstat (limited to 'compiler/rustc_mir_build/src')
| -rw-r--r-- | compiler/rustc_mir_build/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/cx/mod.rs | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index d2992f0bf18..d0dd5116b75 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -30,4 +30,5 @@ pub fn provide(providers: &mut Providers) { providers.thir_check_unsafety = check_unsafety::thir_check_unsafety; providers.thir_check_unsafety_for_const_arg = check_unsafety::thir_check_unsafety_for_const_arg; providers.thir_body = thir::cx::thir_body; + providers.thir_tree = thir::cx::thir_tree; } diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index 604e544286a..5059dd939d9 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -30,6 +30,13 @@ crate fn thir_body<'tcx>( (tcx.alloc_steal_thir(cx.thir), expr) } +crate fn thir_tree<'tcx>( + tcx: TyCtxt<'tcx>, + owner_def: ty::WithOptConstParam<LocalDefId>, +) -> String { + format!("{:#?}", thir_body(tcx, owner_def).0.steal()) +} + struct Cx<'tcx> { tcx: TyCtxt<'tcx>, thir: Thir<'tcx>, |
