Skip to content

Commit 8cf5101

Browse files
committed
Auto merge of #125069 - amandasystems:scc-refactor, r=nikomatsakis
Extend SCC construction to enable extra functionality Do YOU feel like your SCC construction doesn't do enough? Then I have a patch for you! SCCs can now do *everything*! Well, almost. This patch has been extracted from #123720. It specifically enhances `Sccs` to allow tracking arbitrary commutative properties (think min/max mappings on nodes vs arbitrary closures) of strongly connected components, including - reachable values (max/min) - SCC-internal values (max/min) This helps with among other things universe computation. We can now identify SCC universes as a reasonably straightforward "find max/min" operation during SCC construction. This is also included in this patch. It's also more or less zero-cost; don't use the new features, don't pay for them. This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following. It may or may not have gotten easier to read for someone else. I believe this logic can also be used in leak check, but haven't checked. Ha. ha. Ha.
2 parents 8337ba9 + d63708b commit 8cf5101

File tree

5 files changed

+670
-337
lines changed

5 files changed

+670
-337
lines changed

Diff for: compiler/rustc_borrowck/src/constraints/mod.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
use rustc_data_structures::graph::scc::Sccs;
1+
use crate::type_check::Locations;
22
use rustc_index::{IndexSlice, IndexVec};
33
use rustc_middle::mir::ConstraintCategory;
44
use rustc_middle::ty::{RegionVid, TyCtxt, VarianceDiagInfo};
55
use rustc_span::Span;
66
use std::fmt;
77
use std::ops::Index;
88

9-
use crate::type_check::Locations;
10-
119
pub(crate) mod graph;
1210

1311
/// A set of NLL region constraints. These include "outlives"
@@ -45,18 +43,6 @@ impl<'tcx> OutlivesConstraintSet<'tcx> {
4543
graph::ConstraintGraph::new(graph::Reverse, self, num_region_vars)
4644
}
4745

48-
/// Computes cycles (SCCs) in the graph of regions. In particular,
49-
/// find all regions R1, R2 such that R1: R2 and R2: R1 and group
50-
/// them into an SCC, and find the relationships between SCCs.
51-
pub(crate) fn compute_sccs(
52-
&self,
53-
constraint_graph: &graph::NormalConstraintGraph,
54-
static_region: RegionVid,
55-
) -> Sccs<RegionVid, ConstraintSccIndex> {
56-
let region_graph = &constraint_graph.region_graph(self, static_region);
57-
Sccs::new(region_graph)
58-
}
59-
6046
pub(crate) fn outlives(
6147
&self,
6248
) -> &IndexSlice<OutlivesConstraintIndex, OutlivesConstraint<'tcx>> {

0 commit comments

Comments
 (0)