Skip to content

Commit 7205fc5

Browse files
committed
Auto merge of rust-lang#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.
2 parents ae3b909 + 98cdb82 commit 7205fc5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_infer/src/infer/outlives/obligations.rs

+8
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ impl<'tcx> InferCtxt<'tcx> {
9898
sub_region: Region<'tcx>,
9999
cause: &ObligationCause<'tcx>,
100100
) {
101+
// `is_global` means the type has no params, infer, placeholder, or non-`'static`
102+
// free regions. If the type has none of these things, then we can skip registering
103+
// this outlives obligation since it has no components which affect lifetime
104+
// checking in an interesting way.
105+
if sup_type.is_global() {
106+
return;
107+
}
108+
101109
debug!(?sup_type, ?sub_region, ?cause);
102110
let origin = SubregionOrigin::from_obligation_cause(cause, || {
103111
infer::RelateParamBound(

0 commit comments

Comments
 (0)