rustc_mir::pretty: factor out scope entry/exit annotation computation.

This commit is contained in:
Felix S. Klock II 2016-04-28 16:06:18 +02:00
parent bfe789c044
commit 306ca4ca4f

View file

@ -106,12 +106,9 @@ enum Annotation {
ExitScope(ScopeId),
}
pub fn write_mir_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
src: MirSource,
mir: &Mir<'tcx>,
w: &mut Write,
auxiliary: Option<&ScopeAuxiliaryVec>)
-> io::Result<()> {
fn scope_entry_exit_annotations(auxiliary: Option<&ScopeAuxiliaryVec>)
-> FnvHashMap<Location, Vec<Annotation>>
{
// compute scope/entry exit annotations
let mut annotations = FnvHashMap();
if let Some(auxiliary) = auxiliary {
@ -129,7 +126,16 @@ pub fn write_mir_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
}
return annotations;
}
pub fn write_mir_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
src: MirSource,
mir: &Mir<'tcx>,
w: &mut Write,
auxiliary: Option<&ScopeAuxiliaryVec>)
-> io::Result<()> {
let annotations = scope_entry_exit_annotations(auxiliary);
write_mir_intro(tcx, src, mir, w)?;
for block in mir.all_basic_blocks() {
write_basic_block(tcx, block, mir, w, &annotations)?;