@@ -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 = "" ) , 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 ,
@@ -94,24 +81,6 @@ fn clause_kind_discriminant<I: Interner>(value: &ClauseKind<I>) -> usize {
9481 }
9582}
9683
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-
11584impl < CTX : HashStableContext , I : Interner > HashStable < CTX > for ClauseKind < I >
11685where
11786 I :: Ty : HashStable < CTX > ,
@@ -249,6 +218,8 @@ where
249218 }
250219}
251220
221+ #[ derive( derivative:: Derivative ) ]
222+ #[ derivative( Clone ( bound = "" ) , Hash ( bound = "" ) ) ]
252223pub enum PredicateKind < I : Interner > {
253224 /// Prove a clause
254225 Clause ( ClauseKind < I > ) ,
@@ -305,25 +276,6 @@ where
305276{
306277}
307278
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-
327279impl < I : Interner > PartialEq for PredicateKind < I > {
328280 fn eq ( & self , other : & Self ) -> bool {
329281 match ( self , other) {
@@ -358,33 +310,6 @@ fn predicate_kind_discriminant<I: Interner>(value: &PredicateKind<I>) -> usize {
358310 }
359311}
360312
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-
388313impl < CTX : HashStableContext , I : Interner > HashStable < CTX > for PredicateKind < I >
389314where
390315 I :: DefId : HashStable < CTX > ,
0 commit comments