about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-05-18 08:56:48 +0000
committerbors <bors@rust-lang.org>2025-05-18 08:56:48 +0000
commit7205fc537d0fe8c3c2560b313e54fcb91ab6f3d1 (patch)
treeb048013a21b63182e0b01d2cf6d86f1234f44d9d /compiler
parentae3b909a323aa771db8ee3919c1454b77db05fbf (diff)
parent98cdb829a8e751a4fa82849bfe3195e3f0756e36 (diff)
downloadrust-7205fc537d0fe8c3c2560b313e54fcb91ab6f3d1.tar.gz
rust-7205fc537d0fe8c3c2560b313e54fcb91ab6f3d1.zip
Auto merge of #141129 - compiler-errors:register-region-obl, r=oli-obk
Fast path for `register_region_obligation`

If a type has no params, infer, placeholder, or non-`'static` free regions, then we can skip registering outlives obligations since the type has no components which affect lifetime checking in an interesting way.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_infer/src/infer/outlives/obligations.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs
index 8dde99c45cf..5fd98e35e5c 100644
--- a/compiler/rustc_infer/src/infer/outlives/obligations.rs
+++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs
@@ -98,6 +98,14 @@ impl<'tcx> InferCtxt<'tcx> {
         sub_region: Region<'tcx>,
         cause: &ObligationCause<'tcx>,
     ) {
+        // `is_global` means the type has no params, infer, placeholder, or non-`'static`
+        // free regions. If the type has none of these things, then we can skip registering
+        // this outlives obligation since it has no components which affect lifetime
+        // checking in an interesting way.
+        if sup_type.is_global() {
+            return;
+        }
+
         debug!(?sup_type, ?sub_region, ?cause);
         let origin = SubregionOrigin::from_obligation_cause(cause, || {
             infer::RelateParamBound(