]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/util/graphviz.rs
rustc: split off BodyOwnerKind from MirSource.
[rust.git] / src / librustc_mir / util / graphviz.rs
index a38d317b823b234959a6cf96b37734b082b66947..b3c7b4bce0353dd310ae9b2e628384f65de5e2dc 100644 (file)
@@ -14,7 +14,6 @@
 use rustc::ty::TyCtxt;
 use std::fmt::Debug;
 use std::io::{self, Write};
-use syntax::ast::NodeId;
 
 use rustc_data_structures::indexed_vec::Idx;
 
@@ -28,21 +27,20 @@ pub fn write_mir_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>,
     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"];"#)?;
@@ -50,7 +48,7 @@ pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>,
     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() {
@@ -138,11 +136,11 @@ fn write_edges<W: Write>(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result
 /// 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() {