Skip to content

Commit cf8d342

Browse files
authored
Rollup merge of #137216 - amandasystems:cheap-outlives-eval, r=compiler-errors
eval_outlives: bail out early if both regions are in the same SCC A drive-by optimisation of region outlives evaluation: if we are evaluating whether an outlives holds for two regions, bail out early if they are both in the same SCC. This probably won't make a huge difference, but the cost is one comparison of SCC indices (integers). May want a perf run, depending on how confident whomever reviewing this is!
2 parents 34535b6 + 53effa4 commit cf8d342

File tree

1 file changed

+5
-0
lines changed
  • compiler/rustc_borrowck/src/region_infer

1 file changed

+5
-0
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12671267
let sub_region_scc = self.constraint_sccs.scc(sub_region);
12681268
let sup_region_scc = self.constraint_sccs.scc(sup_region);
12691269

1270+
if sub_region_scc == sup_region_scc {
1271+
debug!("{sup_region:?}: {sub_region:?} holds trivially; they are in the same SCC");
1272+
return true;
1273+
}
1274+
12701275
// If we are checking that `'sup: 'sub`, and `'sub` contains
12711276
// some placeholder that `'sup` cannot name, then this is only
12721277
// true if `'sup` outlives static.

0 commit comments

Comments
 (0)