]> git.lizzy.rs Git - rust.git/commitdiff
Mir pretty print: Add cleanup comment
authorDavid Henningsson <diwic@ubuntu.com>
Fri, 29 Sep 2017 09:00:08 +0000 (11:00 +0200)
committerDavid Henningsson <diwic@ubuntu.com>
Fri, 29 Sep 2017 09:02:36 +0000 (11:02 +0200)
I found it useful to add a comment indicating whether or not a
BasicBlock is a cleanup block or not. Hopefully you'll find it
useful too.

src/librustc_mir/util/pretty.rs

index 0811783a9e57f7b75c211652c2398cc84b346c81..9e1f05f6d2f777cc2b5893c59227ff9848991237 100644 (file)
@@ -188,7 +188,9 @@ pub fn write_basic_block(tcx: TyCtxt,
     let data = &mir[block];
 
     // Basic block label at the top.
-    writeln!(w, "{}{:?}: {{", INDENT, block)?;
+    let cleanup_text = if data.is_cleanup { " // cleanup" } else { "" };
+    let lbl = format!("{}{:?}: {{", INDENT, block);
+    writeln!(w, "{0:1$}{2}", lbl, ALIGN, cleanup_text)?;
 
     // List of statements in the middle.
     let mut current_location = Location { block: block, statement_index: 0 };