use rustc::ty::TyCtxt;
use std::fmt::Debug;
use std::io::{self, Write};
-use syntax::ast::NodeId;
use rustc_data_structures::indexed_vec::Idx;
where W: Write
{
for def_id in dump_mir_def_ids(tcx, single) {
- let nodeid = tcx.hir.as_local_node_id(def_id).unwrap();
let mir = &tcx.optimized_mir(def_id);
- write_mir_fn_graphviz(tcx, nodeid, mir, w)?;
+ write_mir_fn_graphviz(tcx, def_id, mir, w)?;
}
Ok(())
}
/// Write a graphviz DOT graph of the MIR.
pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>,
- nodeid: NodeId,
+ def_id: DefId,
mir: &Mir,
w: &mut W) -> io::Result<()>
where W: Write
{
- writeln!(w, "digraph Mir_{} {{", nodeid)?;
+ writeln!(w, "digraph Mir_{} {{", tcx.hir.as_local_node_id(def_id).unwrap())?;
// Global graph properties
writeln!(w, r#" graph [fontname="monospace"];"#)?;
writeln!(w, r#" edge [fontname="monospace"];"#)?;
// Graph label
- write_graph_label(tcx, nodeid, mir, w)?;
+ write_graph_label(tcx, def_id, mir, w)?;
// Nodes
for (block, _) in mir.basic_blocks().iter_enumerated() {
/// will appear below the graph, showing the type of the `fn` this MIR represents and the types of
/// all the variables and temporaries.
fn write_graph_label<'a, 'gcx, 'tcx, W: Write>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
- nid: NodeId,
+ def_id: DefId,
mir: &Mir,
w: &mut W)
-> io::Result<()> {
- write!(w, " label=<fn {}(", dot::escape_html(&tcx.node_path_str(nid)))?;
+ write!(w, " label=<fn {}(", dot::escape_html(&tcx.item_path_str(def_id)))?;
// fn argument types.
for (i, arg) in mir.args_iter().enumerate() {