1
Fork 0

Auto merge of #135592 - matthiaskrgr:rollup-4t69l7i, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #134754 (Implement `use` associated items of traits)
 - #135481 (coverage: Completely overhaul counter assignment, using node-flow graphs)
 - #135504 (Allow coercing safe-to-call target_feature functions to safe fn pointers)
 - #135561 (Update docs for `-Clink-dead-code` to discourage its use)
 - #135574 (ci: mirror ubuntu:22.04 to ghcr.io)
 - #135585 (resolve symlinks of LLVM tool binaries before copying them)
 - #135588 (Add license-metadata.json to rustc-src tarball.)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-01-16 21:31:19 +00:00
commit 76a030a6c2
91 changed files with 2613 additions and 2052 deletions

View file

@ -125,6 +125,16 @@ where
pub fn visited(&self, node: G::Node) -> bool {
self.visited.contains(node)
}
/// Returns a reference to the set of nodes that have been visited, with
/// the same caveats as [`Self::visited`].
///
/// When incorporating the visited nodes into another bitset, using bulk
/// operations like `union` or `intersect` can be more efficient than
/// processing each node individually.
pub fn visited_set(&self) -> &DenseBitSet<G::Node> {
&self.visited
}
}
impl<G> std::fmt::Debug for DepthFirstSearch<G>

View file

@ -4,6 +4,7 @@ pub mod dominators;
pub mod implementation;
pub mod iterate;
mod reference;
pub mod reversed;
pub mod scc;
pub mod vec_graph;

View file

@ -0,0 +1,42 @@
use crate::graph::{DirectedGraph, Predecessors, Successors};
/// View that reverses the direction of edges in its underlying graph, so that
/// successors become predecessors and vice-versa.
///
/// Because of `impl<G: Graph> Graph for &G`, the underlying graph can be
/// wrapped by-reference instead of by-value if desired.
#[derive(Clone, Copy, Debug)]
pub struct ReversedGraph<G> {
pub inner: G,
}
impl<G> ReversedGraph<G> {
pub fn new(inner: G) -> Self {
Self { inner }
}
}
impl<G: DirectedGraph> DirectedGraph for ReversedGraph<G> {
type Node = G::Node;
fn num_nodes(&self) -> usize {
self.inner.num_nodes()
}
}
// Implementing `StartNode` is not possible in general, because the start node
// of an underlying graph is instead an _end_ node in the reversed graph.
// But would be possible to define another wrapper type that adds an explicit
// start node to its underlying graph, if desired.
impl<G: Predecessors> Successors for ReversedGraph<G> {
fn successors(&self, node: Self::Node) -> impl Iterator<Item = Self::Node> {
self.inner.predecessors(node)
}
}
impl<G: Successors> Predecessors for ReversedGraph<G> {
fn predecessors(&self, node: Self::Node) -> impl Iterator<Item = Self::Node> {
self.inner.successors(node)
}
}