Address some more nits
This commit is contained in:
parent
d793d80cf7
commit
ce11ae5d0d
@ -290,10 +290,7 @@ fn compare_predicate_entailment<'tcx>(
|
|||||||
// type would be more appropriate. In other places we have a `Vec<Span>`
|
// 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.
|
// corresponding to their `Vec<Predicate>`, but we don't have that here.
|
||||||
// Fixing this would improve the output of test `issue-83765.rs`.
|
// Fixing this would improve the output of test `issue-83765.rs`.
|
||||||
let mut result = infcx
|
let mut result = ocx.sup_types(&cause, param_env, trait_fty, impl_fty);
|
||||||
.at(&cause, param_env)
|
|
||||||
.sup(trait_fty, impl_fty)
|
|
||||||
.map(|infer_ok| ocx.register_infer_ok_obligations(infer_ok));
|
|
||||||
|
|
||||||
// HACK(RPITIT): #101614. When we are trying to infer the hidden types for
|
// 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
|
// RPITITs, we need to equate the output tys instead of just subtyping. If
|
||||||
@ -302,10 +299,7 @@ fn compare_predicate_entailment<'tcx>(
|
|||||||
// fixed up to `ReEmpty`, and which is certainly not what we want.
|
// fixed up to `ReEmpty`, and which is certainly not what we want.
|
||||||
if trait_fty.has_infer_types() {
|
if trait_fty.has_infer_types() {
|
||||||
result = result.and_then(|()| {
|
result = result.and_then(|()| {
|
||||||
infcx
|
ocx.equate_types(&cause, param_env, trait_sig.output(), impl_sig.output())
|
||||||
.at(&cause, param_env)
|
|
||||||
.eq(trait_sig.output(), impl_sig.output())
|
|
||||||
.map(|infer_ok| ocx.register_infer_ok_obligations(infer_ok))
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1389,10 +1383,7 @@ pub(crate) fn raw_compare_const_impl<'tcx>(
|
|||||||
|
|
||||||
debug!("compare_const_impl: trait_ty={:?}", trait_ty);
|
debug!("compare_const_impl: trait_ty={:?}", trait_ty);
|
||||||
|
|
||||||
let err = infcx
|
let err = ocx.sup_types(&cause, param_env, trait_ty, impl_ty);
|
||||||
.at(&cause, param_env)
|
|
||||||
.sup(trait_ty, impl_ty)
|
|
||||||
.map(|ok| ocx.register_infer_ok_obligations(ok));
|
|
||||||
|
|
||||||
if let Err(terr) = err {
|
if let Err(terr) = err {
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -6,6 +6,7 @@ use super::{ChalkFulfillmentContext, FulfillmentContext};
|
|||||||
use crate::infer::InferCtxtExt;
|
use crate::infer::InferCtxtExt;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
|
use rustc_infer::infer::at::ToTrace;
|
||||||
use rustc_infer::infer::canonical::{
|
use rustc_infer::infer::canonical::{
|
||||||
Canonical, CanonicalVarValues, CanonicalizedQueryResponse, QueryResponse,
|
Canonical, CanonicalVarValues, CanonicalizedQueryResponse, QueryResponse,
|
||||||
};
|
};
|
||||||
@ -111,12 +112,12 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
|
|||||||
self.register_infer_ok_obligations(infer_ok)
|
self.register_infer_ok_obligations(infer_ok)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn equate_types(
|
pub fn equate_types<T: ToTrace<'tcx>>(
|
||||||
&self,
|
&self,
|
||||||
cause: &ObligationCause<'tcx>,
|
cause: &ObligationCause<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
expected: Ty<'tcx>,
|
expected: T,
|
||||||
actual: Ty<'tcx>,
|
actual: T,
|
||||||
) -> Result<(), TypeError<'tcx>> {
|
) -> Result<(), TypeError<'tcx>> {
|
||||||
match self.infcx.at(cause, param_env).eq(expected, actual) {
|
match self.infcx.at(cause, param_env).eq(expected, actual) {
|
||||||
Ok(InferOk { obligations, value: () }) => {
|
Ok(InferOk { obligations, value: () }) => {
|
||||||
@ -127,6 +128,22 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn sup_types<T: ToTrace<'tcx>>(
|
||||||
|
&self,
|
||||||
|
cause: &ObligationCause<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
|
expected: T,
|
||||||
|
actual: T,
|
||||||
|
) -> Result<(), TypeError<'tcx>> {
|
||||||
|
match self.infcx.at(cause, param_env).sup(expected, actual) {
|
||||||
|
Ok(InferOk { obligations, value: () }) => {
|
||||||
|
self.register_obligations(obligations);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn select_all_or_error(&self) -> Vec<FulfillmentError<'tcx>> {
|
pub fn select_all_or_error(&self) -> Vec<FulfillmentError<'tcx>> {
|
||||||
self.engine.borrow_mut().select_all_or_error(self.infcx)
|
self.engine.borrow_mut().select_all_or_error(self.infcx)
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,7 @@ impl<'me, 'tcx> AscribeUserTypeCx<'me, 'tcx> {
|
|||||||
where
|
where
|
||||||
T: ToTrace<'tcx>,
|
T: ToTrace<'tcx>,
|
||||||
{
|
{
|
||||||
Ok(self.ocx.register_infer_ok_obligations(
|
Ok(self.ocx.equate_types(&ObligationCause::dummy_with_span(self.span), self.param_env, a, b)?)
|
||||||
self.ocx
|
|
||||||
.infcx
|
|
||||||
.at(&ObligationCause::dummy_with_span(self.span), self.param_env)
|
|
||||||
.eq(a, b)?,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prove_predicate(&self, predicate: Predicate<'tcx>, cause: ObligationCause<'tcx>) {
|
fn prove_predicate(&self, predicate: Predicate<'tcx>, cause: ObligationCause<'tcx>) {
|
||||||
@ -181,10 +176,7 @@ fn type_op_eq<'tcx>(
|
|||||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
||||||
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
|
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
|
||||||
let (param_env, Eq { a, b }) = key.into_parts();
|
let (param_env, Eq { a, b }) = key.into_parts();
|
||||||
ocx.register_infer_ok_obligations(
|
Ok(ocx.equate_types(&ObligationCause::dummy(), param_env, a, b)?)
|
||||||
ocx.infcx.at(&ObligationCause::dummy(), param_env).eq(a, b)?,
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,10 +228,7 @@ fn type_op_subtype<'tcx>(
|
|||||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
||||||
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
|
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
|
||||||
let (param_env, Subtype { sub, sup }) = key.into_parts();
|
let (param_env, Subtype { sub, sup }) = key.into_parts();
|
||||||
ocx.register_infer_ok_obligations(
|
Ok(ocx.sup_types(&ObligationCause::dummy(), param_env, sup, sub)?)
|
||||||
ocx.infcx.at(&ObligationCause::dummy(), param_env).sup(sup, sub)?,
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user