Auto merge of #103590 - compiler-errors:ocx-more, r=lcnr
(almost) Always use `ObligationCtxt` when dealing with canonical queries Hope this is a step in the right direction. cc rust-lang/types-team#50. r? `@lcnr`
This commit is contained in:
commit
e70cbef0c5
10 changed files with 121 additions and 134 deletions
|
@ -290,10 +290,7 @@ fn compare_predicate_entailment<'tcx>(
|
|||
// type would be more appropriate. In other places we have a `Vec<Span>`
|
||||
// corresponding to their `Vec<Predicate>`, but we don't have that here.
|
||||
// Fixing this would improve the output of test `issue-83765.rs`.
|
||||
let mut result = infcx
|
||||
.at(&cause, param_env)
|
||||
.sup(trait_fty, impl_fty)
|
||||
.map(|infer_ok| ocx.register_infer_ok_obligations(infer_ok));
|
||||
let mut result = ocx.sup(&cause, param_env, trait_fty, impl_fty);
|
||||
|
||||
// HACK(RPITIT): #101614. When we are trying to infer the hidden types for
|
||||
// RPITITs, we need to equate the output tys instead of just subtyping. If
|
||||
|
@ -301,12 +298,8 @@ fn compare_predicate_entailment<'tcx>(
|
|||
// us to infer `_#1t = #'_#2r str`, where `'_#2r` is unconstrained, which gets
|
||||
// fixed up to `ReEmpty`, and which is certainly not what we want.
|
||||
if trait_fty.has_infer_types() {
|
||||
result = result.and_then(|()| {
|
||||
infcx
|
||||
.at(&cause, param_env)
|
||||
.eq(trait_sig.output(), impl_sig.output())
|
||||
.map(|infer_ok| ocx.register_infer_ok_obligations(infer_ok))
|
||||
});
|
||||
result =
|
||||
result.and_then(|()| ocx.eq(&cause, param_env, trait_sig.output(), impl_sig.output()));
|
||||
}
|
||||
|
||||
if let Err(terr) = result {
|
||||
|
@ -1389,10 +1382,7 @@ pub(crate) fn raw_compare_const_impl<'tcx>(
|
|||
|
||||
debug!("compare_const_impl: trait_ty={:?}", trait_ty);
|
||||
|
||||
let err = infcx
|
||||
.at(&cause, param_env)
|
||||
.sup(trait_ty, impl_ty)
|
||||
.map(|ok| ocx.register_infer_ok_obligations(ok));
|
||||
let err = ocx.sup(&cause, param_env, trait_ty, impl_ty);
|
||||
|
||||
if let Err(terr) = err {
|
||||
debug!(
|
||||
|
|
|
@ -1674,7 +1674,7 @@ fn receiver_is_valid<'tcx>(
|
|||
|
||||
// `self: Self` is always valid.
|
||||
if can_eq_self(receiver_ty) {
|
||||
if let Err(err) = wfcx.equate_types(&cause, wfcx.param_env, self_ty, receiver_ty) {
|
||||
if let Err(err) = wfcx.eq(&cause, wfcx.param_env, self_ty, receiver_ty) {
|
||||
infcx.err_ctxt().report_mismatched_types(&cause, self_ty, receiver_ty, err).emit();
|
||||
}
|
||||
return true;
|
||||
|
@ -1704,9 +1704,7 @@ fn receiver_is_valid<'tcx>(
|
|||
if can_eq_self(potential_self_ty) {
|
||||
wfcx.register_obligations(autoderef.into_obligations());
|
||||
|
||||
if let Err(err) =
|
||||
wfcx.equate_types(&cause, wfcx.param_env, self_ty, potential_self_ty)
|
||||
{
|
||||
if let Err(err) = wfcx.eq(&cause, wfcx.param_env, self_ty, potential_self_ty) {
|
||||
infcx
|
||||
.err_ctxt()
|
||||
.report_mismatched_types(&cause, self_ty, potential_self_ty, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue