1
Fork 0

Fold lifetimes before substitution.

This commit is contained in:
Camille GILLOT 2023-06-03 08:38:44 +00:00
parent 9450b75986
commit ff03204365

View file

@ -3115,12 +3115,11 @@ fn bind_generator_hidden_types_above<'tcx>(
.generator_hidden_types(def_id) .generator_hidden_types(def_id)
// Deduplicate tys to avoid repeated work. // Deduplicate tys to avoid repeated work.
.filter(|bty| seen_tys.insert(*bty)) .filter(|bty| seen_tys.insert(*bty))
.map(|bty| { .map(|mut bty| {
let mut ty = bty.instantiate(tcx, args);
// Only remap erased regions if we use them. // Only remap erased regions if we use them.
if considering_regions { if considering_regions {
ty = tcx.fold_regions(ty, |r, current_depth| match r.kind() { bty = bty.map_bound(|ty| {
tcx.fold_regions(ty, |r, current_depth| match r.kind() {
ty::ReErased => { ty::ReErased => {
let br = ty::BoundRegion { let br = ty::BoundRegion {
var: ty::BoundVar::from_u32(counter), var: ty::BoundVar::from_u32(counter),
@ -3131,9 +3130,10 @@ fn bind_generator_hidden_types_above<'tcx>(
} }
r => bug!("unexpected region: {r:?}"), r => bug!("unexpected region: {r:?}"),
}) })
})
} }
ty bty.instantiate(tcx, args)
}) })
.collect(); .collect();
if considering_regions { if considering_regions {