Skip to content

Commit 35cba9e

Browse files
committed
Retire EnumLiftImpl.
1 parent 033d1df commit 35cba9e

File tree

5 files changed

+9
-126
lines changed

5 files changed

+9
-126
lines changed

src/librustc/macros.rs

-52
Original file line numberDiff line numberDiff line change
@@ -253,58 +253,6 @@ macro_rules! CloneTypeFoldableAndLiftImpls {
253253
}
254254
}
255255

256-
#[macro_export]
257-
macro_rules! EnumLiftImpl {
258-
(impl<$($p:tt),*> Lift<$tcx:tt> for $s:path {
259-
type Lifted = $lifted:ty;
260-
$($variants:tt)*
261-
} $(where $($wc:tt)*)*) => {
262-
impl<$($p),*> $crate::ty::Lift<$tcx> for $s
263-
$(where $($wc)*)*
264-
{
265-
type Lifted = $lifted;
266-
267-
fn lift_to_tcx(&self, tcx: TyCtxt<$tcx>) -> Option<$lifted> {
268-
EnumLiftImpl!(@Variants(self, tcx) input($($variants)*) output())
269-
}
270-
}
271-
};
272-
273-
(@Variants($this:expr, $tcx:expr) input() output($($output:tt)*)) => {
274-
match $this {
275-
$($output)*
276-
}
277-
};
278-
279-
(@Variants($this:expr, $tcx:expr)
280-
input( ($variant:path) ( $($variant_arg:ident),* ) , $($input:tt)*)
281-
output( $($output:tt)*) ) => {
282-
EnumLiftImpl!(
283-
@Variants($this, $tcx)
284-
input($($input)*)
285-
output(
286-
$variant ( $($variant_arg),* ) => {
287-
Some($variant ( $($tcx.lift($variant_arg)?),* ))
288-
}
289-
$($output)*
290-
)
291-
)
292-
};
293-
294-
(@Variants($this:expr, $tcx:expr)
295-
input( ($variant:path), $($input:tt)*)
296-
output( $($output:tt)*) ) => {
297-
EnumLiftImpl!(
298-
@Variants($this, $tcx)
299-
input($($input)*)
300-
output(
301-
$variant => { Some($variant) }
302-
$($output)*
303-
)
304-
)
305-
};
306-
}
307-
308256
#[macro_export]
309257
macro_rules! EnumTypeFoldableImpl {
310258
(impl<$($p:tt),*> TypeFoldable<$tcx:tt> for $s:path {

src/librustc/traits/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -334,27 +334,27 @@ pub type TraitObligations<'tcx> = Vec<TraitObligation<'tcx>>;
334334
/// are used for representing the trait system in the form of
335335
/// logic programming clauses. They are part of the interface
336336
/// for the chalk SLG solver.
337-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
337+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
338338
pub enum WhereClause<'tcx> {
339339
Implemented(ty::TraitPredicate<'tcx>),
340340
ProjectionEq(ty::ProjectionPredicate<'tcx>),
341341
RegionOutlives(ty::RegionOutlivesPredicate<'tcx>),
342342
TypeOutlives(ty::TypeOutlivesPredicate<'tcx>),
343343
}
344344

345-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
345+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
346346
pub enum WellFormed<'tcx> {
347347
Trait(ty::TraitPredicate<'tcx>),
348348
Ty(Ty<'tcx>),
349349
}
350350

351-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
351+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
352352
pub enum FromEnv<'tcx> {
353353
Trait(ty::TraitPredicate<'tcx>),
354354
Ty(Ty<'tcx>),
355355
}
356356

357-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
357+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
358358
pub enum DomainGoal<'tcx> {
359359
Holds(WhereClause<'tcx>),
360360
WellFormed(WellFormed<'tcx>),
@@ -370,7 +370,7 @@ pub enum QuantifierKind {
370370
Existential,
371371
}
372372

373-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable)]
373+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, TypeFoldable, Lift)]
374374
pub enum GoalKind<'tcx> {
375375
Implies(Clauses<'tcx>, Goal<'tcx>),
376376
And(Goal<'tcx>, Goal<'tcx>),

src/librustc/traits/query/outlives_bounds.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::hir;
44
use syntax::source_map::Span;
55
use crate::traits::{FulfillmentContext, ObligationCause, TraitEngine, TraitEngineExt};
66
use crate::traits::query::NoSolution;
7-
use crate::ty::{self, Ty, TyCtxt};
7+
use crate::ty::{self, Ty};
88

99
use crate::ich::StableHashingContext;
1010
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -17,22 +17,13 @@ use std::mem;
1717
/// case they are called implied bounds). They are fed to the
1818
/// `OutlivesEnv` which in turn is supplied to the region checker and
1919
/// other parts of the inference system.
20-
#[derive(Clone, Debug, TypeFoldable)]
20+
#[derive(Clone, Debug, TypeFoldable, Lift)]
2121
pub enum OutlivesBound<'tcx> {
2222
RegionSubRegion(ty::Region<'tcx>, ty::Region<'tcx>),
2323
RegionSubParam(ty::Region<'tcx>, ty::ParamTy),
2424
RegionSubProjection(ty::Region<'tcx>, ty::ProjectionTy<'tcx>),
2525
}
2626

27-
EnumLiftImpl! {
28-
impl<'a, 'tcx> Lift<'tcx> for self::OutlivesBound<'a> {
29-
type Lifted = self::OutlivesBound<'tcx>;
30-
(self::OutlivesBound::RegionSubRegion)(a, b),
31-
(self::OutlivesBound::RegionSubParam)(a, b),
32-
(self::OutlivesBound::RegionSubProjection)(a, b),
33-
}
34-
}
35-
3627
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for OutlivesBound<'tcx> {
3728
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
3829
mem::discriminant(self).hash_stable(hcx, hasher);

src/librustc/traits/structural_impls.rs

-49
Original file line numberDiff line numberDiff line change
@@ -650,55 +650,6 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
650650
}
651651
}
652652

653-
EnumLiftImpl! {
654-
impl<'a, 'tcx> Lift<'tcx> for traits::WhereClause<'a> {
655-
type Lifted = traits::WhereClause<'tcx>;
656-
(traits::WhereClause::Implemented)(trait_ref),
657-
(traits::WhereClause::ProjectionEq)(projection),
658-
(traits::WhereClause::TypeOutlives)(ty_outlives),
659-
(traits::WhereClause::RegionOutlives)(region_outlives),
660-
}
661-
}
662-
663-
EnumLiftImpl! {
664-
impl<'a, 'tcx> Lift<'tcx> for traits::WellFormed<'a> {
665-
type Lifted = traits::WellFormed<'tcx>;
666-
(traits::WellFormed::Trait)(trait_ref),
667-
(traits::WellFormed::Ty)(ty),
668-
}
669-
}
670-
671-
EnumLiftImpl! {
672-
impl<'a, 'tcx> Lift<'tcx> for traits::FromEnv<'a> {
673-
type Lifted = traits::FromEnv<'tcx>;
674-
(traits::FromEnv::Trait)(trait_ref),
675-
(traits::FromEnv::Ty)(ty),
676-
}
677-
}
678-
679-
EnumLiftImpl! {
680-
impl<'a, 'tcx> Lift<'tcx> for traits::DomainGoal<'a> {
681-
type Lifted = traits::DomainGoal<'tcx>;
682-
(traits::DomainGoal::Holds)(wc),
683-
(traits::DomainGoal::WellFormed)(wf),
684-
(traits::DomainGoal::FromEnv)(from_env),
685-
(traits::DomainGoal::Normalize)(projection),
686-
}
687-
}
688-
689-
EnumLiftImpl! {
690-
impl<'a, 'tcx> Lift<'tcx> for traits::GoalKind<'a> {
691-
type Lifted = traits::GoalKind<'tcx>;
692-
(traits::GoalKind::Implies)(hypotheses, goal),
693-
(traits::GoalKind::And)(goal1, goal2),
694-
(traits::GoalKind::Not)(goal),
695-
(traits::GoalKind::DomainGoal)(domain_goal),
696-
(traits::GoalKind::Quantified)(kind, goal),
697-
(traits::GoalKind::Subtype)(a, b),
698-
(traits::GoalKind::CannotProve),
699-
}
700-
}
701-
702653
impl<'a, 'tcx> Lift<'tcx> for traits::Environment<'a> {
703654
type Lifted = traits::Environment<'tcx>;
704655
fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {

src/librustc/ty/context.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ impl CanonicalUserType<'tcx> {
885885
/// A user-given type annotation attached to a constant. These arise
886886
/// from constants that are named via paths, like `Foo::<A>::new` and
887887
/// so forth.
888-
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
888+
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
889+
#[derive(HashStable, TypeFoldable, Lift)]
889890
pub enum UserType<'tcx> {
890891
Ty(Ty<'tcx>),
891892

@@ -894,14 +895,6 @@ pub enum UserType<'tcx> {
894895
TypeOf(DefId, UserSubsts<'tcx>),
895896
}
896897

897-
EnumLiftImpl! {
898-
impl<'a, 'tcx> Lift<'tcx> for UserType<'a> {
899-
type Lifted = UserType<'tcx>;
900-
(UserType::Ty)(ty),
901-
(UserType::TypeOf)(def, substs),
902-
}
903-
}
904-
905898
impl<'tcx> CommonTypes<'tcx> {
906899
fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> {
907900
let mk = |ty| interners.intern_ty(ty);

0 commit comments

Comments
 (0)