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.
This commit is contained in:
commit
eba3228b2a
8 changed files with 88 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue