Skip to content

Commit 162dcdc

Browse files
committed
Add user type annotations to MIR dump.
This commit writes the user type annotations to the MIR dump so that they are visible again.
1 parent 4be7214 commit 162dcdc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/librustc_mir/borrow_check/nll/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,14 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
230230
// Before the CFG, dump out the values for each region variable.
231231
PassWhere::BeforeCFG => {
232232
regioncx.dump_mir(out)?;
233+
writeln!(out, "|")?;
233234

234235
if let Some(closure_region_requirements) = closure_region_requirements {
235-
writeln!(out, "|")?;
236236
writeln!(out, "| Free Region Constraints")?;
237237
for_each_region_constraint(closure_region_requirements, &mut |msg| {
238238
writeln!(out, "| {}", msg)
239239
})?;
240+
writeln!(out, "|")?;
240241
}
241242
}
242243

src/librustc_mir/util/pretty.rs

+14
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>(
142142
}
143143
writeln!(file, "")?;
144144
extra_data(PassWhere::BeforeCFG, &mut file)?;
145+
write_user_type_annotations(mir, &mut file)?;
145146
write_mir_fn(tcx, source, mir, &mut extra_data, &mut file)?;
146147
extra_data(PassWhere::AfterCFG, &mut file)?;
147148
};
@@ -618,6 +619,19 @@ fn write_temp_decls(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
618619
Ok(())
619620
}
620621

622+
fn write_user_type_annotations(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
623+
if !mir.user_type_annotations.is_empty() {
624+
writeln!(w, "| User Type Annotations")?;
625+
}
626+
for (index, (span, annotation)) in mir.user_type_annotations.iter_enumerated() {
627+
writeln!(w, "| {:?}: {:?} at {:?}", index.index(), annotation, span)?;
628+
}
629+
if !mir.user_type_annotations.is_empty() {
630+
writeln!(w, "|")?;
631+
}
632+
Ok(())
633+
}
634+
621635
pub fn dump_mir_def_ids(tcx: TyCtxt, single: Option<DefId>) -> Vec<DefId> {
622636
if let Some(i) = single {
623637
vec![i]

0 commit comments

Comments
 (0)