diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index d04f5c1d4ee77..a53e0012ca221 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -597,6 +597,8 @@ pub enum RenderOption { NoNodeLabels, NoEdgeStyles, NoNodeStyles, + + Monospace, } /// Returns vec holding all the default render options. @@ -626,6 +628,14 @@ where W: Write, { writeln!(w, "digraph {} {{", g.graph_id().as_slice())?; + + // Global graph properties + if options.contains(&RenderOption::Monospace) { + writeln!(w, r#" graph[fontname="monospace"];"#)?; + writeln!(w, r#" node[fontname="monospace"];"#)?; + writeln!(w, r#" edge[fontname="monospace"];"#)?; + } + for n in g.nodes().iter() { write!(w, " ")?; let id = g.node_id(n); diff --git a/src/librustc_mir/dataflow/generic/engine.rs b/src/librustc_mir/dataflow/generic/engine.rs index c0152b0c7d504..718c1e9ae2043 100644 --- a/src/librustc_mir/dataflow/generic/engine.rs +++ b/src/librustc_mir/dataflow/generic/engine.rs @@ -331,7 +331,7 @@ where let mut buf = Vec::new(); let graphviz = graphviz::Formatter::new(body, def_id, results, &mut *formatter); - dot::render(&graphviz, &mut buf)?; + dot::render_opts(&graphviz, &mut buf, &[dot::RenderOption::Monospace])?; fs::write(&path, buf)?; Ok(()) } diff --git a/src/librustc_mir/dataflow/generic/graphviz.rs b/src/librustc_mir/dataflow/generic/graphviz.rs index fdf86e7b53f60..b805b13592f89 100644 --- a/src/librustc_mir/dataflow/generic/graphviz.rs +++ b/src/librustc_mir/dataflow/generic/graphviz.rs @@ -171,10 +171,19 @@ where // | | (on successful return) | +_4 | // +-+----------------------------------+------------+ - write!( - w, - r#"
"#, + r#" | "#, colspan = num_state_columns, fmt = fmt, )?; @@ -311,7 +320,9 @@ where f: impl FnOnce(&mut Self, &mut W, &str) -> io::Result<()>, ) -> io::Result<()> { let bg = self.toggle_background(); - let fmt = format!("sides=\"tl\" {}", bg.attr()); + let valign = if mir.starts_with("(on ") && mir != "(on entry)" { "bottom" } else { "top" }; + + let fmt = format!("valign=\"{}\" sides=\"tl\" {}", valign, bg.attr()); write!( w, @@ -345,7 +356,7 @@ where colspan = this.num_state_columns(), fmt = fmt, )?; - pretty_print_state_elems(w, analysis, state.iter(), ",", LIMIT_40_ALIGN_1)?; + pretty_print_state_elems(w, analysis, state.iter(), ", ", LIMIT_30_ALIGN_1)?; write!(w, "}} | ") }) } @@ -387,7 +398,6 @@ pub struct SimpleDiff"#, fmt = fmt)?; - results.seek_before(location); + write!(w, r#" | "#, fmt = fmt)?;
+ results.seek_after(location);
let curr_state = results.get();
write_diff(&mut w, results.analysis(), &self.prev_state, curr_state)?;
self.prev_state.overwrite(curr_state);
@@ -434,7 +444,6 @@ pub struct TwoPhaseDiff"#, fmt = fmt)?;
results.seek_before(location);
@@ -474,7 +483,7 @@ where
self.prev_state.overwrite(curr_state);
write!(w, " | ")?;
- // Exit
+ // After
write!(w, r#""#, fmt = fmt)?;
results.seek_after(location);
@@ -492,7 +501,6 @@ pub struct BlockTransferFunc<'a, 'tcx, T: Idx> {
}
impl | "#,
+ r#" | "#,
fmt = fmt,
rowspan = rowspan
)?;
- pretty_print_state_elems(&mut w, results.analysis(), set.iter(), "\n", None)?;
+ pretty_print_state_elems(&mut w, results.analysis(), set.iter(), BR_LEFT, None)?;
write!(w, " | ")?;
}
@@ -564,25 +572,28 @@ fn write_diff")?; + write!(w, "{}", BR_LEFT)?; } if !clear.is_empty() { write!(w, r#"-"#)?; - pretty_print_state_elems(w, analysis, clear.iter(), ",", LIMIT_40_ALIGN_1)?; + pretty_print_state_elems(w, analysis, clear.iter(), ", ", LIMIT_30_ALIGN_1)?; write!(w, r#""#)?; } Ok(()) } +const BR_LEFT: &'static str = r#" "#; +const BR_LEFT_SPACE: &'static str = r#" "#; + /// Line break policy that breaks at 40 characters and starts the next line with a single space. -const LIMIT_40_ALIGN_1: Option ", limit: 40 }); +const LIMIT_30_ALIGN_1: Option |