]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/mir/mod.rs
deconstruct the `ControlFlowGraph` trait into more granular traits
[rust.git] / src / librustc / mir / mod.rs
index cd4b32735e57a220f0f395da909f91f9e364803c..1ce5742b4646fcdfcabd6d8b789e7fb82c7265ca 100644 (file)
@@ -22,7 +22,7 @@
 use rustc_apfloat::ieee::{Double, Single};
 use rustc_apfloat::Float;
 use rustc_data_structures::control_flow_graph::dominators::{dominators, Dominators};
-use rustc_data_structures::control_flow_graph::ControlFlowGraph;
+use rustc_data_structures::control_flow_graph;
 use rustc_data_structures::control_flow_graph::{GraphPredecessors, GraphSuccessors};
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 use rustc_data_structures::small_vec::SmallVec;
@@ -2289,23 +2289,32 @@ fn item_path_str(def_id: DefId) -> String {
     ty::tls::with(|tcx| tcx.item_path_str(def_id))
 }
 
-impl<'tcx> ControlFlowGraph for Mir<'tcx> {
+impl<'tcx> control_flow_graph::DirectedGraph for Mir<'tcx> {
     type Node = BasicBlock;
+}
 
+impl<'tcx> control_flow_graph::WithNumNodes for Mir<'tcx> {
     fn num_nodes(&self) -> usize {
         self.basic_blocks.len()
     }
+}
 
+impl<'tcx> control_flow_graph::WithStartNode for Mir<'tcx> {
     fn start_node(&self) -> Self::Node {
         START_BLOCK
     }
+}
 
+impl<'tcx> control_flow_graph::WithPredecessors for Mir<'tcx> {
     fn predecessors<'graph>(
         &'graph self,
         node: Self::Node,
     ) -> <Self as GraphPredecessors<'graph>>::Iter {
         self.predecessors_for(node).clone().into_iter()
     }
+}
+
+impl<'tcx> control_flow_graph::WithSuccessors for Mir<'tcx> {
     fn successors<'graph>(
         &'graph self,
         node: Self::Node,
@@ -2314,12 +2323,12 @@ fn successors<'graph>(
     }
 }
 
-impl<'a, 'b> GraphPredecessors<'b> for Mir<'a> {
+impl<'a, 'b> control_flow_graph::GraphPredecessors<'b> for Mir<'a> {
     type Item = BasicBlock;
     type Iter = IntoIter<BasicBlock>;
 }
 
-impl<'a, 'b> GraphSuccessors<'b> for Mir<'a> {
+impl<'a, 'b> control_flow_graph::GraphSuccessors<'b> for Mir<'a> {
     type Item = BasicBlock;
     type Iter = iter::Cloned<Successors<'b>>;
 }