Skip to content

Commit 0eaa536

Browse files
Do process_registered_region_obligations in a loop
1 parent 65db28c commit 0eaa536

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

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

+22-16
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,28 @@ impl<'tcx> InferCtxt<'tcx> {
153153
.try_collect()
154154
.map_err(|e| (e, SubregionOrigin::AscribeUserTypeProvePredicate(DUMMY_SP)))?;
155155

156-
let my_region_obligations = self.take_registered_region_obligations();
157-
158-
for RegionObligation { sup_type, sub_region, origin } in my_region_obligations {
159-
let sup_type =
160-
deeply_normalize_ty(sup_type, origin.clone()).map_err(|e| (e, origin.clone()))?;
161-
debug!(?sup_type, ?sub_region, ?origin);
162-
163-
let outlives = &mut TypeOutlives::new(
164-
self,
165-
self.tcx,
166-
outlives_env.region_bound_pairs(),
167-
None,
168-
&normalized_caller_bounds,
169-
);
170-
let category = origin.to_constraint_category();
171-
outlives.type_must_outlive(origin, sup_type, sub_region, category);
156+
// Must loop since the process of normalizing may itself register region obligations.
157+
loop {
158+
let my_region_obligations = self.take_registered_region_obligations();
159+
if my_region_obligations.is_empty() {
160+
break;
161+
}
162+
163+
for RegionObligation { sup_type, sub_region, origin } in my_region_obligations {
164+
let sup_type = deeply_normalize_ty(sup_type, origin.clone())
165+
.map_err(|e| (e, origin.clone()))?;
166+
debug!(?sup_type, ?sub_region, ?origin);
167+
168+
let outlives = &mut TypeOutlives::new(
169+
self,
170+
self.tcx,
171+
outlives_env.region_bound_pairs(),
172+
None,
173+
&normalized_caller_bounds,
174+
);
175+
let category = origin.to_constraint_category();
176+
outlives.type_must_outlive(origin, sup_type, sub_region, category);
177+
}
172178
}
173179

174180
Ok(())

0 commit comments

Comments
 (0)