diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2024-04-14 15:40:26 +0000 | 
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2024-04-14 15:48:53 +0000 | 
| commit | 0d5fc9bf584f0e8700f0c3d2854bb6c70453f624 (patch) | |
| tree | 163982785183644158a7d71d90407fa85e9a41a1 /compiler/rustc_data_structures/src/graph/scc | |
| parent | 398da593a53161c1ef9ca7dabbc5e9edf67deac6 (diff) | |
| download | rust-0d5fc9bf584f0e8700f0c3d2854bb6c70453f624.tar.gz rust-0d5fc9bf584f0e8700f0c3d2854bb6c70453f624.zip | |
Merge `{With,Graph}{Successors,Predecessors}` into `{Successors,Predecessors}`
Now with GAT!
Diffstat (limited to 'compiler/rustc_data_structures/src/graph/scc')
| -rw-r--r-- | compiler/rustc_data_structures/src/graph/scc/mod.rs | 18 | 
1 files changed, 7 insertions, 11 deletions
| diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index a9967c2ecbb..f8f2f3cf0ce 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -7,7 +7,7 @@ use crate::fx::FxHashSet; use crate::graph::vec_graph::VecGraph; -use crate::graph::{DirectedGraph, GraphSuccessors, WithNumEdges, WithSuccessors}; +use crate::graph::{DirectedGraph, Successors, WithNumEdges}; use rustc_index::{Idx, IndexSlice, IndexVec}; use std::ops::Range; @@ -39,7 +39,7 @@ pub struct SccData<S: Idx> { } impl<N: Idx, S: Idx + Ord> Sccs<N, S> { - pub fn new(graph: &(impl DirectedGraph<Node = N> + WithSuccessors)) -> Self { + pub fn new(graph: &(impl DirectedGraph<Node = N> + Successors)) -> Self { SccsConstruction::construct(graph) } @@ -103,14 +103,10 @@ impl<N: Idx, S: Idx + Ord> WithNumEdges for Sccs<N, S> { } } -impl<'graph, N: Idx, S: Idx> GraphSuccessors<'graph> for Sccs<N, S> { - type Item = S; +impl<N: Idx, S: Idx + Ord> Successors for Sccs<N, S> { + type Successors<'g> = std::iter::Cloned<std::slice::Iter<'g, S>>; - type Iter = std::iter::Cloned<std::slice::Iter<'graph, S>>; -} - -impl<N: Idx, S: Idx + Ord> WithSuccessors for Sccs<N, S> { - fn successors(&self, node: S) -> <Self as GraphSuccessors<'_>>::Iter { + fn successors(&self, node: S) -> Self::Successors<'_> { self.successors(node).iter().cloned() } } @@ -156,7 +152,7 @@ impl<S: Idx> SccData<S> { } } -struct SccsConstruction<'c, G: DirectedGraph + WithSuccessors, S: Idx> { +struct SccsConstruction<'c, G: DirectedGraph + Successors, S: Idx> { graph: &'c G, /// The state of each node; used during walk to record the stack @@ -216,7 +212,7 @@ enum WalkReturn<S> { impl<'c, G, S> SccsConstruction<'c, G, S> where - G: DirectedGraph + WithSuccessors, + G: DirectedGraph + Successors, S: Idx, { /// Identifies SCCs in the graph `G` and computes the resulting | 
