format!("{:#?}", krate)
}),
- ThirTree => {
- let mut out = String::new();
- abort_on_err(rustc_typeck::check_crate(tcx), tcx.sess);
- debug!("pretty printing THIR tree");
- for did in tcx.body_owners() {
- let hir = tcx.hir();
- let body = hir.body(hir.body_owned_by(hir.local_def_id_to_hir_id(did)));
- let arena = thir::Arena::default();
- let thir =
- thir::build_thir(tcx, ty::WithOptConstParam::unknown(did), &arena, &body.value);
- let _ = writeln!(out, "{:?}:\n{:#?}\n", did, thir);
- }
- out
- }
-
_ => unreachable!(),
};
ppm: PpMode,
ofile: Option<&Path>,
) -> Result<(), ErrorReported> {
- let mut out = Vec::new();
-
tcx.analysis(LOCAL_CRATE)?;
- match ppm {
- Mir => write_mir_pretty(tcx, None, &mut out).unwrap(),
- MirCFG => write_mir_graphviz(tcx, None, &mut out).unwrap(),
+ let out = match ppm {
+ Mir => {
+ let mut out = Vec::new();
+ write_mir_pretty(tcx, None, &mut out).unwrap();
+ String::from_utf8(out).unwrap()
+ }
+
+ MirCFG => {
+ let mut out = Vec::new();
+ write_mir_graphviz(tcx, None, &mut out).unwrap();
+ String::from_utf8(out).unwrap()
+ }
+
+ ThirTree => {
+ let mut out = String::new();
+ abort_on_err(rustc_typeck::check_crate(tcx), tcx.sess);
+ debug!("pretty printing THIR tree");
+ for did in tcx.body_owners() {
+ let hir = tcx.hir();
+ let body = hir.body(hir.body_owned_by(hir.local_def_id_to_hir_id(did)));
+ let arena = thir::Arena::default();
+ let thir =
+ thir::build_thir(tcx, ty::WithOptConstParam::unknown(did), &arena, &body.value);
+ let _ = writeln!(out, "{:?}:\n{:#?}\n", did, thir);
+ }
+ out
+ }
+
_ => unreachable!(),
- }
+ };
- let out = std::str::from_utf8(&out).unwrap();
- write_or_print(out, ofile);
+ write_or_print(&out, ofile);
Ok(())
}