about summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow/src/framework
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-10-30 13:21:32 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-10-30 13:21:32 +1100
commitd921be92a459b41f0ba2d5b97e32397902f37294 (patch)
tree5b103e0de5500c4cf28015675455805cadbd1d9d /compiler/rustc_mir_dataflow/src/framework
parenta8ce44f7d9921f4ae1e620016c22f2a0ac6d8753 (diff)
downloadrust-d921be92a459b41f0ba2d5b97e32397902f37294.tar.gz
rust-d921be92a459b41f0ba2d5b97e32397902f37294.zip
Return label from `write_node_label`.
Instead of appending an empty label. Because it's conceptually simpler.
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/framework')
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/graphviz.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs
index 5785964de21..bac75b972f9 100644
--- a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs
@@ -97,11 +97,10 @@ where
     }
 
     fn node_label(&self, block: &Self::Node) -> dot::LabelText<'_> {
-        let mut label = Vec::new();
         let mut cursor = self.cursor.borrow_mut();
         let mut fmt =
             BlockFormatter { cursor: &mut cursor, style: self.style, bg: Background::Light };
-        fmt.write_node_label(&mut label, *block).unwrap();
+        let label = fmt.write_node_label(*block).unwrap();
 
         dot::LabelText::html(String::from_utf8(label).unwrap())
     }
@@ -172,7 +171,9 @@ where
         bg
     }
 
-    fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io::Result<()> {
+    fn write_node_label(&mut self, block: BasicBlock) -> io::Result<Vec<u8>> {
+        use std::io::Write;
+
         //   Sample output:
         //   +-+-----------------------------------------------+
         // A |                      bb4                        |
@@ -199,6 +200,9 @@ where
         // attributes. Make sure to test the output before trying to remove the redundancy.
         // Notably, `align` was found to have no effect when applied only to <table>.
 
+        let mut v = vec![];
+        let w = &mut v;
+
         let table_fmt = concat!(
             " border=\"1\"",
             " cellborder=\"1\"",
@@ -327,7 +331,9 @@ where
             _ => {}
         };
 
-        write!(w, "</table>")
+        write!(w, "</table>")?;
+
+        Ok(v)
     }
 
     fn write_block_header_simple(