diff options
| author | Boxy <rust@boxyuwu.dev> | 2025-01-29 16:46:09 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-29 16:46:09 +0000 |
| commit | 0b4890851287f7552e25beb43ab67243a87a1ff4 (patch) | |
| tree | 6b28cb50611b2bbcca661aaef967dd4a6eb7f26f /compiler/rustc_data_structures/src | |
| parent | bec4359db9bf5fd3c6e9d4a88d26dcf091b3c82a (diff) | |
| parent | 815c5d4eee36e836c7b75aa9288a58c4e8e7830b (diff) | |
| download | rust-0b4890851287f7552e25beb43ab67243a87a1ff4.tar.gz rust-0b4890851287f7552e25beb43ab67243a87a1ff4.zip | |
Rustc pull
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/flock/windows.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/graph/mod.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/graph/scc/mod.rs | 4 |
3 files changed, 20 insertions, 4 deletions
diff --git a/compiler/rustc_data_structures/src/flock/windows.rs b/compiler/rustc_data_structures/src/flock/windows.rs index 9739e501272..e761faee67b 100644 --- a/compiler/rustc_data_structures/src/flock/windows.rs +++ b/compiler/rustc_data_structures/src/flock/windows.rs @@ -60,9 +60,9 @@ impl Lock { unsafe { LockFileEx( - HANDLE(file.as_raw_handle() as isize), + HANDLE(file.as_raw_handle()), flags, - 0, + None, u32::MAX, u32::MAX, &mut overlapped, diff --git a/compiler/rustc_data_structures/src/graph/mod.rs b/compiler/rustc_data_structures/src/graph/mod.rs index 92035e8bc48..4a1e5db6768 100644 --- a/compiler/rustc_data_structures/src/graph/mod.rs +++ b/compiler/rustc_data_structures/src/graph/mod.rs @@ -14,7 +14,23 @@ mod tests; pub trait DirectedGraph { type Node: Idx; + /// Returns the total number of nodes in this graph. + /// + /// Several graph algorithm implementations assume that every node ID is + /// strictly less than the number of nodes, i.e. nodes are densely numbered. + /// That assumption allows them to use `num_nodes` to allocate per-node + /// data structures, indexed by node. fn num_nodes(&self) -> usize; + + /// Iterates over all nodes of a graph in ascending numeric order. + /// + /// Assumes that nodes are densely numbered, i.e. every index in + /// `0..num_nodes` is a valid node. + fn iter_nodes( + &self, + ) -> impl Iterator<Item = Self::Node> + DoubleEndedIterator + ExactSizeIterator { + (0..self.num_nodes()).map(<Self::Node as Idx>::new) + } } pub trait NumEdges: DirectedGraph { diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index 06fedef00fc..93f6192b10b 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -333,8 +333,8 @@ where to_annotation, }; - let scc_indices = (0..num_nodes) - .map(G::Node::new) + let scc_indices = graph + .iter_nodes() .map(|node| match this.start_walk_from(node) { WalkReturn::Complete { scc_index, .. } => scc_index, WalkReturn::Cycle { min_depth, .. } => { |
