about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/graph
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2024-04-15 13:33:08 +0000
committerMaybe Waffle <waffle.lapkin@gmail.com>2024-04-15 13:34:08 +0000
commit435db9b9bd404c1bc632fbb6ade8b4ce92c2828c (patch)
treea203fe3f701723487e869937d0446d11bb13779c /compiler/rustc_data_structures/src/graph
parente8d2221e3bbb4e8971c97395463036ebd6e7b23d (diff)
downloadrust-435db9b9bd404c1bc632fbb6ade8b4ce92c2828c.tar.gz
rust-435db9b9bd404c1bc632fbb6ade8b4ce92c2828c.zip
Use RPITIT for `Successors` and `Predecessors` traits
Now with RPITIT instead of GAT!
Diffstat (limited to 'compiler/rustc_data_structures/src/graph')
-rw-r--r--compiler/rustc_data_structures/src/graph/mod.rs12
-rw-r--r--compiler/rustc_data_structures/src/graph/reference.rs8
-rw-r--r--compiler/rustc_data_structures/src/graph/scc/mod.rs4
-rw-r--r--compiler/rustc_data_structures/src/graph/tests.rs10
-rw-r--r--compiler/rustc_data_structures/src/graph/vec_graph/mod.rs4
5 files changed, 8 insertions, 30 deletions
diff --git a/compiler/rustc_data_structures/src/graph/mod.rs b/compiler/rustc_data_structures/src/graph/mod.rs
index 61bee2ee0bb..3ae3023a91b 100644
--- a/compiler/rustc_data_structures/src/graph/mod.rs
+++ b/compiler/rustc_data_structures/src/graph/mod.rs
@@ -25,19 +25,11 @@ pub trait StartNode: DirectedGraph {
 }
 
 pub trait Successors: DirectedGraph {
-    type Successors<'g>: Iterator<Item = Self::Node>
-    where
-        Self: 'g;
-
-    fn successors(&self, node: Self::Node) -> Self::Successors<'_>;
+    fn successors(&self, node: Self::Node) -> impl Iterator<Item = Self::Node>;
 }
 
 pub trait Predecessors: DirectedGraph {
-    type Predecessors<'g>: Iterator<Item = Self::Node>
-    where
-        Self: 'g;
-
-    fn predecessors(&self, node: Self::Node) -> Self::Predecessors<'_>;
+    fn predecessors(&self, node: Self::Node) -> impl Iterator<Item = Self::Node>;
 }
 
 /// Alias for [`DirectedGraph`] + [`StartNode`] + [`Predecessors`] + [`Successors`].
diff --git a/compiler/rustc_data_structures/src/graph/reference.rs b/compiler/rustc_data_structures/src/graph/reference.rs
index 16b019374be..7a487552f53 100644
--- a/compiler/rustc_data_structures/src/graph/reference.rs
+++ b/compiler/rustc_data_structures/src/graph/reference.rs
@@ -15,17 +15,13 @@ impl<'graph, G: StartNode> StartNode for &'graph G {
 }
 
 impl<'graph, G: Successors> Successors for &'graph G {
-    type Successors<'g> = G::Successors<'g> where 'graph: 'g;
-
-    fn successors(&self, node: Self::Node) -> Self::Successors<'_> {
+    fn successors(&self, node: Self::Node) -> impl Iterator<Item = Self::Node> {
         (**self).successors(node)
     }
 }
 
 impl<'graph, G: Predecessors> Predecessors for &'graph G {
-    type Predecessors<'g> = G::Predecessors<'g> where 'graph: 'g;
-
-    fn predecessors(&self, node: Self::Node) -> Self::Predecessors<'_> {
+    fn predecessors(&self, node: Self::Node) -> impl Iterator<Item = Self::Node> {
         (**self).predecessors(node)
     }
 }
diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs
index 1cd0edfe57f..5021e5e8fc0 100644
--- a/compiler/rustc_data_structures/src/graph/scc/mod.rs
+++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs
@@ -104,9 +104,7 @@ impl<N: Idx, S: Idx + Ord> NumEdges for Sccs<N, S> {
 }
 
 impl<N: Idx, S: Idx + Ord> Successors for Sccs<N, S> {
-    type Successors<'g> = std::iter::Cloned<std::slice::Iter<'g, S>>;
-
-    fn successors(&self, node: S) -> Self::Successors<'_> {
+    fn successors(&self, node: S) -> impl Iterator<Item = Self::Node> {
         self.successors(node).iter().cloned()
     }
 }
diff --git a/compiler/rustc_data_structures/src/graph/tests.rs b/compiler/rustc_data_structures/src/graph/tests.rs
index 118b6bd3eb6..85c2703cc25 100644
--- a/compiler/rustc_data_structures/src/graph/tests.rs
+++ b/compiler/rustc_data_structures/src/graph/tests.rs
@@ -1,7 +1,5 @@
 use crate::fx::FxHashMap;
 use std::cmp::max;
-use std::iter;
-use std::slice;
 
 use super::*;
 
@@ -49,17 +47,13 @@ impl StartNode for TestGraph {
 }
 
 impl Predecessors for TestGraph {
-    type Predecessors<'g> = iter::Cloned<slice::Iter<'g, usize>>;
-
-    fn predecessors(&self, node: usize) -> Self::Predecessors<'_> {
+    fn predecessors(&self, node: usize) -> impl Iterator<Item = Self::Node> {
         self.predecessors[&node].iter().cloned()
     }
 }
 
 impl Successors for TestGraph {
-    type Successors<'g> = iter::Cloned<slice::Iter<'g, usize>>;
-
-    fn successors(&self, node: usize) -> Self::Successors<'_> {
+    fn successors(&self, node: usize) -> impl Iterator<Item = Self::Node> {
         self.successors[&node].iter().cloned()
     }
 }
diff --git a/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs b/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs
index 3f9d8ec0aca..26c86469fad 100644
--- a/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs
+++ b/compiler/rustc_data_structures/src/graph/vec_graph/mod.rs
@@ -93,9 +93,7 @@ impl<N: Idx> NumEdges for VecGraph<N> {
 }
 
 impl<N: Idx + Ord> Successors for VecGraph<N> {
-    type Successors<'g> = std::iter::Cloned<std::slice::Iter<'g, N>>;
-
-    fn successors(&self, node: N) -> Self::Successors<'_> {
+    fn successors(&self, node: N) -> impl Iterator<Item = Self::Node> {
         self.successors(node).iter().cloned()
     }
 }