Skip to content

Commit b1fe8d2

Browse files
committed
Remove caching from OpaqueTypeExpander. Fixes rust-lang#87450.
1 parent 0ded6ad commit b1fe8d2

File tree

1 file changed

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

1 file changed

+4
-14
lines changed

compiler/rustc_middle/src/ty/util.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::ty::{self, DebruijnIndex, DefIdTree, List, Ty, TyCtxt, TypeFoldable};
1111
use rustc_apfloat::Float as _;
1212
use rustc_ast as ast;
1313
use rustc_attr::{self as attr, SignedInt, UnsignedInt};
14-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
14+
use rustc_data_structures::fx::FxHashSet;
1515
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1616
use rustc_errors::ErrorReported;
1717
use rustc_hir as hir;
@@ -537,7 +537,6 @@ impl<'tcx> TyCtxt<'tcx> {
537537
) -> Result<Ty<'tcx>, Ty<'tcx>> {
538538
let mut visitor = OpaqueTypeExpander {
539539
seen_opaque_tys: FxHashSet::default(),
540-
expanded_cache: FxHashMap::default(),
541540
primary_def_id: Some(def_id),
542541
found_recursion: false,
543542
check_recursion: true,
@@ -557,7 +556,6 @@ struct OpaqueTypeExpander<'tcx> {
557556
seen_opaque_tys: FxHashSet<DefId>,
558557
// Cache of all expansions we've seen so far. This is a critical
559558
// optimization for some large types produced by async fn trees.
560-
expanded_cache: FxHashMap<(DefId, SubstsRef<'tcx>), Ty<'tcx>>,
561559
primary_def_id: Option<DefId>,
562560
found_recursion: bool,
563561
/// Whether or not to check for recursive opaque types.
@@ -574,16 +572,9 @@ impl<'tcx> OpaqueTypeExpander<'tcx> {
574572
}
575573
let substs = substs.fold_with(self);
576574
if !self.check_recursion || self.seen_opaque_tys.insert(def_id) {
577-
let expanded_ty = match self.expanded_cache.get(&(def_id, substs)) {
578-
Some(expanded_ty) => expanded_ty,
579-
None => {
580-
let generic_ty = self.tcx.type_of(def_id);
581-
let concrete_ty = generic_ty.subst(self.tcx, substs);
582-
let expanded_ty = self.fold_ty(concrete_ty);
583-
self.expanded_cache.insert((def_id, substs), expanded_ty);
584-
expanded_ty
585-
}
586-
};
575+
let generic_ty = self.tcx.type_of(def_id);
576+
let concrete_ty = generic_ty.subst(self.tcx, substs);
577+
let expanded_ty = self.fold_ty(concrete_ty);
587578
if self.check_recursion {
588579
self.seen_opaque_tys.remove(&def_id);
589580
}
@@ -1075,7 +1066,6 @@ pub fn normalize_opaque_types(
10751066
) -> &'tcx List<ty::Predicate<'tcx>> {
10761067
let mut visitor = OpaqueTypeExpander {
10771068
seen_opaque_tys: FxHashSet::default(),
1078-
expanded_cache: FxHashMap::default(),
10791069
primary_def_id: None,
10801070
found_recursion: false,
10811071
check_recursion: false,

0 commit comments

Comments
 (0)