about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-05-17 19:35:01 +0000
committerMichael Goulet <michael@errs.io>2025-05-17 19:35:05 +0000
commit98cdb829a8e751a4fa82849bfe3195e3f0756e36 (patch)
tree2a14548daeb52aafd4783a6e23538104d21fbfab
parentbf5a38d118a46fb5fdff90e3dc3cbb58fe618c46 (diff)
downloadrust-98cdb829a8e751a4fa82849bfe3195e3f0756e36.tar.gz
rust-98cdb829a8e751a4fa82849bfe3195e3f0756e36.zip
Fast path for register_region_obligation
-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(