Remove redundant type ops
This commit is contained in:
parent
80eb5a8e91
commit
f264e5d011
@ -65,10 +65,9 @@
|
|||||||
};
|
};
|
||||||
use crate::traits::query::{
|
use crate::traits::query::{
|
||||||
CanonicalAliasGoal, CanonicalPredicateGoal, CanonicalTyGoal,
|
CanonicalAliasGoal, CanonicalPredicateGoal, CanonicalTyGoal,
|
||||||
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
|
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpNormalizeGoal,
|
||||||
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, DropckConstraint,
|
CanonicalTypeOpProvePredicateGoal, DropckConstraint, DropckOutlivesResult,
|
||||||
DropckOutlivesResult, MethodAutoderefStepsResult, NoSolution, NormalizationResult,
|
MethodAutoderefStepsResult, NoSolution, NormalizationResult, OutlivesBound,
|
||||||
OutlivesBound,
|
|
||||||
};
|
};
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
specialization_graph, CodegenObligationError, EvaluationResult, ImplSource,
|
specialization_graph, CodegenObligationError, EvaluationResult, ImplSource,
|
||||||
@ -2090,26 +2089,6 @@
|
|||||||
desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal.value.value }
|
desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal.value.value }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `Eq` type-op
|
|
||||||
query type_op_eq(
|
|
||||||
goal: CanonicalTypeOpEqGoal<'tcx>
|
|
||||||
) -> Result<
|
|
||||||
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
|
|
||||||
NoSolution,
|
|
||||||
> {
|
|
||||||
desc { "evaluating `type_op_eq` `{:?}`", goal.value.value }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `Subtype` type-op
|
|
||||||
query type_op_subtype(
|
|
||||||
goal: CanonicalTypeOpSubtypeGoal<'tcx>
|
|
||||||
) -> Result<
|
|
||||||
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
|
|
||||||
NoSolution,
|
|
||||||
> {
|
|
||||||
desc { "evaluating `type_op_subtype` `{:?}`", goal.value.value }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `ProvePredicate` type-op
|
/// Do not call this query directly: part of the `ProvePredicate` type-op
|
||||||
query type_op_prove_predicate(
|
query type_op_prove_predicate(
|
||||||
goal: CanonicalTypeOpProvePredicateGoal<'tcx>
|
goal: CanonicalTypeOpProvePredicateGoal<'tcx>
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
pub use rustc_middle::traits::query::type_op::Eq;
|
|
||||||
use rustc_middle::traits::query::NoSolution;
|
|
||||||
use rustc_middle::traits::ObligationCause;
|
|
||||||
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
|
|
||||||
|
|
||||||
use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
|
|
||||||
use crate::traits::ObligationCtxt;
|
|
||||||
|
|
||||||
impl<'tcx> super::QueryTypeOp<'tcx> for Eq<'tcx> {
|
|
||||||
type QueryResponse = ();
|
|
||||||
|
|
||||||
fn try_fast_path(
|
|
||||||
_tcx: TyCtxt<'tcx>,
|
|
||||||
key: &ParamEnvAnd<'tcx, Eq<'tcx>>,
|
|
||||||
) -> Option<Self::QueryResponse> {
|
|
||||||
if key.value.a == key.value.b { Some(()) } else { None }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn perform_query(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>,
|
|
||||||
) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
|
|
||||||
tcx.type_op_eq(canonicalized)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn perform_locally_with_next_solver(
|
|
||||||
ocx: &ObligationCtxt<'_, 'tcx>,
|
|
||||||
key: ParamEnvAnd<'tcx, Self>,
|
|
||||||
) -> Result<Self::QueryResponse, NoSolution> {
|
|
||||||
ocx.eq(&ObligationCause::dummy(), key.param_env, key.value.a, key.value.b)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,12 +16,10 @@
|
|||||||
|
|
||||||
pub mod ascribe_user_type;
|
pub mod ascribe_user_type;
|
||||||
pub mod custom;
|
pub mod custom;
|
||||||
pub mod eq;
|
|
||||||
pub mod implied_outlives_bounds;
|
pub mod implied_outlives_bounds;
|
||||||
pub mod normalize;
|
pub mod normalize;
|
||||||
pub mod outlives;
|
pub mod outlives;
|
||||||
pub mod prove_predicate;
|
pub mod prove_predicate;
|
||||||
pub mod subtype;
|
|
||||||
|
|
||||||
pub use rustc_middle::traits::query::type_op::*;
|
pub use rustc_middle::traits::query::type_op::*;
|
||||||
|
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
pub use rustc_middle::traits::query::type_op::Subtype;
|
|
||||||
use rustc_middle::traits::query::NoSolution;
|
|
||||||
use rustc_middle::traits::ObligationCause;
|
|
||||||
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
|
|
||||||
|
|
||||||
use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
|
|
||||||
use crate::traits::ObligationCtxt;
|
|
||||||
|
|
||||||
impl<'tcx> super::QueryTypeOp<'tcx> for Subtype<'tcx> {
|
|
||||||
type QueryResponse = ();
|
|
||||||
|
|
||||||
fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<()> {
|
|
||||||
if key.value.sub == key.value.sup { Some(()) } else { None }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn perform_query(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>,
|
|
||||||
) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
|
|
||||||
tcx.type_op_subtype(canonicalized)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn perform_locally_with_next_solver(
|
|
||||||
ocx: &ObligationCtxt<'_, 'tcx>,
|
|
||||||
key: ParamEnvAnd<'tcx, Self>,
|
|
||||||
) -> Result<Self::QueryResponse, NoSolution> {
|
|
||||||
ocx.sub(&ObligationCause::dummy(), key.param_env, key.value.sub, key.value.sup)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,18 +10,14 @@
|
|||||||
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{
|
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{
|
||||||
type_op_ascribe_user_type_with_span, AscribeUserType,
|
type_op_ascribe_user_type_with_span, AscribeUserType,
|
||||||
};
|
};
|
||||||
use rustc_trait_selection::traits::query::type_op::eq::Eq;
|
|
||||||
use rustc_trait_selection::traits::query::type_op::normalize::Normalize;
|
use rustc_trait_selection::traits::query::type_op::normalize::Normalize;
|
||||||
use rustc_trait_selection::traits::query::type_op::prove_predicate::ProvePredicate;
|
use rustc_trait_selection::traits::query::type_op::prove_predicate::ProvePredicate;
|
||||||
use rustc_trait_selection::traits::query::type_op::subtype::Subtype;
|
|
||||||
use rustc_trait_selection::traits::{Normalized, Obligation, ObligationCause, ObligationCtxt};
|
use rustc_trait_selection::traits::{Normalized, Obligation, ObligationCause, ObligationCtxt};
|
||||||
|
|
||||||
pub(crate) fn provide(p: &mut Providers) {
|
pub(crate) fn provide(p: &mut Providers) {
|
||||||
*p = Providers {
|
*p = Providers {
|
||||||
type_op_ascribe_user_type,
|
type_op_ascribe_user_type,
|
||||||
type_op_eq,
|
|
||||||
type_op_prove_predicate,
|
type_op_prove_predicate,
|
||||||
type_op_subtype,
|
|
||||||
type_op_normalize_ty,
|
type_op_normalize_ty,
|
||||||
type_op_normalize_clause,
|
type_op_normalize_clause,
|
||||||
type_op_normalize_fn_sig,
|
type_op_normalize_fn_sig,
|
||||||
@ -39,16 +35,6 @@ fn type_op_ascribe_user_type<'tcx>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_op_eq<'tcx>(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Eq<'tcx>>>,
|
|
||||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
|
||||||
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
|
|
||||||
let (param_env, Eq { a, b }) = key.into_parts();
|
|
||||||
Ok(ocx.eq(&ObligationCause::dummy(), param_env, a, b)?)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn type_op_normalize<'tcx, T>(
|
fn type_op_normalize<'tcx, T>(
|
||||||
ocx: &ObligationCtxt<'_, 'tcx>,
|
ocx: &ObligationCtxt<'_, 'tcx>,
|
||||||
key: ParamEnvAnd<'tcx, Normalize<T>>,
|
key: ParamEnvAnd<'tcx, Normalize<T>>,
|
||||||
@ -91,16 +77,6 @@ fn type_op_normalize_poly_fn_sig<'tcx>(
|
|||||||
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize)
|
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, type_op_normalize)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_op_subtype<'tcx>(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Subtype<'tcx>>>,
|
|
||||||
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
|
|
||||||
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |ocx, key| {
|
|
||||||
let (param_env, Subtype { sub, sup }) = key.into_parts();
|
|
||||||
Ok(ocx.sup(&ObligationCause::dummy(), param_env, sup, sub)?)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn type_op_prove_predicate<'tcx>(
|
fn type_op_prove_predicate<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
|
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
|
||||||
|
Loading…
Reference in New Issue
Block a user