A few more code cleanups
This commit is contained in:
parent
3ed189e8af
commit
dd3772e4f0
|
@ -391,16 +391,13 @@ pub fn print_after_parsing(
|
|||
) {
|
||||
let (src, src_name) = get_source(input, sess);
|
||||
|
||||
let mut out = String::new();
|
||||
|
||||
if let Source(s) = ppm {
|
||||
let out = if let Source(s) = ppm {
|
||||
// Silently ignores an identified node.
|
||||
let out = &mut out;
|
||||
call_with_pp_support(&s, sess, None, move |annotation| {
|
||||
debug!("pretty printing source code {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
let parse = &sess.parse_sess;
|
||||
*out = pprust::print_crate(
|
||||
pprust::print_crate(
|
||||
sess.source_map(),
|
||||
krate,
|
||||
src_name,
|
||||
|
@ -411,7 +408,7 @@ pub fn print_after_parsing(
|
|||
)
|
||||
})
|
||||
} else {
|
||||
unreachable!();
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
write_or_print(&out, ofile);
|
||||
|
@ -431,17 +428,14 @@ pub fn print_after_hir_lowering<'tcx>(
|
|||
|
||||
let (src, src_name) = get_source(input, tcx.sess);
|
||||
|
||||
let mut out = String::new();
|
||||
|
||||
match ppm {
|
||||
let out = match ppm {
|
||||
Source(s) => {
|
||||
// Silently ignores an identified node.
|
||||
let out = &mut out;
|
||||
call_with_pp_support(&s, tcx.sess, Some(tcx), move |annotation| {
|
||||
debug!("pretty printing source code {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
let parse = &sess.parse_sess;
|
||||
*out = pprust::print_crate(
|
||||
pprust::print_crate(
|
||||
sess.source_map(),
|
||||
krate,
|
||||
src_name,
|
||||
|
@ -453,26 +447,20 @@ pub fn print_after_hir_lowering<'tcx>(
|
|||
})
|
||||
}
|
||||
|
||||
Hir(s) => {
|
||||
let out = &mut out;
|
||||
call_with_pp_support_hir(&s, tcx, move |annotation, krate| {
|
||||
debug!("pretty printing HIR {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
let sm = sess.source_map();
|
||||
*out = pprust_hir::print_crate(sm, krate, src_name, src, annotation.pp_ann())
|
||||
})
|
||||
}
|
||||
Hir(s) => call_with_pp_support_hir(&s, tcx, move |annotation, krate| {
|
||||
debug!("pretty printing HIR {:?}", s);
|
||||
let sess = annotation.sess();
|
||||
let sm = sess.source_map();
|
||||
pprust_hir::print_crate(sm, krate, src_name, src, annotation.pp_ann())
|
||||
}),
|
||||
|
||||
HirTree => {
|
||||
let out = &mut out;
|
||||
call_with_pp_support_hir(&PpHirMode::Normal, tcx, move |_annotation, krate| {
|
||||
debug!("pretty printing HIR tree");
|
||||
*out = format!("{:#?}", krate);
|
||||
});
|
||||
}
|
||||
HirTree => call_with_pp_support_hir(&PpHirMode::Normal, tcx, move |_annotation, krate| {
|
||||
debug!("pretty printing HIR tree");
|
||||
format!("{:#?}", krate)
|
||||
}),
|
||||
|
||||
_ => unreachable!(),
|
||||
}
|
||||
};
|
||||
|
||||
write_or_print(&out, ofile);
|
||||
}
|
||||
|
@ -491,14 +479,10 @@ fn print_with_analysis(
|
|||
tcx.analysis(LOCAL_CRATE)?;
|
||||
|
||||
match ppm {
|
||||
Mir | MirCFG => match ppm {
|
||||
Mir => write_mir_pretty(tcx, None, &mut out),
|
||||
MirCFG => write_mir_graphviz(tcx, None, &mut out),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
Mir => write_mir_pretty(tcx, None, &mut out).unwrap(),
|
||||
MirCFG => write_mir_graphviz(tcx, None, &mut out).unwrap(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
.unwrap();
|
||||
|
||||
let out = std::str::from_utf8(&out).unwrap();
|
||||
write_or_print(out, ofile);
|
||||
|
|
Loading…
Reference in New Issue