Skip to content

Commit

Permalink
Add user type annotations to MIR dump.
Browse files Browse the repository at this point in the history
This commit writes the user type annotations to the MIR dump so that
they are visible again.
  • Loading branch information
davidtwco committed Dec 30, 2018
1 parent 4be7214 commit 162dcdc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_mir/borrow_check/nll/mod.rs
Expand Up @@ -230,13 +230,14 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
// Before the CFG, dump out the values for each region variable.
PassWhere::BeforeCFG => {
regioncx.dump_mir(out)?;
writeln!(out, "|")?;

if let Some(closure_region_requirements) = closure_region_requirements {
writeln!(out, "|")?;
writeln!(out, "| Free Region Constraints")?;
for_each_region_constraint(closure_region_requirements, &mut |msg| {
writeln!(out, "| {}", msg)
})?;
writeln!(out, "|")?;
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/librustc_mir/util/pretty.rs
Expand Up @@ -142,6 +142,7 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>(
}
writeln!(file, "")?;
extra_data(PassWhere::BeforeCFG, &mut file)?;
write_user_type_annotations(mir, &mut file)?;
write_mir_fn(tcx, source, mir, &mut extra_data, &mut file)?;
extra_data(PassWhere::AfterCFG, &mut file)?;
};
Expand Down Expand Up @@ -618,6 +619,19 @@ fn write_temp_decls(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
Ok(())
}

fn write_user_type_annotations(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
if !mir.user_type_annotations.is_empty() {
writeln!(w, "| User Type Annotations")?;
}
for (index, (span, annotation)) in mir.user_type_annotations.iter_enumerated() {
writeln!(w, "| {:?}: {:?} at {:?}", index.index(), annotation, span)?;
}
if !mir.user_type_annotations.is_empty() {
writeln!(w, "|")?;
}
Ok(())
}

pub fn dump_mir_def_ids(tcx: TyCtxt, single: Option<DefId>) -> Vec<DefId> {
if let Some(i) = single {
vec![i]
Expand Down

0 comments on commit 162dcdc

Please sign in to comment.