1
Fork 0

Revise documentation after @lqd's comments

This commit is contained in:
Amanda Stjerna 2024-05-21 10:57:32 +02:00
parent e6eb63d4b9
commit 3bdcb9d436
2 changed files with 5 additions and 9 deletions

View file

@ -22,12 +22,9 @@ mod tests;
/// An annotation for an SCC. This can be a representative, /// An annotation for an SCC. This can be a representative,
/// the max/min element of the SCC, or all of the above. /// the max/min element of the SCC, or all of the above.
/// ///
/// Concretely, the following properties must hold (where `merge` /// Concretely, the both merge operations must commute, e.g. where `merge`
/// is `merge_scc` and `merge_reached`): /// is `merge_scc` and `merge_reached`: `a.merge(b) == b.merge(a)`
/// - idempotency: `a.merge(a) = a`
/// - commutativity: `a.merge(b) = b.merge(a)`
/// ///
/// This is rather limiting and precludes, for example, counting.
/// In general, what you want is probably always min/max according /// In general, what you want is probably always min/max according
/// to some ordering, potentially with side constraints (min x such /// to some ordering, potentially with side constraints (min x such
/// that P holds). /// that P holds).
@ -62,7 +59,7 @@ impl Annotation for () {
/// the index type for the graph nodes and `S` is the index type for /// the index type for the graph nodes and `S` is the index type for
/// the SCCs. We can map from each node to the SCC that it /// the SCCs. We can map from each node to the SCC that it
/// participates in, and we also have the successors of each SCC. /// participates in, and we also have the successors of each SCC.
pub struct Sccs<N: Idx, S: Idx, A: Annotation> { pub struct Sccs<N: Idx, S: Idx, A: Annotation = ()> {
/// For each node, what is the SCC index of the SCC to which it /// For each node, what is the SCC index of the SCC to which it
/// belongs. /// belongs.
scc_indices: IndexVec<N, S>, scc_indices: IndexVec<N, S>,
@ -314,8 +311,7 @@ where
/// D' (i.e., D' < D), we know that N, N', and all nodes in /// D' (i.e., D' < D), we know that N, N', and all nodes in
/// between them on the stack are part of an SCC. /// between them on the stack are part of an SCC.
/// ///
/// Additionally, we keep track of a representative annotation of the /// Additionally, we keep track of a current annotation of the SCC.
/// SCC.
/// ///
/// [wikipedia]: https://bit.ly/2EZIx84 /// [wikipedia]: https://bit.ly/2EZIx84
fn construct(graph: &'c G, to_annotation: F) -> Sccs<G::Node, S, A> { fn construct(graph: &'c G, to_annotation: F) -> Sccs<G::Node, S, A> {

View file

@ -360,7 +360,7 @@ struct MiniGraph<'tcx> {
/// Map from node index to SCC, and stores the successors of each SCC. All /// Map from node index to SCC, and stores the successors of each SCC. All
/// the regions in the same SCC are equal to one another, and if `S1 -> S2`, /// the regions in the same SCC are equal to one another, and if `S1 -> S2`,
/// then `S1: S2`. /// then `S1: S2`.
sccs: Sccs<LeakCheckNode, LeakCheckScc, ()>, sccs: Sccs<LeakCheckNode, LeakCheckScc>,
} }
impl<'tcx> MiniGraph<'tcx> { impl<'tcx> MiniGraph<'tcx> {