Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 27d6200

Browse files
committedMay 6, 2025·
Auto merge of #140708 - GuillaumeGomez:rollup-egt3nl9, r=GuillaumeGomez
Rollup of 4 pull requests Successful merges: - #136183 (Update iterator.rs to use arrays by value) - #139966 (coverage: Only merge adjacent coverage spans) - #140692 (Rename `graph::implementation::Graph` to `LinkedGraph`) - #140703 (Handle PR not found in post-merge workflow) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1a95cc6 + ee0d68f commit 27d6200

File tree

147 files changed

+3166
-2111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+3166
-2111
lines changed
 

‎.github/workflows/post-merge.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ jobs:
2525
env:
2626
GH_TOKEN: ${{ github.token }}
2727
run: |
28+
# Give GitHub some time to propagate the information that the PR was merged
29+
sleep 60
30+
2831
# Get closest bors merge commit
2932
PARENT_COMMIT=`git rev-list --author='bors <bors@rust-lang.org>' -n1 --first-parent HEAD^1`
3033
echo "Parent: ${PARENT_COMMIT}"
3134
3235
# Find PR for the current commit
3336
HEAD_PR=`gh pr list --search "${{ github.sha }}" --state merged --json number --jq '.[0].number'`
37+
if [ -z "${HEAD_PR}" ]; then
38+
echo "PR for commit SHA ${{ github.sha }} not found, exiting"
39+
exit 1
40+
fi
3441
echo "HEAD: ${{ github.sha }} (#${HEAD_PR})"
3542
3643
cd src/ci/citool

‎compiler/rustc_data_structures/src/graph/implementation/mod.rs renamed to ‎compiler/rustc_data_structures/src/graph/linked_graph/mod.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! A graph module for use in dataflow, region resolution, and elsewhere.
1+
//! See [`LinkedGraph`].
22
//!
33
//! # Interface details
44
//!
@@ -28,7 +28,23 @@ use tracing::debug;
2828
#[cfg(test)]
2929
mod tests;
3030

31-
pub struct Graph<N, E> {
31+
/// A concrete graph implementation that supports:
32+
/// - Nodes and/or edges labelled with custom data types (`N` and `E` respectively).
33+
/// - Incremental addition of new nodes/edges (but not removal).
34+
/// - Flat storage of node/edge data in a pair of vectors.
35+
/// - Iteration over any node's out-edges or in-edges, via linked lists
36+
/// threaded through the node/edge data.
37+
///
38+
/// # Caution
39+
/// This is an older graph implementation that is still used by some pieces
40+
/// of diagnostic/debugging code. New code that needs a graph data structure
41+
/// should consider using `VecGraph` instead, or implementing its own
42+
/// special-purpose graph with the specific features needed.
43+
///
44+
/// This graph implementation predates the later [graph traits](crate::graph),
45+
/// and does not implement those traits, so it has its own implementations of a
46+
/// few basic graph algorithms.
47+
pub struct LinkedGraph<N, E> {
3248
nodes: Vec<Node<N>>,
3349
edges: Vec<Edge<E>>,
3450
}
@@ -71,13 +87,13 @@ impl NodeIndex {
7187
}
7288
}
7389

74-
impl<N: Debug, E: Debug> Graph<N, E> {
75-
pub fn new() -> Graph<N, E> {
76-
Graph { nodes: Vec::new(), edges: Vec::new() }
90+
impl<N: Debug, E: Debug> LinkedGraph<N, E> {
91+
pub fn new() -> Self {
92+
Self { nodes: Vec::new(), edges: Vec::new() }
7793
}
7894

79-
pub fn with_capacity(nodes: usize, edges: usize) -> Graph<N, E> {
80-
Graph { nodes: Vec::with_capacity(nodes), edges: Vec::with_capacity(edges) }
95+
pub fn with_capacity(nodes: usize, edges: usize) -> Self {
96+
Self { nodes: Vec::with_capacity(nodes), edges: Vec::with_capacity(edges) }
8197
}
8298

8399
// # Simple accessors
@@ -249,7 +265,7 @@ impl<N: Debug, E: Debug> Graph<N, E> {
249265
// # Iterators
250266

251267
pub struct AdjacentEdges<'g, N, E> {
252-
graph: &'g Graph<N, E>,
268+
graph: &'g LinkedGraph<N, E>,
253269
direction: Direction,
254270
next: EdgeIndex,
255271
}
@@ -285,15 +301,15 @@ impl<'g, N: Debug, E: Debug> Iterator for AdjacentEdges<'g, N, E> {
285301
}
286302

287303
pub struct DepthFirstTraversal<'g, N, E> {
288-
graph: &'g Graph<N, E>,
304+
graph: &'g LinkedGraph<N, E>,
289305
stack: Vec<NodeIndex>,
290306
visited: DenseBitSet<usize>,
291307
direction: Direction,
292308
}
293309

294310
impl<'g, N: Debug, E: Debug> DepthFirstTraversal<'g, N, E> {
295311
pub fn with_start_node(
296-
graph: &'g Graph<N, E>,
312+
graph: &'g LinkedGraph<N, E>,
297313
start_node: NodeIndex,
298314
direction: Direction,
299315
) -> Self {

0 commit comments

Comments
 (0)
Please sign in to comment.