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
|
@ -3870,6 +3870,7 @@ dependencies = [
|
|||
"rustc_metadata",
|
||||
"rustc_middle",
|
||||
"rustc_mir",
|
||||
"rustc_mir_build",
|
||||
"rustc_parse",
|
||||
"rustc_plugin_impl",
|
||||
"rustc_save_analysis",
|
||||
|
@ -3877,6 +3878,7 @@ dependencies = [
|
|||
"rustc_session",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"rustc_typeck",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"tracing-tree",
|
||||
|
|
|
@ -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!(),
|
||||
};
|
||||
|
||||
|
|
|
@ -2074,6 +2074,7 @@ fn parse_pretty(
|
|||
("hir,identified", true) => Hir(PpHirMode::Identified),
|
||||
("hir,typed", true) => Hir(PpHirMode::Typed),
|
||||
("hir-tree", true) => HirTree,
|
||||
("thir-tree", true) => ThirTree,
|
||||
("mir", true) => Mir,
|
||||
("mir-cfg", true) => MirCFG,
|
||||
_ => {
|
||||
|
@ -2265,6 +2266,8 @@ pub enum PpMode {
|
|||
Hir(PpHirMode),
|
||||
/// `-Zunpretty=hir-tree`
|
||||
HirTree,
|
||||
/// `-Zunpretty=thir-tree`
|
||||
ThirTree,
|
||||
/// `-Zunpretty=mir`
|
||||
Mir,
|
||||
/// `-Zunpretty=mir-cfg`
|
||||
|
@ -2282,6 +2285,7 @@ impl PpMode {
|
|||
| AstTree(PpAstTreeMode::Expanded)
|
||||
| Hir(_)
|
||||
| HirTree
|
||||
| ThirTree
|
||||
| Mir
|
||||
| MirCFG => true,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue