Skip to content

Commit 7ee5cf6

Browse files
committed
fold regions, don't erase
erase regions also anonymizes bound vars, which is undesirable
1 parent ee361e8 commit 7ee5cf6

File tree

1 file changed

+4
-3
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+4
-3
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,14 +829,15 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
829829
// Convert the type from the function into a type valid outside by mapping generic
830830
// parameters to into the context of the opaque.
831831
//
832-
// We erase regions when doing this during HIR typeck.
832+
// We erase regions when doing this during HIR typeck. We manually use `fold_regions`
833+
// here as we do not want to anonymize bound variables.
833834
let this = match defining_scope_kind {
834-
DefiningScopeKind::HirTypeck => tcx.erase_regions(self),
835+
DefiningScopeKind::HirTypeck => fold_regions(tcx, self, |_, _| tcx.lifetimes.re_erased),
835836
DefiningScopeKind::MirBorrowck => self,
836837
};
837838
let result = this.fold_with(&mut opaque_types::ReverseMapper::new(tcx, map, self.span));
838839
if cfg!(debug_assertions) && matches!(defining_scope_kind, DefiningScopeKind::HirTypeck) {
839-
assert_eq!(result.ty, tcx.erase_regions(result.ty));
840+
assert_eq!(result.ty, fold_regions(tcx, result.ty, |_, _| tcx.lifetimes.re_erased));
840841
}
841842
result
842843
}

0 commit comments

Comments
 (0)