mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Rollup merge of #106204 - compiler-errors:no-take-opaques-in-compare, r=oli-obk
No need to take opaques in `check_type_bounds` `InferCtxt` already has its defining use anchor set to err r? ``@oli-obk``
This commit is contained in:
commit
e5e116dca9
@ -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)
|
// This is still required for many(half of the tests in ui/type-alias-impl-trait)
|
||||||
// tests to pass
|
// tests to pass
|
||||||
let _ = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
let _ = infcx.take_opaque_types();
|
||||||
|
|
||||||
if errors.is_empty() {
|
if errors.is_empty() {
|
||||||
definition_ty
|
definition_ty
|
||||||
|
@ -209,7 +209,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
translate_outlives_facts(&mut checker);
|
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
|
let opaque_type_values = opaque_type_values
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -58,6 +58,6 @@ pub fn is_subtype<'tcx>(
|
|||||||
// even if they're constrained in our current function.
|
// even if they're constrained in our current function.
|
||||||
//
|
//
|
||||||
// It seems very unlikely that this hides any bugs.
|
// 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()
|
errors.is_empty()
|
||||||
}
|
}
|
||||||
|
@ -475,7 +475,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Clean up after ourselves
|
// 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>(
|
fn is_enum_of_nonnullable_ptr<'tcx>(
|
||||||
|
@ -424,7 +424,7 @@ fn compare_asyncness<'tcx>(
|
|||||||
ty::Alias(ty::Opaque, ..) => {
|
ty::Alias(ty::Opaque, ..) => {
|
||||||
// allow both `async fn foo()` and `fn foo() -> impl Future`
|
// allow both `async fn foo()` and `fn foo() -> impl Future`
|
||||||
}
|
}
|
||||||
ty::Error(rustc_errors::ErrorGuaranteed { .. }) => {
|
ty::Error(_) => {
|
||||||
// We don't know if it's ok, but at least it's already an error.
|
// We don't know if it's ok, but at least it's already an error.
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -1972,22 +1972,6 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||||||
&outlives_environment,
|
&outlives_environment,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let constraints = infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
|
||||||
for (key, value) in constraints {
|
|
||||||
infcx
|
|
||||||
.err_ctxt()
|
|
||||||
.report_mismatched_types(
|
|
||||||
&ObligationCause::misc(
|
|
||||||
value.hidden_type.span,
|
|
||||||
tcx.hir().local_def_id_to_hir_id(impl_ty.def_id.expect_local()),
|
|
||||||
),
|
|
||||||
tcx.mk_opaque(key.def_id.to_def_id(), key.substs),
|
|
||||||
value.hidden_type.ty,
|
|
||||||
TypeError::Mismatch,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,8 +534,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||||||
|
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
fn visit_opaque_types(&mut self) {
|
fn visit_opaque_types(&mut self) {
|
||||||
let opaque_types =
|
let opaque_types = self.fcx.infcx.take_opaque_types();
|
||||||
self.fcx.infcx.inner.borrow_mut().opaque_type_storage.take_opaque_types();
|
|
||||||
for (opaque_type_key, decl) in opaque_types {
|
for (opaque_type_key, decl) in opaque_types {
|
||||||
let hidden_type = self.resolve(decl.hidden_type, &decl.hidden_type.span);
|
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);
|
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
|
/// As the new solver does canonicalization slightly differently, this is also used there
|
||||||
/// for now. This should hopefully change fairly soon.
|
/// for now. This should hopefully change fairly soon.
|
||||||
pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
|
pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
|
||||||
self.inner
|
std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
|
||||||
.borrow_mut()
|
|
||||||
.opaque_type_storage
|
|
||||||
.take_opaque_types()
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(k, v)| (self.tcx.mk_opaque(k.def_id.to_def_id(), k.substs), v.hidden_type.ty))
|
.map(|(k, v)| (self.tcx.mk_opaque(k.def_id.to_def_id(), k.substs), v.hidden_type.ty))
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -1338,6 +1338,12 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
var_infos
|
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 {
|
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
|
||||||
self.resolve_vars_if_possible(t).to_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]
|
#[inline]
|
||||||
pub(crate) fn with_log<'a>(
|
pub(crate) fn with_log<'a>(
|
||||||
&'a mut self,
|
&'a mut self,
|
||||||
|
@ -450,9 +450,6 @@ pub fn impossible_predicates<'tcx>(
|
|||||||
}
|
}
|
||||||
let errors = ocx.select_all_or_error();
|
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();
|
let result = !errors.is_empty();
|
||||||
debug!("impossible_predicates = {:?}", result);
|
debug!("impossible_predicates = {:?}", result);
|
||||||
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
|
// Opaque types may have gotten their hidden types constrained, but we can ignore them safely
|
||||||
// as they will get constrained elsewhere, too.
|
// as they will get constrained elsewhere, too.
|
||||||
// (ouz-a) This is required for `type-alias-impl-trait/assoc-projection-ice.rs` to pass
|
// (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))
|
Ok(&*tcx.arena.alloc(impl_source))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user