Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ff03204

Browse files
committed
Fold lifetimes before substitution.
1 parent 9450b75 commit ff03204

File tree

1 file changed

+14
-14
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+14
-14
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,25 +3115,25 @@ fn bind_generator_hidden_types_above<'tcx>(
31153115
.generator_hidden_types(def_id)
31163116
// Deduplicate tys to avoid repeated work.
31173117
.filter(|bty| seen_tys.insert(*bty))
3118-
.map(|bty| {
3119-
let mut ty = bty.instantiate(tcx, args);
3120-
3118+
.map(|mut bty| {
31213119
// Only remap erased regions if we use them.
31223120
if considering_regions {
3123-
ty = tcx.fold_regions(ty, |r, current_depth| match r.kind() {
3124-
ty::ReErased => {
3125-
let br = ty::BoundRegion {
3126-
var: ty::BoundVar::from_u32(counter),
3127-
kind: ty::BrAnon(None),
3128-
};
3129-
counter += 1;
3130-
ty::Region::new_late_bound(tcx, current_depth, br)
3131-
}
3132-
r => bug!("unexpected region: {r:?}"),
3121+
bty = bty.map_bound(|ty| {
3122+
tcx.fold_regions(ty, |r, current_depth| match r.kind() {
3123+
ty::ReErased => {
3124+
let br = ty::BoundRegion {
3125+
var: ty::BoundVar::from_u32(counter),
3126+
kind: ty::BrAnon(None),
3127+
};
3128+
counter += 1;
3129+
ty::Region::new_late_bound(tcx, current_depth, br)
3130+
}
3131+
r => bug!("unexpected region: {r:?}"),
3132+
})
31333133
})
31343134
}
31353135

3136-
ty
3136+
bty.instantiate(tcx, args)
31373137
})
31383138
.collect();
31393139
if considering_regions {

0 commit comments

Comments
 (0)