提交 2e012ce6 编写于 作者: B bors

Auto merge of #83050 - osa1:issue83048, r=matthewjasper

Run analyses before thir-tree dumps

Fixes #83048
......@@ -471,21 +471,6 @@ 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!(),
};
......@@ -501,18 +486,40 @@ fn print_with_analysis(
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(())
}
......@@ -2274,7 +2274,7 @@ pub fn needs_ast_map(&self) -> bool {
pub fn needs_analysis(&self) -> bool {
use PpMode::*;
matches!(*self, Mir | MirCFG)
matches!(*self, Mir | MirCFG | ThirTree)
}
}
......
// compile-flags: -Z unpretty=thir-tree
pub fn main() {
break; //~ ERROR: `break` outside of a loop [E0268]
}
error[E0268]: `break` outside of a loop
--> $DIR/issue-83048.rs:4:5
|
LL | break;
| ^^^^^ cannot `break` outside of a loop
error: aborting due to previous error
For more information about this error, try `rustc --explain E0268`.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册