Skip to content

Commit f514493

Browse files
committed
Rename WithNumEdges => NumEdges and WithStartNode => StartNode
1 parent 0d5fc9b commit f514493

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{DirectedGraph, Successors, WithStartNode};
1+
use super::{DirectedGraph, StartNode, Successors};
22
use rustc_index::bit_set::BitSet;
33
use rustc_index::{IndexSlice, IndexVec};
44
use std::ops::ControlFlow;
@@ -278,7 +278,7 @@ where
278278

279279
impl<G> TriColorDepthFirstSearch<'_, G>
280280
where
281-
G: ?Sized + DirectedGraph + Successors + WithStartNode,
281+
G: ?Sized + DirectedGraph + Successors + StartNode,
282282
{
283283
/// Performs a depth-first search, starting from `G::start_node()`.
284284
///

compiler/rustc_data_structures/src/graph/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ pub trait DirectedGraph {
1616
fn num_nodes(&self) -> usize;
1717
}
1818

19-
pub trait WithNumEdges: DirectedGraph {
19+
pub trait NumEdges: DirectedGraph {
2020
fn num_edges(&self) -> usize;
2121
}
2222

23+
pub trait StartNode: DirectedGraph {
24+
fn start_node(&self) -> Self::Node;
25+
}
26+
2327
pub trait Successors: DirectedGraph {
2428
type Successors<'g>: Iterator<Item = Self::Node>
2529
where
@@ -40,20 +44,16 @@ pub trait Predecessors: DirectedGraph {
4044
fn predecessors(&self, node: Self::Node) -> Self::Predecessors<'_>;
4145
}
4246

43-
pub trait WithStartNode: DirectedGraph {
44-
fn start_node(&self) -> Self::Node;
45-
}
46-
47-
pub trait ControlFlowGraph: DirectedGraph + WithStartNode + Predecessors + Successors {
47+
pub trait ControlFlowGraph: DirectedGraph + StartNode + Predecessors + Successors {
4848
// convenient trait
4949
}
5050

51-
impl<T> ControlFlowGraph for T where T: DirectedGraph + WithStartNode + Predecessors + Successors {}
51+
impl<T> ControlFlowGraph for T where T: DirectedGraph + StartNode + Predecessors + Successors {}
5252

5353
/// Returns `true` if the graph has a cycle that is reachable from the start node.
5454
pub fn is_cyclic<G>(graph: &G) -> bool
5555
where
56-
G: ?Sized + DirectedGraph + WithStartNode + Successors,
56+
G: ?Sized + DirectedGraph + StartNode + Successors,
5757
{
5858
iterate::TriColorDepthFirstSearch::new(graph)
5959
.run_from_start(&mut iterate::CycleDetector)

compiler/rustc_data_structures/src/graph/reference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ impl<'graph, G: DirectedGraph> DirectedGraph for &'graph G {
88
}
99
}
1010

11-
impl<'graph, G: WithStartNode> WithStartNode for &'graph G {
11+
impl<'graph, G: StartNode> StartNode for &'graph G {
1212
fn start_node(&self) -> Self::Node {
1313
(**self).start_node()
1414
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
use crate::fx::FxHashSet;
99
use crate::graph::vec_graph::VecGraph;
10-
use crate::graph::{DirectedGraph, Successors, WithNumEdges};
10+
use crate::graph::{DirectedGraph, NumEdges, Successors};
1111
use rustc_index::{Idx, IndexSlice, IndexVec};
1212
use std::ops::Range;
1313

@@ -97,7 +97,7 @@ impl<N: Idx, S: Idx + Ord> DirectedGraph for Sccs<N, S> {
9797
}
9898
}
9999

100-
impl<N: Idx, S: Idx + Ord> WithNumEdges for Sccs<N, S> {
100+
impl<N: Idx, S: Idx + Ord> NumEdges for Sccs<N, S> {
101101
fn num_edges(&self) -> usize {
102102
self.scc_data.all_successors.len()
103103
}

compiler/rustc_data_structures/src/graph/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl DirectedGraph for TestGraph {
4242
}
4343
}
4444

45-
impl WithStartNode for TestGraph {
45+
impl StartNode for TestGraph {
4646
fn start_node(&self) -> usize {
4747
self.start_node
4848
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::graph::{DirectedGraph, Successors, WithNumEdges};
1+
use crate::graph::{DirectedGraph, NumEdges, Successors};
22
use rustc_index::{Idx, IndexVec};
33

44
#[cfg(test)]
@@ -86,7 +86,7 @@ impl<N: Idx> DirectedGraph for VecGraph<N> {
8686
}
8787
}
8888

89-
impl<N: Idx> WithNumEdges for VecGraph<N> {
89+
impl<N: Idx> NumEdges for VecGraph<N> {
9090
fn num_edges(&self) -> usize {
9191
self.edge_targets.len()
9292
}

compiler/rustc_middle/src/mir/basic_blocks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<'tcx> graph::DirectedGraph for BasicBlocks<'tcx> {
148148
}
149149
}
150150

151-
impl<'tcx> graph::WithStartNode for BasicBlocks<'tcx> {
151+
impl<'tcx> graph::StartNode for BasicBlocks<'tcx> {
152152
#[inline]
153153
fn start_node(&self) -> Self::Node {
154154
START_BLOCK

compiler/rustc_middle/src/mir/generic_graphviz.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io::{self, Write};
55

66
pub struct GraphvizWriter<
77
'a,
8-
G: graph::DirectedGraph + graph::Successors + graph::WithStartNode,
8+
G: graph::DirectedGraph + graph::Successors + graph::StartNode,
99
NodeContentFn: Fn(<G as graph::DirectedGraph>::Node) -> Vec<String>,
1010
EdgeLabelsFn: Fn(<G as graph::DirectedGraph>::Node) -> Vec<String>,
1111
> {
@@ -19,7 +19,7 @@ pub struct GraphvizWriter<
1919

2020
impl<
2121
'a,
22-
G: graph::DirectedGraph + graph::Successors + graph::WithStartNode,
22+
G: graph::DirectedGraph + graph::Successors + graph::StartNode,
2323
NodeContentFn: Fn(<G as graph::DirectedGraph>::Node) -> Vec<String>,
2424
EdgeLabelsFn: Fn(<G as graph::DirectedGraph>::Node) -> Vec<String>,
2525
> GraphvizWriter<'a, G, NodeContentFn, EdgeLabelsFn>

compiler/rustc_mir_transform/src/coverage/graph.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_data_structures::captures::Captures;
22
use rustc_data_structures::fx::FxHashSet;
33
use rustc_data_structures::graph::dominators::{self, Dominators};
4-
use rustc_data_structures::graph::{self, DirectedGraph, WithStartNode};
4+
use rustc_data_structures::graph::{self, DirectedGraph, StartNode};
55
use rustc_index::bit_set::BitSet;
66
use rustc_index::IndexVec;
77
use rustc_middle::mir::{self, BasicBlock, Terminator, TerminatorKind};
@@ -200,7 +200,7 @@ impl graph::DirectedGraph for CoverageGraph {
200200
}
201201
}
202202

203-
impl graph::WithStartNode for CoverageGraph {
203+
impl graph::StartNode for CoverageGraph {
204204
#[inline]
205205
fn start_node(&self) -> Self::Node {
206206
self.bcb_from_bb(mir::START_BLOCK)

0 commit comments

Comments
 (0)