diff options
Diffstat (limited to '')
-rw-r--r-- | compiler/rustc_driver_impl/src/pretty.rs (renamed from compiler/rustc_driver/src/pretty.rs) | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/compiler/rustc_driver/src/pretty.rs b/compiler/rustc_driver_impl/src/pretty.rs index ae3ac8625..446c6832c 100644 --- a/compiler/rustc_driver/src/pretty.rs +++ b/compiler/rustc_driver_impl/src/pretty.rs @@ -403,7 +403,7 @@ pub fn print_after_parsing(sess: &Session, krate: &ast::Crate, ppm: PpMode) { write_or_print(&out, sess); } -pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, krate: &ast::Crate, ppm: PpMode) { +pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, ppm: PpMode) { if ppm.needs_analysis() { abort_on_err(print_with_analysis(tcx, ppm), tcx.sess); return; @@ -420,7 +420,7 @@ pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, krate: &ast::Crate, ppm let parse = &sess.parse_sess; pprust::print_crate( sess.source_map(), - krate, + &tcx.resolver_for_lowering(()).borrow().1, src_name, src, annotation.pp_ann(), @@ -433,7 +433,7 @@ pub fn print_after_hir_lowering<'tcx>(tcx: TyCtxt<'tcx>, krate: &ast::Crate, ppm AstTree(PpAstTreeMode::Expanded) => { debug!("pretty-printing expanded AST"); - format!("{krate:#?}") + format!("{:#?}", tcx.resolver_for_lowering(()).borrow().1) } Hir(s) => call_with_pp_support_hir(&s, tcx, move |annotation, hir_map| { @@ -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!(), }; |