@@ -150,7 +150,7 @@ pub enum TyKind<'tcx> {
150
150
FnPtr ( PolyFnSig < ' tcx > ) ,
151
151
152
152
/// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`.
153
- Dynamic ( & ' tcx List < Binder < ' tcx , ExistentialPredicate < ' tcx > > > , ty:: Region < ' tcx > ) ,
153
+ Dynamic ( & ' tcx List < ExistentialPredicate < ' tcx > > , ty:: Region < ' tcx > ) ,
154
154
155
155
/// The anonymous type of a closure. Used to represent the type of
156
156
/// `|a| a`.
@@ -766,7 +766,7 @@ impl<'tcx> InlineConstSubsts<'tcx> {
766
766
767
767
#[ derive( Debug , Copy , Clone , PartialEq , PartialOrd , Ord , Eq , Hash , TyEncodable , TyDecodable ) ]
768
768
#[ derive( HashStable , TypeFoldable ) ]
769
- pub enum ExistentialPredicate < ' tcx > {
769
+ pub enum WhereClause < ' tcx > {
770
770
/// E.g., `Iterator`.
771
771
Trait ( ExistentialTraitRef < ' tcx > ) ,
772
772
/// E.g., `Iterator::Item = T`.
@@ -775,11 +775,13 @@ pub enum ExistentialPredicate<'tcx> {
775
775
AutoTrait ( DefId ) ,
776
776
}
777
777
778
- impl < ' tcx > ExistentialPredicate < ' tcx > {
778
+ pub type ExistentialPredicate < ' tcx > = Binder < ' tcx , WhereClause < ' tcx > > ;
779
+
780
+ impl < ' tcx > WhereClause < ' tcx > {
779
781
/// Compares via an ordering that will not change if modules are reordered or other changes are
780
782
/// made to the tree. In particular, this ordering is preserved across incremental compilations.
781
783
pub fn stable_cmp ( & self , tcx : TyCtxt < ' tcx > , other : & Self ) -> Ordering {
782
- use self :: ExistentialPredicate :: * ;
784
+ use WhereClause :: * ;
783
785
match ( * self , * other) {
784
786
( Trait ( _) , Trait ( _) ) => Ordering :: Equal ,
785
787
( Projection ( ref a) , Projection ( ref b) ) => {
@@ -796,17 +798,17 @@ impl<'tcx> ExistentialPredicate<'tcx> {
796
798
}
797
799
}
798
800
799
- impl < ' tcx > Binder < ' tcx , ExistentialPredicate < ' tcx > > {
801
+ impl < ' tcx > ExistentialPredicate < ' tcx > {
800
802
pub fn with_self_ty ( & self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> ty:: Predicate < ' tcx > {
801
803
use crate :: ty:: ToPredicate ;
802
804
match self . skip_binder ( ) {
803
- ExistentialPredicate :: Trait ( tr) => {
805
+ WhereClause :: Trait ( tr) => {
804
806
self . rebind ( tr) . with_self_ty ( tcx, self_ty) . without_const ( ) . to_predicate ( tcx)
805
807
}
806
- ExistentialPredicate :: Projection ( p) => {
808
+ WhereClause :: Projection ( p) => {
807
809
self . rebind ( p. with_self_ty ( tcx, self_ty) ) . to_predicate ( tcx)
808
810
}
809
- ExistentialPredicate :: AutoTrait ( did) => {
811
+ WhereClause :: AutoTrait ( did) => {
810
812
let trait_ref = self . rebind ( ty:: TraitRef {
811
813
def_id : did,
812
814
substs : tcx. mk_substs_trait ( self_ty, & [ ] ) ,
@@ -817,7 +819,7 @@ impl<'tcx> Binder<'tcx, ExistentialPredicate<'tcx>> {
817
819
}
818
820
}
819
821
820
- impl < ' tcx > List < ty :: Binder < ' tcx , ExistentialPredicate < ' tcx > > > {
822
+ impl < ' tcx > List < ExistentialPredicate < ' tcx > > {
821
823
/// Returns the "principal `DefId`" of this set of existential predicates.
822
824
///
823
825
/// A Rust trait object type consists (in addition to a lifetime bound)
@@ -846,7 +848,7 @@ impl<'tcx> List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
846
848
pub fn principal ( & self ) -> Option < ty:: Binder < ' tcx , ExistentialTraitRef < ' tcx > > > {
847
849
self [ 0 ]
848
850
. map_bound ( |this| match this {
849
- ExistentialPredicate :: Trait ( tr) => Some ( tr) ,
851
+ WhereClause :: Trait ( tr) => Some ( tr) ,
850
852
_ => None ,
851
853
} )
852
854
. transpose ( )
@@ -863,7 +865,7 @@ impl<'tcx> List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
863
865
self . iter ( ) . filter_map ( |predicate| {
864
866
predicate
865
867
. map_bound ( |pred| match pred {
866
- ExistentialPredicate :: Projection ( projection) => Some ( projection) ,
868
+ WhereClause :: Projection ( projection) => Some ( projection) ,
867
869
_ => None ,
868
870
} )
869
871
. transpose ( )
@@ -873,7 +875,7 @@ impl<'tcx> List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
873
875
#[ inline]
874
876
pub fn auto_traits < ' a > ( & ' a self ) -> impl Iterator < Item = DefId > + ' a {
875
877
self . iter ( ) . filter_map ( |predicate| match predicate. skip_binder ( ) {
876
- ExistentialPredicate :: AutoTrait ( did) => Some ( did) ,
878
+ WhereClause :: AutoTrait ( did) => Some ( did) ,
877
879
_ => None ,
878
880
} )
879
881
}
0 commit comments