Skip to content

Commit 7d2cb3d

Browse files
committed
Make graph::DepthFirstSearch accept G by value
It's required for the next commit. Note that you can still have `G = &H`, since there are implementations of all the graph traits for references.
1 parent 86a5765 commit 7d2cb3d

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎compiler/rustc_data_structures/src/graph/iterate/mod.rs‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ pub fn reverse_post_order<G: DirectedGraph + Successors>(
7070
}
7171

7272
/// A "depth-first search" iterator for a directed graph.
73-
pubstructDepthFirstSearch<'graph,G>
73+
pubstructDepthFirstSearch<G>
7474
where
75-
G:?Sized + DirectedGraph + Successors,
75+
G:DirectedGraph + Successors,
7676
{
77-
graph:&'graphG,
77+
graph:G,
7878
stack:Vec<G::Node>,
7979
visited:BitSet<G::Node>,
8080
}
8181

82-
impl<'graph,G>DepthFirstSearch<'graph,G>
82+
impl<G>DepthFirstSearch<G>
8383
where
84-
G:?Sized + DirectedGraph + Successors,
84+
G:DirectedGraph + Successors,
8585
{
86-
pubfnnew(graph:&'graphG) -> Self{
87-
Self{graph,stack:vec![],visited:BitSet::new_empty(graph.num_nodes())}
86+
pubfnnew(graph:G) -> Self{
87+
Self{stack:vec![],visited:BitSet::new_empty(graph.num_nodes()), graph}
8888
}
8989

9090
/// Version of `push_start_node` that is convenient for chained
@@ -125,9 +125,9 @@ where
125125
}
126126
}
127127

128-
impl<G> std::fmt::DebugforDepthFirstSearch<'_,G>
128+
impl<G> std::fmt::DebugforDepthFirstSearch<G>
129129
where
130-
G:?Sized + DirectedGraph + Successors,
130+
G:DirectedGraph + Successors,
131131
{
132132
fnfmt(&self,fmt:&mut std::fmt::Formatter<'_>) -> std::fmt::Result{
133133
letmut f = fmt.debug_set();
@@ -138,9 +138,9 @@ where
138138
}
139139
}
140140

141-
impl<G>IteratorforDepthFirstSearch<'_,G>
141+
impl<G>IteratorforDepthFirstSearch<G>
142142
where
143-
G:?Sized + DirectedGraph + Successors,
143+
G:DirectedGraph + Successors,
144144
{
145145
typeItem = G::Node;
146146

‎compiler/rustc_data_structures/src/graph/mod.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ where
4646
.is_some()
4747
}
4848

49-
pubfndepth_first_search<G>(graph:&G,from:G::Node) -> iterate::DepthFirstSearch<'_,G>
49+
pubfndepth_first_search<G>(graph:G,from:G::Node) -> iterate::DepthFirstSearch<G>
5050
where
51-
G:?Sized + Successors,
51+
G:Successors,
5252
{
5353
iterate::DepthFirstSearch::new(graph).with_start_node(from)
5454
}

0 commit comments

Comments
 (0)