]> git.lizzy.rs Git - rust.git/commitdiff
Add user type annotations to MIR dump.
authorDavid Wood <david@davidtw.co>
Sun, 25 Nov 2018 12:31:34 +0000 (13:31 +0100)
committerDavid Wood <david@davidtw.co>
Sun, 30 Dec 2018 13:30:58 +0000 (14:30 +0100)
This commit writes the user type annotations to the MIR dump so that
they are visible again.

src/librustc_mir/borrow_check/nll/mod.rs
src/librustc_mir/util/pretty.rs

index c5eabbbefa9a497775a968d45a404980d0988c55..a092c3b8ecde2c5671874d7ad4f67835a50f8eed 100644 (file)
@@ -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, "|")?;
                     }
                 }
 
index 35b367855ad28f751892eaec6818b5ef0a44ef0b..6353eab6f6553770271e491549ce1c16cda7a1b7 100644 (file)
@@ -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)?;
     };
@@ -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]