@@ -2,7 +2,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
22use rustc_serialize:: Decoder ;
33use rustc_serialize:: { Decodable , Encodable } ;
44use std:: fmt;
5- use std:: hash;
65use std:: ops:: ControlFlow ;
76
87use crate :: fold:: { FallibleTypeFolder , TypeFoldable } ;
@@ -12,6 +11,8 @@ use crate::{TyDecoder, TyEncoder};
1211
1312/// A clause is something that can appear in where bounds or be inferred
1413/// by implied bounds.
14+ #[ derive( derivative:: Derivative ) ]
15+ #[ derivative( Clone ( bound = "" ) , PartialEq ( bound = "" ) , Eq ( bound = "" ) , Hash ( bound = "" ) ) ]
1516pub enum ClauseKind < I : Interner > {
1617 /// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
1718 /// the `Self` type of the trait reference and `A`, `B`, and `C`
@@ -39,20 +40,6 @@ pub enum ClauseKind<I: Interner> {
3940 ConstEvaluatable ( I :: Const ) ,
4041}
4142
42- impl < I : Interner > Clone for ClauseKind < I > {
43- fn clone ( & self ) -> Self {
44- match self {
45- Self :: Trait ( arg0) => Self :: Trait ( arg0. clone ( ) ) ,
46- Self :: RegionOutlives ( arg0) => Self :: RegionOutlives ( arg0. clone ( ) ) ,
47- Self :: TypeOutlives ( arg0) => Self :: TypeOutlives ( arg0. clone ( ) ) ,
48- Self :: Projection ( arg0) => Self :: Projection ( arg0. clone ( ) ) ,
49- Self :: ConstArgHasType ( arg0, arg1) => Self :: ConstArgHasType ( arg0. clone ( ) , arg1. clone ( ) ) ,
50- Self :: WellFormed ( arg0) => Self :: WellFormed ( arg0. clone ( ) ) ,
51- Self :: ConstEvaluatable ( arg0) => Self :: ConstEvaluatable ( arg0. clone ( ) ) ,
52- }
53- }
54- }
55-
5643impl < I : Interner > Copy for ClauseKind < I >
5744where
5845 I :: Ty : Copy ,
6552{
6653}
6754
68- impl < I : Interner > PartialEq for ClauseKind < I > {
69- fn eq ( & self , other : & Self ) -> bool {
70- match ( self , other) {
71- ( Self :: Trait ( l0) , Self :: Trait ( r0) ) => l0 == r0,
72- ( Self :: RegionOutlives ( l0) , Self :: RegionOutlives ( r0) ) => l0 == r0,
73- ( Self :: TypeOutlives ( l0) , Self :: TypeOutlives ( r0) ) => l0 == r0,
74- ( Self :: Projection ( l0) , Self :: Projection ( r0) ) => l0 == r0,
75- ( Self :: ConstArgHasType ( l0, l1) , Self :: ConstArgHasType ( r0, r1) ) => l0 == r0 && l1 == r1,
76- ( Self :: WellFormed ( l0) , Self :: WellFormed ( r0) ) => l0 == r0,
77- ( Self :: ConstEvaluatable ( l0) , Self :: ConstEvaluatable ( r0) ) => l0 == r0,
78- _ => false ,
79- }
80- }
81- }
82-
83- impl < I : Interner > Eq for ClauseKind < I > { }
84-
8555fn clause_kind_discriminant < I : Interner > ( value : & ClauseKind < I > ) -> usize {
8656 match value {
8757 ClauseKind :: Trait ( _) => 0 ,
@@ -94,24 +64,6 @@ fn clause_kind_discriminant<I: Interner>(value: &ClauseKind<I>) -> usize {
9464 }
9565}
9666
97- impl < I : Interner > hash:: Hash for ClauseKind < I > {
98- fn hash < H : hash:: Hasher > ( & self , state : & mut H ) {
99- clause_kind_discriminant ( self ) . hash ( state) ;
100- match self {
101- ClauseKind :: Trait ( p) => p. hash ( state) ,
102- ClauseKind :: RegionOutlives ( p) => p. hash ( state) ,
103- ClauseKind :: TypeOutlives ( p) => p. hash ( state) ,
104- ClauseKind :: Projection ( p) => p. hash ( state) ,
105- ClauseKind :: ConstArgHasType ( c, t) => {
106- c. hash ( state) ;
107- t. hash ( state) ;
108- }
109- ClauseKind :: WellFormed ( t) => t. hash ( state) ,
110- ClauseKind :: ConstEvaluatable ( c) => c. hash ( state) ,
111- }
112- }
113- }
114-
11567impl < CTX : HashStableContext , I : Interner > HashStable < CTX > for ClauseKind < I >
11668where
11769 I :: Ty : HashStable < CTX > ,
@@ -249,6 +201,8 @@ where
249201 }
250202}
251203
204+ #[ derive( derivative:: Derivative ) ]
205+ #[ derivative( Clone ( bound = "" ) , PartialEq ( bound = "" ) , Eq ( bound = "" ) , Hash ( bound = "" ) ) ]
252206pub enum PredicateKind < I : Interner > {
253207 /// Prove a clause
254208 Clause ( ClauseKind < I > ) ,
@@ -305,46 +259,6 @@ where
305259{
306260}
307261
308- impl < I : Interner > Clone for PredicateKind < I > {
309- fn clone ( & self ) -> Self {
310- match self {
311- Self :: Clause ( arg0) => Self :: Clause ( arg0. clone ( ) ) ,
312- Self :: ObjectSafe ( arg0) => Self :: ObjectSafe ( arg0. clone ( ) ) ,
313- Self :: ClosureKind ( arg0, arg1, arg2) => {
314- Self :: ClosureKind ( arg0. clone ( ) , arg1. clone ( ) , arg2. clone ( ) )
315- }
316- Self :: Subtype ( arg0) => Self :: Subtype ( arg0. clone ( ) ) ,
317- Self :: Coerce ( arg0) => Self :: Coerce ( arg0. clone ( ) ) ,
318- Self :: ConstEquate ( arg0, arg1) => Self :: ConstEquate ( arg0. clone ( ) , arg1. clone ( ) ) ,
319- Self :: Ambiguous => Self :: Ambiguous ,
320- Self :: AliasRelate ( arg0, arg1, arg2) => {
321- Self :: AliasRelate ( arg0. clone ( ) , arg1. clone ( ) , arg2. clone ( ) )
322- }
323- }
324- }
325- }
326-
327- impl < I : Interner > PartialEq for PredicateKind < I > {
328- fn eq ( & self , other : & Self ) -> bool {
329- match ( self , other) {
330- ( Self :: Clause ( l0) , Self :: Clause ( r0) ) => l0 == r0,
331- ( Self :: ObjectSafe ( l0) , Self :: ObjectSafe ( r0) ) => l0 == r0,
332- ( Self :: ClosureKind ( l0, l1, l2) , Self :: ClosureKind ( r0, r1, r2) ) => {
333- l0 == r0 && l1 == r1 && l2 == r2
334- }
335- ( Self :: Subtype ( l0) , Self :: Subtype ( r0) ) => l0 == r0,
336- ( Self :: Coerce ( l0) , Self :: Coerce ( r0) ) => l0 == r0,
337- ( Self :: ConstEquate ( l0, l1) , Self :: ConstEquate ( r0, r1) ) => l0 == r0 && l1 == r1,
338- ( Self :: AliasRelate ( l0, l1, l2) , Self :: AliasRelate ( r0, r1, r2) ) => {
339- l0 == r0 && l1 == r1 && l2 == r2
340- }
341- _ => core:: mem:: discriminant ( self ) == core:: mem:: discriminant ( other) ,
342- }
343- }
344- }
345-
346- impl < I : Interner > Eq for PredicateKind < I > { }
347-
348262fn predicate_kind_discriminant < I : Interner > ( value : & PredicateKind < I > ) -> usize {
349263 match value {
350264 PredicateKind :: Clause ( _) => 0 ,
@@ -358,33 +272,6 @@ fn predicate_kind_discriminant<I: Interner>(value: &PredicateKind<I>) -> usize {
358272 }
359273}
360274
361- impl < I : Interner > hash:: Hash for PredicateKind < I > {
362- fn hash < H : hash:: Hasher > ( & self , state : & mut H ) {
363- predicate_kind_discriminant ( self ) . hash ( state) ;
364- match self {
365- PredicateKind :: Clause ( p) => p. hash ( state) ,
366- PredicateKind :: ObjectSafe ( d) => d. hash ( state) ,
367- PredicateKind :: ClosureKind ( d, g, k) => {
368- d. hash ( state) ;
369- g. hash ( state) ;
370- k. hash ( state) ;
371- }
372- PredicateKind :: Subtype ( p) => p. hash ( state) ,
373- PredicateKind :: Coerce ( p) => p. hash ( state) ,
374- PredicateKind :: ConstEquate ( c1, c2) => {
375- c1. hash ( state) ;
376- c2. hash ( state) ;
377- }
378- PredicateKind :: Ambiguous => { }
379- PredicateKind :: AliasRelate ( t1, t2, r) => {
380- t1. hash ( state) ;
381- t2. hash ( state) ;
382- r. hash ( state) ;
383- }
384- }
385- }
386- }
387-
388275impl < CTX : HashStableContext , I : Interner > HashStable < CTX > for PredicateKind < I >
389276where
390277 I :: DefId : HashStable < CTX > ,
0 commit comments