diff options
| author | lcnr <rust@lcnr.de> | 2025-08-19 14:10:22 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-08-25 11:29:29 +0200 |
| commit | 7ee5cf6087eff3555bf0c7517f42e99a9b1a47a5 (patch) | |
| tree | 3e69820621cb3cd9ca58b5b284784c23ef925e2a /compiler/rustc_middle/src | |
| parent | ee361e8fca1c30e13e7a31cc82b64c045339d3a8 (diff) | |
| download | rust-7ee5cf6087eff3555bf0c7517f42e99a9b1a47a5.tar.gz rust-7ee5cf6087eff3555bf0c7517f42e99a9b1a47a5.zip | |
fold regions, don't erase
erase regions also anonymizes bound vars, which is undesirable
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index a7298af502e..e567ba05f61 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -829,14 +829,15 @@ impl<'tcx> OpaqueHiddenType<'tcx> { // Convert the type from the function into a type valid outside by mapping generic // parameters to into the context of the opaque. // - // We erase regions when doing this during HIR typeck. + // We erase regions when doing this during HIR typeck. We manually use `fold_regions` + // here as we do not want to anonymize bound variables. let this = match defining_scope_kind { - DefiningScopeKind::HirTypeck => tcx.erase_regions(self), + DefiningScopeKind::HirTypeck => fold_regions(tcx, self, |_, _| tcx.lifetimes.re_erased), DefiningScopeKind::MirBorrowck => self, }; let result = this.fold_with(&mut opaque_types::ReverseMapper::new(tcx, map, self.span)); if cfg!(debug_assertions) && matches!(defining_scope_kind, DefiningScopeKind::HirTypeck) { - assert_eq!(result.ty, tcx.erase_regions(result.ty)); + assert_eq!(result.ty, fold_regions(tcx, result.ty, |_, _| tcx.lifetimes.re_erased)); } result } |
