Assert defining anchor is set in take_opaque_types
This commit is contained in:
parent
5132e13f13
commit
f769d34291
@ -318,7 +318,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||
|
||||
// This is still required for many(half of the tests in ui/type-alias-impl-trait)
|
||||
// tests to pass
|
||||
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
||||
let _ = infcx.take_opaque_types();
|
||||
|
||||
if errors.is_empty() {
|
||||
definition_ty
|
||||
|
@ -208,7 +208,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
||||
);
|
||||
|
||||
translate_outlives_facts(&mut checker);
|
||||
let opaque_type_values = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
||||
let opaque_type_values = infcx.take_opaque_types();
|
||||
|
||||
let opaque_type_values = opaque_type_values
|
||||
.into_iter()
|
||||
|
@ -58,6 +58,6 @@ pub fn is_subtype<'tcx>(
|
||||
// even if they're constrained in our current function.
|
||||
//
|
||||
// It seems very unlikely that this hides any bugs.
|
||||
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
||||
let _ = infcx.take_opaque_types();
|
||||
errors.is_empty()
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
||||
}
|
||||
}
|
||||
// Clean up after ourselves
|
||||
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
||||
let _ = infcx.take_opaque_types();
|
||||
}
|
||||
|
||||
fn is_enum_of_nonnullable_ptr<'tcx>(
|
||||
|
@ -534,8 +534,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn visit_opaque_types(&mut self) {
|
||||
let opaque_types =
|
||||
self.fcx.infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
||||
let opaque_types = self.fcx.infcx.take_opaque_types();
|
||||
for (opaque_type_key, decl) in opaque_types {
|
||||
let hidden_type = self.resolve(decl.hidden_type, &decl.hidden_type.span);
|
||||
let opaque_type_key = self.resolve(opaque_type_key, &decl.hidden_type.span);
|
||||
|
@ -156,10 +156,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
/// As the new solver does canonicalization slightly differently, this is also used there
|
||||
/// for now. This should hopefully change fairly soon.
|
||||
pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
|
||||
self.inner
|
||||
.borrow_mut()
|
||||
.opaque_type_storage
|
||||
.take_opaque_types()
|
||||
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
|
||||
.into_iter()
|
||||
.map(|(k, v)| (self.tcx.mk_opaque(k.def_id.to_def_id(), k.substs), v.hidden_type.ty))
|
||||
.collect()
|
||||
|
@ -1338,6 +1338,12 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
var_infos
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self), ret)]
|
||||
pub fn take_opaque_types(&self) -> opaque_types::OpaqueTypeMap<'tcx> {
|
||||
debug_assert_ne!(self.defining_use_anchor, DefiningAnchor::Error);
|
||||
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
|
||||
}
|
||||
|
||||
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
|
||||
self.resolve_vars_if_possible(t).to_string()
|
||||
}
|
||||
|
@ -29,11 +29,6 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", ret)]
|
||||
pub fn take_opaque_types(&mut self) -> OpaqueTypeMap<'tcx> {
|
||||
std::mem::take(&mut self.opaque_types)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn with_log<'a>(
|
||||
&'a mut self,
|
||||
|
@ -450,9 +450,6 @@ pub fn impossible_predicates<'tcx>(
|
||||
}
|
||||
let errors = ocx.select_all_or_error();
|
||||
|
||||
// Clean up after ourselves
|
||||
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
||||
|
||||
let result = !errors.is_empty();
|
||||
debug!("impossible_predicates = {:?}", result);
|
||||
result
|
||||
|
@ -82,7 +82,7 @@ pub fn codegen_select_candidate<'tcx>(
|
||||
// Opaque types may have gotten their hidden types constrained, but we can ignore them safely
|
||||
// as they will get constrained elsewhere, too.
|
||||
// (ouz-a) This is required for `type-alias-impl-trait/assoc-projection-ice.rs` to pass
|
||||
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
||||
let _ = infcx.take_opaque_types();
|
||||
|
||||
Ok(&*tcx.arena.alloc(impl_source))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user