output tree representation for thir-tree
This commit is contained in:
parent
e187f8871e
commit
90e4c13409
5 changed files with 893 additions and 4 deletions
|
@ -439,6 +439,10 @@ fn construct_fn<'tcx>(
|
|||
let fn_id = tcx.hir().local_def_id_to_hir_id(fn_def.did);
|
||||
let generator_kind = tcx.generator_kind(fn_def.did);
|
||||
|
||||
// The representation of thir for `-Zunpretty=thir-tree` relies on
|
||||
// the entry expression being the last element of `thir.exprs`.
|
||||
assert_eq!(expr.as_usize(), thir.exprs.len() - 1);
|
||||
|
||||
// Figure out what primary body this item has.
|
||||
let body_id = tcx.hir().body_owned_by(fn_def.did);
|
||||
let span_with_body = tcx.hir().span_with_body(fn_id);
|
||||
|
|
|
@ -54,7 +54,10 @@ pub(crate) fn thir_body(
|
|||
|
||||
pub(crate) fn thir_tree(tcx: TyCtxt<'_>, owner_def: ty::WithOptConstParam<LocalDefId>) -> String {
|
||||
match thir_body(tcx, owner_def) {
|
||||
Ok((thir, _)) => format!("{:#?}", thir.steal()),
|
||||
Ok((thir, _)) => {
|
||||
let thir = thir.steal();
|
||||
tcx.thir_tree_representation(&thir)
|
||||
}
|
||||
Err(_) => "error".into(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue