]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir/src/dataflow/framework/graphviz.rs
Add comments to explain memory usage optimization
[rust.git] / compiler / rustc_mir / src / dataflow / framework / graphviz.rs
index 5d4c4251961d20df3bdf7d1c71e31ef3eafae90f..4e54257a1cb2d96128db3314699f36cd11513a96 100644 (file)
@@ -6,7 +6,6 @@
 
 use regex::Regex;
 use rustc_graphviz as dot;
-use rustc_hir::def_id::DefId;
 use rustc_middle::mir::{self, BasicBlock, Body, Location};
 
 use super::fmt::{DebugDiffWithAdapter, DebugWithAdapter, DebugWithContext};
@@ -33,7 +32,6 @@ pub struct Formatter<'a, 'tcx, A>
     A: Analysis<'tcx>,
 {
     body: &'a Body<'tcx>,
-    def_id: DefId,
     results: &'a Results<'tcx, A>,
     style: OutputStyle,
 }
@@ -42,13 +40,8 @@ impl<A> Formatter<'a, 'tcx, A>
 where
     A: Analysis<'tcx>,
 {
-    pub fn new(
-        body: &'a Body<'tcx>,
-        def_id: DefId,
-        results: &'a Results<'tcx, A>,
-        style: OutputStyle,
-    ) -> Self {
-        Formatter { body, def_id, results, style }
+    pub fn new(body: &'a Body<'tcx>, results: &'a Results<'tcx, A>, style: OutputStyle) -> Self {
+        Formatter { body, results, style }
     }
 }
 
@@ -77,7 +70,7 @@ impl<A> dot::Labeller<'_> for Formatter<'a, 'tcx, A>
     type Edge = CfgEdge;
 
     fn graph_id(&self) -> dot::Id<'_> {
-        let name = graphviz_safe_def_name(self.def_id);
+        let name = graphviz_safe_def_name(self.body.source.def_id());
         dot::Id::new(format!("graph_for_def_id_{}", name)).unwrap()
     }