1
Fork 0

Add roll back infrastructure for opaque type caches

This commit is contained in:
Oli Scherer 2021-08-13 17:19:26 +00:00 committed by Oli Scherer
parent dca1e7aa5a
commit d49b0746f6
10 changed files with 113 additions and 37 deletions

View file

@ -647,8 +647,7 @@ fn check_opaque_meets_bounds<'tcx>(
infcx.instantiate_opaque_types(hir_id, param_env, opaque_ty, span),
);
let opaque_type_map = infcx.inner.borrow().opaque_types.clone();
for (OpaqueTypeKey { def_id, substs }, opaque_defn) in opaque_type_map {
for (OpaqueTypeKey { def_id, substs }, opaque_defn) in infcx.opaque_types() {
let hidden_type = tcx.type_of(def_id).subst(tcx, substs);
trace!(?hidden_type);
match infcx.at(&misc_cause, param_env).eq(opaque_defn.concrete_ty, hidden_type) {

View file

@ -176,7 +176,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
.type_var_origin(ty)
.map(|origin| origin.span)
.unwrap_or(rustc_span::DUMMY_SP);
let oty = self.inner.borrow().opaque_types_vars.get(ty).copied();
let oty = self.inner.borrow().opaque_type_storage.get_opaque_type_for_infer_var(ty);
if let Some(opaque_ty) = oty {
debug!(
"fallback_opaque_type_vars(ty={:?}): falling back to opaque type {:?}",

View file

@ -498,8 +498,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
#[instrument(skip(self, span), level = "debug")]
fn visit_opaque_types(&mut self, span: Span) {
let opaque_types = self.fcx.infcx.inner.borrow().opaque_types.clone();
for (opaque_type_key, opaque_defn) in opaque_types {
for (opaque_type_key, opaque_defn) in self.fcx.infcx.opaque_types() {
let hir_id =
self.tcx().hir().local_def_id_to_hir_id(opaque_type_key.def_id.expect_local());
let instantiated_ty = self.resolve(opaque_defn.concrete_ty, &hir_id);