Skip to content

Commit d921be9

Browse files
committed
Return label from write_node_label.
Instead of appending an empty label. Because it's conceptually simpler.
1 parent a8ce44f commit d921be9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

compiler/rustc_mir_dataflow/src/framework/graphviz.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ where
9797
}
9898

9999
fn node_label(&self, block: &Self::Node) -> dot::LabelText<'_> {
100-
let mut label = Vec::new();
101100
let mut cursor = self.cursor.borrow_mut();
102101
let mut fmt =
103102
BlockFormatter { cursor: &mut cursor, style: self.style, bg: Background::Light };
104-
fmt.write_node_label(&mut label, *block).unwrap();
103+
let label = fmt.write_node_label(*block).unwrap();
105104

106105
dot::LabelText::html(String::from_utf8(label).unwrap())
107106
}
@@ -172,7 +171,9 @@ where
172171
bg
173172
}
174173

175-
fn write_node_label(&mut self, w: &mut impl io::Write, block: BasicBlock) -> io::Result<()> {
174+
fn write_node_label(&mut self, block: BasicBlock) -> io::Result<Vec<u8>> {
175+
use std::io::Write;
176+
176177
// Sample output:
177178
// +-+-----------------------------------------------+
178179
// A | bb4 |
@@ -199,6 +200,9 @@ where
199200
// attributes. Make sure to test the output before trying to remove the redundancy.
200201
// Notably, `align` was found to have no effect when applied only to <table>.
201202

203+
let mut v = vec![];
204+
let w = &mut v;
205+
202206
let table_fmt = concat!(
203207
" border=\"1\"",
204208
" cellborder=\"1\"",
@@ -327,7 +331,9 @@ where
327331
_ => {}
328332
};
329333

330-
write!(w, "</table>")
334+
write!(w, "</table>")?;
335+
336+
Ok(v)
331337
}
332338

333339
fn write_block_header_simple(

0 commit comments

Comments
 (0)