Skip to content

Commit c0d7803

Browse files
committed
Fix replacement of escaping bound types
Multiple references to the same `BoundTy` were not using the same result.
1 parent e5992e7 commit c0d7803

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/librustc/ty/fold.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,18 +533,25 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
533533
G: FnMut(ty::BoundTy) -> ty::Ty<'tcx>,
534534
T: TypeFoldable<'tcx>
535535
{
536-
let mut map = BTreeMap::new();
536+
use rustc_data_structures::fx::FxHashMap;
537+
538+
let mut region_map = BTreeMap::new();
539+
let mut type_map = FxHashMap::default();
537540

538541
if !value.has_escaping_bound_vars() {
539-
(value.clone(), map)
542+
(value.clone(), region_map)
540543
} else {
541544
let mut real_fld_r = |br| {
542-
*map.entry(br).or_insert_with(|| fld_r(br))
545+
*region_map.entry(br).or_insert_with(|| fld_r(br))
546+
};
547+
548+
let mut real_fld_t = |bound_ty| {
549+
*type_map.entry(bound_ty).or_insert_with(|| fld_t(bound_ty))
543550
};
544551

545-
let mut replacer = BoundVarReplacer::new(self, &mut real_fld_r, &mut fld_t);
552+
let mut replacer = BoundVarReplacer::new(self, &mut real_fld_r, &mut real_fld_t);
546553
let result = value.fold_with(&mut replacer);
547-
(result, map)
554+
(result, region_map)
548555
}
549556
}
550557

0 commit comments

Comments
 (0)