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

Commit ad6977c

Browse files
committed
Fold lifetimes before substitution.
1 parent f53325e commit ad6977c

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
@@ -3114,25 +3114,25 @@ fn bind_generator_hidden_types_above<'tcx>(
31143114
.generator_hidden_types(def_id)
31153115
// Deduplicate tys to avoid repeated work.
31163116
.filter(|bty| seen_tys.insert(*bty))
3117-
.map(|bty| {
3118-
let mut ty = bty.instantiate(tcx, args);
3119-
3117+
.map(|mut bty| {
31203118
// Only remap erased regions if we use them.
31213119
if considering_regions {
3122-
ty = 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:?}"),
3120+
bty = bty.map_bound(|ty| {
3121+
tcx.fold_regions(ty, |r, current_depth| match r.kind() {
3122+
ty::ReErased => {
3123+
let br = ty::BoundRegion {
3124+
var: ty::BoundVar::from_u32(counter),
3125+
kind: ty::BrAnon(None),
3126+
};
3127+
counter += 1;
3128+
ty::Region::new_late_bound(tcx, current_depth, br)
3129+
}
3130+
r => bug!("unexpected region: {r:?}"),
3131+
})
31323132
})
31333133
}
31343134

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

0 commit comments

Comments
 (0)