Skip to content

Commit

Permalink
Do process_registered_region_obligations in a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jan 30, 2024
1 parent 65db28c commit 0eaa536
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,28 @@ impl<'tcx> InferCtxt<'tcx> {
.try_collect()
.map_err(|e| (e, SubregionOrigin::AscribeUserTypeProvePredicate(DUMMY_SP)))?;

let my_region_obligations = self.take_registered_region_obligations();

for RegionObligation { sup_type, sub_region, origin } in my_region_obligations {
let sup_type =
deeply_normalize_ty(sup_type, origin.clone()).map_err(|e| (e, origin.clone()))?;
debug!(?sup_type, ?sub_region, ?origin);

let outlives = &mut TypeOutlives::new(
self,
self.tcx,
outlives_env.region_bound_pairs(),
None,
&normalized_caller_bounds,
);
let category = origin.to_constraint_category();
outlives.type_must_outlive(origin, sup_type, sub_region, category);
// Must loop since the process of normalizing may itself register region obligations.
loop {
let my_region_obligations = self.take_registered_region_obligations();
if my_region_obligations.is_empty() {
break;
}

for RegionObligation { sup_type, sub_region, origin } in my_region_obligations {
let sup_type = deeply_normalize_ty(sup_type, origin.clone())
.map_err(|e| (e, origin.clone()))?;
debug!(?sup_type, ?sub_region, ?origin);

let outlives = &mut TypeOutlives::new(
self,
self.tcx,
outlives_env.region_bound_pairs(),
None,
&normalized_caller_bounds,
);
let category = origin.to_constraint_category();
outlives.type_must_outlive(origin, sup_type, sub_region, category);
}
}

Ok(())
Expand Down

0 comments on commit 0eaa536

Please sign in to comment.