Add -Z unpretty
flag for the THIR
This commit is contained in:
parent
2a34428253
commit
6bf4147646
4 changed files with 25 additions and 0 deletions
|
@ -34,6 +34,8 @@ rustc_interface = { path = "../rustc_interface" }
|
|||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
rustc_mir_build = { path = "../rustc_mir_build" }
|
||||
rustc_typeck = { path = "../rustc_typeck" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3", features = ["consoleapi", "debugapi", "processenv"] }
|
||||
|
|
|
@ -9,12 +9,14 @@ use rustc_hir_pretty as pprust_hir;
|
|||
use rustc_middle::hir::map as hir_map;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
|
||||
use rustc_mir_build::thir;
|
||||
use rustc_session::config::{Input, PpAstTreeMode, PpHirMode, PpMode, PpSourceMode};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::FileName;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::fmt::Write;
|
||||
use std::path::Path;
|
||||
|
||||
pub use self::PpMode::*;
|
||||
|
@ -469,6 +471,21 @@ pub fn print_after_hir_lowering<'tcx>(
|
|||
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!(),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue