Retire EnumLiftImpl.
This commit is contained in:
parent
033d1df19b
commit
35cba9eb0b
5 changed files with 9 additions and 126 deletions
|
@ -253,58 +253,6 @@ macro_rules! CloneTypeFoldableAndLiftImpls {
|
|||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! EnumLiftImpl {
|
||||
(impl<$($p:tt),*> Lift<$tcx:tt> for $s:path {
|
||||
type Lifted = $lifted:ty;
|
||||
$($variants:tt)*
|
||||
} $(where $($wc:tt)*)*) => {
|
||||
impl<$($p),*> $crate::ty::Lift<$tcx> for $s
|
||||
$(where $($wc)*)*
|
||||
{
|
||||
type Lifted = $lifted;
|
||||
|
||||
fn lift_to_tcx(&self, tcx: TyCtxt<$tcx>) -> Option<$lifted> {
|
||||
EnumLiftImpl!(@Variants(self, tcx) input($($variants)*) output())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
(@Variants($this:expr, $tcx:expr) input() output($($output:tt)*)) => {
|
||||
match $this {
|
||||
$($output)*
|
||||
}
|
||||
};
|
||||
|
||||
(@Variants($this:expr, $tcx:expr)
|
||||
input( ($variant:path) ( $($variant_arg:ident),* ) , $($input:tt)*)
|
||||
output( $($output:tt)*) ) => {
|
||||
EnumLiftImpl!(
|
||||
@Variants($this, $tcx)
|
||||
input($($input)*)
|
||||
output(
|
||||
$variant ( $($variant_arg),* ) => {
|
||||
Some($variant ( $($tcx.lift($variant_arg)?),* ))
|
||||
}
|
||||
$($output)*
|
||||
)
|
||||
)
|
||||
};
|
||||
|
||||
(@Variants($this:expr, $tcx:expr)
|
||||
input( ($variant:path), $($input:tt)*)
|
||||
output( $($output:tt)*) ) => {
|
||||
EnumLiftImpl!(
|
||||
@Variants($this, $tcx)
|
||||
input($($input)*)
|
||||
output(
|
||||
$variant => { Some($variant) }
|
||||
$($output)*
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! EnumTypeFoldableImpl {
|
||||
(impl<$($p:tt),*> TypeFoldable<$tcx:tt> for $s:path {
|
||||
|
|
|
@ -334,7 +334,7 @@ pub type TraitObligations<'tcx> = Vec<TraitObligation<'tcx>>;
|
|||
/// are used for representing the trait system in the form of
|
||||
/// logic programming clauses. They are part of the interface
|
||||
/// for the chalk SLG solver.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
|
||||
pub enum WhereClause<'tcx> {
|
||||
Implemented(ty::TraitPredicate<'tcx>),
|
||||
ProjectionEq(ty::ProjectionPredicate<'tcx>),
|
||||
|
@ -342,19 +342,19 @@ pub enum WhereClause<'tcx> {
|
|||
TypeOutlives(ty::TypeOutlivesPredicate<'tcx>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
|
||||
pub enum WellFormed<'tcx> {
|
||||
Trait(ty::TraitPredicate<'tcx>),
|
||||
Ty(Ty<'tcx>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
|
||||
pub enum FromEnv<'tcx> {
|
||||
Trait(ty::TraitPredicate<'tcx>),
|
||||
Ty(Ty<'tcx>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
|
||||
pub enum DomainGoal<'tcx> {
|
||||
Holds(WhereClause<'tcx>),
|
||||
WellFormed(WellFormed<'tcx>),
|
||||
|
@ -370,7 +370,7 @@ pub enum QuantifierKind {
|
|||
Existential,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
|
||||
pub enum GoalKind<'tcx> {
|
||||
Implies(Clauses<'tcx>, Goal<'tcx>),
|
||||
And(Goal<'tcx>, Goal<'tcx>),
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::hir;
|
|||
use syntax::source_map::Span;
|
||||
use crate::traits::{FulfillmentContext, ObligationCause, TraitEngine, TraitEngineExt};
|
||||
use crate::traits::query::NoSolution;
|
||||
use crate::ty::{self, Ty, TyCtxt};
|
||||
use crate::ty::{self, Ty};
|
||||
|
||||
use crate::ich::StableHashingContext;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
|
@ -17,22 +17,13 @@ use std::mem;
|
|||
/// case they are called implied bounds). They are fed to the
|
||||
/// `OutlivesEnv` which in turn is supplied to the region checker and
|
||||
/// other parts of the inference system.
|
||||
#[derive(Clone, Debug, TypeFoldable)]
|
||||
#[derive(Clone, Debug, TypeFoldable, Lift)]
|
||||
pub enum OutlivesBound<'tcx> {
|
||||
RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>),
|
||||
RegionSubParam(ty::Region<'tcx>, ty::ParamTy),
|
||||
RegionSubProjection(ty::Region<'tcx>, ty::ProjectionTy<'tcx>),
|
||||
}
|
||||
|
||||
EnumLiftImpl! {
|
||||
impl<'a, 'tcx> Lift<'tcx> for self::OutlivesBound<'a> {
|
||||
type Lifted = self::OutlivesBound<'tcx>;
|
||||
(self::OutlivesBound::RegionSubRegion)(a, b),
|
||||
(self::OutlivesBound::RegionSubParam)(a, b),
|
||||
(self::OutlivesBound::RegionSubProjection)(a, b),
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for OutlivesBound<'tcx> {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
mem::discriminant(self).hash_stable(hcx, hasher);
|
||||
|
|
|
@ -650,55 +650,6 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
|
|||
}
|
||||
}
|
||||
|
||||
EnumLiftImpl! {
|
||||
impl<'a, 'tcx> Lift<'tcx> for traits::WhereClause<'a> {
|
||||
type Lifted = traits::WhereClause<'tcx>;
|
||||
(traits::WhereClause::Implemented)(trait_ref),
|
||||
(traits::WhereClause::ProjectionEq)(projection),
|
||||
(traits::WhereClause::TypeOutlives)(ty_outlives),
|
||||
(traits::WhereClause::RegionOutlives)(region_outlives),
|
||||
}
|
||||
}
|
||||
|
||||
EnumLiftImpl! {
|
||||
impl<'a, 'tcx> Lift<'tcx> for traits::WellFormed<'a> {
|
||||
type Lifted = traits::WellFormed<'tcx>;
|
||||
(traits::WellFormed::Trait)(trait_ref),
|
||||
(traits::WellFormed::Ty)(ty),
|
||||
}
|
||||
}
|
||||
|
||||
EnumLiftImpl! {
|
||||
impl<'a, 'tcx> Lift<'tcx> for traits::FromEnv<'a> {
|
||||
type Lifted = traits::FromEnv<'tcx>;
|
||||
(traits::FromEnv::Trait)(trait_ref),
|
||||
(traits::FromEnv::Ty)(ty),
|
||||
}
|
||||
}
|
||||
|
||||
EnumLiftImpl! {
|
||||
impl<'a, 'tcx> Lift<'tcx> for traits::DomainGoal<'a> {
|
||||
type Lifted = traits::DomainGoal<'tcx>;
|
||||
(traits::DomainGoal::Holds)(wc),
|
||||
(traits::DomainGoal::WellFormed)(wf),
|
||||
(traits::DomainGoal::FromEnv)(from_env),
|
||||
(traits::DomainGoal::Normalize)(projection),
|
||||
}
|
||||
}
|
||||
|
||||
EnumLiftImpl! {
|
||||
impl<'a, 'tcx> Lift<'tcx> for traits::GoalKind<'a> {
|
||||
type Lifted = traits::GoalKind<'tcx>;
|
||||
(traits::GoalKind::Implies)(hypotheses, goal),
|
||||
(traits::GoalKind::And)(goal1, goal2),
|
||||
(traits::GoalKind::Not)(goal),
|
||||
(traits::GoalKind::DomainGoal)(domain_goal),
|
||||
(traits::GoalKind::Quantified)(kind, goal),
|
||||
(traits::GoalKind::Subtype)(a, b),
|
||||
(traits::GoalKind::CannotProve),
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Lift<'tcx> for traits::Environment<'a> {
|
||||
type Lifted = traits::Environment<'tcx>;
|
||||
fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
|
|
|
@ -885,7 +885,8 @@ impl CanonicalUserType<'tcx> {
|
|||
/// A user-given type annotation attached to a constant. These arise
|
||||
/// from constants that are named via paths, like `Foo::<A>::new` and
|
||||
/// so forth.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
|
||||
#[derive(HashStable, TypeFoldable, Lift)]
|
||||
pub enum UserType<'tcx> {
|
||||
Ty(Ty<'tcx>),
|
||||
|
||||
|
@ -894,14 +895,6 @@ pub enum UserType<'tcx> {
|
|||
TypeOf(DefId, UserSubsts<'tcx>),
|
||||
}
|
||||
|
||||
EnumLiftImpl! {
|
||||
impl<'a, 'tcx> Lift<'tcx> for UserType<'a> {
|
||||
type Lifted = UserType<'tcx>;
|
||||
(UserType::Ty)(ty),
|
||||
(UserType::TypeOf)(def, substs),
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> CommonTypes<'tcx> {
|
||||
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
|
||||
let mk = |ty| interners.intern_ty(ty);
|
||||
|
|
Loading…
Add table
Reference in a new issue