diff options
Diffstat (limited to 'compiler/rustc_data_structures/src/graph/mod.rs')
| -rw-r--r-- | compiler/rustc_data_structures/src/graph/mod.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/rustc_data_structures/src/graph/mod.rs b/compiler/rustc_data_structures/src/graph/mod.rs index ef1dac1509e..5758ffce676 100644 --- a/compiler/rustc_data_structures/src/graph/mod.rs +++ b/compiler/rustc_data_structures/src/graph/mod.rs @@ -16,10 +16,14 @@ pub trait DirectedGraph { fn num_nodes(&self) -> usize; } -pub trait WithNumEdges: DirectedGraph { +pub trait NumEdges: DirectedGraph { fn num_edges(&self) -> usize; } +pub trait StartNode: DirectedGraph { + fn start_node(&self) -> Self::Node; +} + pub trait Successors: DirectedGraph { type Successors<'g>: Iterator<Item = Self::Node> where @@ -40,20 +44,16 @@ pub trait Predecessors: DirectedGraph { fn predecessors(&self, node: Self::Node) -> Self::Predecessors<'_>; } -pub trait WithStartNode: DirectedGraph { - fn start_node(&self) -> Self::Node; -} - -pub trait ControlFlowGraph: DirectedGraph + WithStartNode + Predecessors + Successors { +pub trait ControlFlowGraph: DirectedGraph + StartNode + Predecessors + Successors { // convenient trait } -impl<T> ControlFlowGraph for T where T: DirectedGraph + WithStartNode + Predecessors + Successors {} +impl<T> ControlFlowGraph for T where T: DirectedGraph + StartNode + Predecessors + Successors {} /// Returns `true` if the graph has a cycle that is reachable from the start node. pub fn is_cyclic<G>(graph: &G) -> bool where - G: ?Sized + DirectedGraph + WithStartNode + Successors, + G: ?Sized + DirectedGraph + StartNode + Successors, { iterate::TriColorDepthFirstSearch::new(graph) .run_from_start(&mut iterate::CycleDetector) |
