Use SolverRelating in new solver
This commit is contained in:
parent
efb1c23ff6
commit
3da257a98d
9 changed files with 68 additions and 97 deletions
|
@ -208,49 +208,6 @@ impl<'a, 'tcx> At<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Used in the new solver since we don't care about tracking an `ObligationCause`.
|
||||
pub fn relate_no_trace<T>(
|
||||
self,
|
||||
expected: T,
|
||||
variance: ty::Variance,
|
||||
actual: T,
|
||||
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution>
|
||||
where
|
||||
T: Relate<TyCtxt<'tcx>>,
|
||||
{
|
||||
let mut op = TypeRelating::new(
|
||||
self.infcx,
|
||||
TypeTrace::dummy(self.cause),
|
||||
self.param_env,
|
||||
DefineOpaqueTypes::Yes,
|
||||
StructurallyRelateAliases::No,
|
||||
variance,
|
||||
);
|
||||
op.relate(expected, actual)?;
|
||||
Ok(op.into_obligations().into_iter().map(|o| o.into()).collect())
|
||||
}
|
||||
|
||||
/// Used in the new solver since we don't care about tracking an `ObligationCause`.
|
||||
pub fn eq_structurally_relating_aliases_no_trace<T>(
|
||||
self,
|
||||
expected: T,
|
||||
actual: T,
|
||||
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution>
|
||||
where
|
||||
T: Relate<TyCtxt<'tcx>>,
|
||||
{
|
||||
let mut op = TypeRelating::new(
|
||||
self.infcx,
|
||||
TypeTrace::dummy(self.cause),
|
||||
self.param_env,
|
||||
DefineOpaqueTypes::Yes,
|
||||
StructurallyRelateAliases::Yes,
|
||||
ty::Invariant,
|
||||
);
|
||||
op.relate(expected, actual)?;
|
||||
Ok(op.into_obligations().into_iter().map(|o| o.into()).collect())
|
||||
}
|
||||
|
||||
/// Computes the least-upper-bound, or mutual supertype, of two
|
||||
/// values. The order of the arguments doesn't matter, but since
|
||||
/// this can result in an error (e.g., if asked to compute LUB of
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::infer::unify_key::EffectVarValue;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::traits::solve::{Goal, NoSolution, SolverMode};
|
||||
use rustc_middle::traits::solve::SolverMode;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::relate::RelateResult;
|
||||
use rustc_middle::ty::relate::combine::PredicateEmittingRelation;
|
||||
use rustc_middle::ty::relate::{Relate, RelateResult};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::{DUMMY_SP, ErrorGuaranteed};
|
||||
|
||||
|
@ -210,26 +210,6 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
|
|||
self.set_tainted_by_errors(e)
|
||||
}
|
||||
|
||||
fn relate<T: Relate<TyCtxt<'tcx>>>(
|
||||
&self,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
lhs: T,
|
||||
variance: ty::Variance,
|
||||
rhs: T,
|
||||
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
|
||||
self.at(&ObligationCause::dummy(), param_env).relate_no_trace(lhs, variance, rhs)
|
||||
}
|
||||
|
||||
fn eq_structurally_relating_aliases<T: Relate<TyCtxt<'tcx>>>(
|
||||
&self,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
lhs: T,
|
||||
rhs: T,
|
||||
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
|
||||
self.at(&ObligationCause::dummy(), param_env)
|
||||
.eq_structurally_relating_aliases_no_trace(lhs, rhs)
|
||||
}
|
||||
|
||||
fn shallow_resolve(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
self.shallow_resolve(ty)
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ use rustc_middle::infer::unify_key::{
|
|||
use rustc_middle::mir::ConstraintCategory;
|
||||
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
|
||||
use rustc_middle::traits::select;
|
||||
use rustc_middle::traits::solve::{Goal, NoSolution};
|
||||
pub use rustc_middle::ty::IntVarValue;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::fold::{
|
||||
|
@ -340,7 +339,6 @@ pub enum ValuePairs<'tcx> {
|
|||
PolySigs(ExpectedFound<ty::PolyFnSig<'tcx>>),
|
||||
ExistentialTraitRef(ExpectedFound<ty::PolyExistentialTraitRef<'tcx>>),
|
||||
ExistentialProjection(ExpectedFound<ty::PolyExistentialProjection<'tcx>>),
|
||||
Dummy,
|
||||
}
|
||||
|
||||
impl<'tcx> ValuePairs<'tcx> {
|
||||
|
@ -1638,10 +1636,6 @@ impl<'tcx> TypeTrace<'tcx> {
|
|||
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
|
||||
}
|
||||
}
|
||||
|
||||
fn dummy(cause: &ObligationCause<'tcx>) -> TypeTrace<'tcx> {
|
||||
TypeTrace { cause: cause.clone(), values: ValuePairs::Dummy }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> SubregionOrigin<'tcx> {
|
||||
|
|
|
@ -6,7 +6,6 @@ pub use rustc_middle::ty::relate::RelateResult;
|
|||
pub use rustc_type_ir::relate::combine::PredicateEmittingRelation;
|
||||
pub use rustc_type_ir::relate::*;
|
||||
|
||||
#[allow(hidden_glob_reexports)]
|
||||
mod generalize;
|
||||
mod higher_ranked;
|
||||
pub(super) mod lattice;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue