no subtyping in the new trait solver
This commit is contained in:
parent
685c32fd85
commit
34127c5080
@ -1,10 +1,10 @@
|
||||
use rustc_infer::infer::at::ToTrace;
|
||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use rustc_infer::infer::{InferCtxt, InferOk};
|
||||
use rustc_infer::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime};
|
||||
use rustc_infer::traits::query::NoSolution;
|
||||
use rustc_infer::traits::ObligationCause;
|
||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_middle::ty::{self, Ty, TypeFoldable};
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
use super::Goal;
|
||||
@ -26,12 +26,10 @@ pub(super) trait InferCtxtExt<'tcx> {
|
||||
rhs: T,
|
||||
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution>;
|
||||
|
||||
fn sup<T: ToTrace<'tcx>>(
|
||||
fn instantiate_bound_vars_with_infer<T: TypeFoldable<'tcx> + Copy>(
|
||||
&self,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
lhs: T,
|
||||
rhs: T,
|
||||
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution>;
|
||||
value: ty::Binder<'tcx, T>,
|
||||
) -> T;
|
||||
}
|
||||
|
||||
impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||
@ -67,22 +65,14 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self, param_env), ret)]
|
||||
fn sup<T: ToTrace<'tcx>>(
|
||||
fn instantiate_bound_vars_with_infer<T: TypeFoldable<'tcx> + Copy>(
|
||||
&self,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
lhs: T,
|
||||
rhs: T,
|
||||
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
|
||||
self.at(&ObligationCause::dummy(), param_env)
|
||||
.define_opaque_types(false)
|
||||
.sup(lhs, rhs)
|
||||
.map(|InferOk { value: (), obligations }| {
|
||||
obligations.into_iter().map(|o| o.into()).collect()
|
||||
})
|
||||
.map_err(|e| {
|
||||
debug!(?e, "failed to sup");
|
||||
NoSolution
|
||||
})
|
||||
value: ty::Binder<'tcx, T>,
|
||||
) -> T {
|
||||
self.replace_bound_vars_with_fresh_vars(
|
||||
DUMMY_SP,
|
||||
LateBoundRegionConversionTime::HigherRankedType,
|
||||
value,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use super::{Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::{InferCtxt, LateBoundRegionConversionTime};
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_infer::traits::query::NoSolution;
|
||||
use rustc_infer::traits::specialization_graph::LeafDef;
|
||||
use rustc_infer::traits::Reveal;
|
||||
@ -297,12 +297,9 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
||||
) -> QueryResult<'tcx> {
|
||||
if let Some(poly_projection_pred) = assumption.to_opt_poly_projection_pred() {
|
||||
ecx.infcx.probe(|_| {
|
||||
let assumption_projection_pred = ecx.infcx.replace_bound_vars_with_fresh_vars(
|
||||
DUMMY_SP,
|
||||
LateBoundRegionConversionTime::HigherRankedType,
|
||||
poly_projection_pred,
|
||||
);
|
||||
let nested_goals = ecx.infcx.sup(
|
||||
let assumption_projection_pred =
|
||||
ecx.infcx.instantiate_bound_vars_with_infer(poly_projection_pred);
|
||||
let nested_goals = ecx.infcx.eq(
|
||||
goal.param_env,
|
||||
goal.predicate.projection_ty,
|
||||
assumption_projection_pred.projection_ty,
|
||||
|
@ -10,8 +10,8 @@ use rustc_hir::{Movability, Mutability};
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_infer::traits::query::NoSolution;
|
||||
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
|
||||
use rustc_middle::ty::TraitPredicate;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{ToPolyTraitRef, TraitPredicate};
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
||||
@ -67,10 +67,12 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
||||
if let Some(poly_trait_pred) = assumption.to_opt_poly_trait_pred() {
|
||||
// FIXME: Constness and polarity
|
||||
ecx.infcx.probe(|_| {
|
||||
let nested_goals = ecx.infcx.sup(
|
||||
let assumption_trait_pred =
|
||||
ecx.infcx.instantiate_bound_vars_with_infer(poly_trait_pred);
|
||||
let nested_goals = ecx.infcx.eq(
|
||||
goal.param_env,
|
||||
ty::Binder::dummy(goal.predicate.trait_ref),
|
||||
poly_trait_pred.to_poly_trait_ref(),
|
||||
goal.predicate.trait_ref,
|
||||
assumption_trait_pred.trait_ref,
|
||||
)?;
|
||||
ecx.evaluate_all_and_make_canonical_response(nested_goals)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user