about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-06-03 08:38:44 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-09-23 13:15:15 +0000
commitff032043653e7aebfbf74ab59572f929aa2beb65 (patch)
tree62a46dc46359de924b9629f560d348e12b981e90
parent9450b75986571785b11d202e68af255a1780f68f (diff)
downloadrust-ff032043653e7aebfbf74ab59572f929aa2beb65.tar.gz
rust-ff032043653e7aebfbf74ab59572f929aa2beb65.zip
Fold lifetimes before substitution.
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/mod.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index dcf41c3774f..d4ca0c8a5c5 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -3115,25 +3115,25 @@ fn bind_generator_hidden_types_above<'tcx>(
         .generator_hidden_types(def_id)
         // Deduplicate tys to avoid repeated work.
         .filter(|bty| seen_tys.insert(*bty))
-        .map(|bty| {
-            let mut ty = bty.instantiate(tcx, args);
-
+        .map(|mut bty| {
             // Only remap erased regions if we use them.
             if considering_regions {
-                ty = tcx.fold_regions(ty, |r, current_depth| match r.kind() {
-                    ty::ReErased => {
-                        let br = ty::BoundRegion {
-                            var: ty::BoundVar::from_u32(counter),
-                            kind: ty::BrAnon(None),
-                        };
-                        counter += 1;
-                        ty::Region::new_late_bound(tcx, current_depth, br)
-                    }
-                    r => bug!("unexpected region: {r:?}"),
+                bty = bty.map_bound(|ty| {
+                    tcx.fold_regions(ty, |r, current_depth| match r.kind() {
+                        ty::ReErased => {
+                            let br = ty::BoundRegion {
+                                var: ty::BoundVar::from_u32(counter),
+                                kind: ty::BrAnon(None),
+                            };
+                            counter += 1;
+                            ty::Region::new_late_bound(tcx, current_depth, br)
+                        }
+                        r => bug!("unexpected region: {r:?}"),
+                    })
                 })
             }
 
-            ty
+            bty.instantiate(tcx, args)
         })
         .collect();
     if considering_regions {