From 53effa4566dc1493e1dc5be206105dd99e3192b5 Mon Sep 17 00:00:00 2001 From: Amanda Stjerna Date: Tue, 18 Feb 2025 13:01:01 +0100 Subject: [PATCH] eval_outlives: bail out early if both regions are in the same SCC --- compiler/rustc_borrowck/src/region_infer/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index d2268c4779d6..e0e3e028c612 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1267,6 +1267,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { let sub_region_scc = self.constraint_sccs.scc(sub_region); let sup_region_scc = self.constraint_sccs.scc(sup_region); + if sub_region_scc == sup_region_scc { + debug!("{sup_region:?}: {sub_region:?} holds trivially; they are in the same SCC"); + return true; + } + // If we are checking that `'sup: 'sub`, and `'sub` contains // some placeholder that `'sup` cannot name, then this is only // true if `'sup` outlives static.