@@ -2,7 +2,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2
2
use rustc_serialize:: Decoder ;
3
3
use rustc_serialize:: { Decodable , Encodable } ;
4
4
use std:: fmt;
5
- use std:: hash;
6
5
use std:: ops:: ControlFlow ;
7
6
8
7
use crate :: fold:: { FallibleTypeFolder , TypeFoldable } ;
@@ -12,6 +11,8 @@ use crate::{TyDecoder, TyEncoder};
12
11
13
12
/// A clause is something that can appear in where bounds or be inferred
14
13
/// by implied bounds.
14
+ #[ derive( derivative:: Derivative ) ]
15
+ #[ derivative( Clone ( bound = "" ) , Hash ( bound = "" ) ) ]
15
16
pub enum ClauseKind < I : Interner > {
16
17
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
17
18
/// the `Self` type of the trait reference and `A`, `B`, and `C`
@@ -39,20 +40,6 @@ pub enum ClauseKind<I: Interner> {
39
40
ConstEvaluatable ( I :: Const ) ,
40
41
}
41
42
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
-
56
43
impl < I : Interner > Copy for ClauseKind < I >
57
44
where
58
45
I :: Ty : Copy ,
@@ -94,24 +81,6 @@ fn clause_kind_discriminant<I: Interner>(value: &ClauseKind<I>) -> usize {
94
81
}
95
82
}
96
83
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
-
115
84
impl < CTX : HashStableContext , I : Interner > HashStable < CTX > for ClauseKind < I >
116
85
where
117
86
I :: Ty : HashStable < CTX > ,
@@ -249,6 +218,8 @@ where
249
218
}
250
219
}
251
220
221
+ #[ derive( derivative:: Derivative ) ]
222
+ #[ derivative( Clone ( bound = "" ) , Hash ( bound = "" ) ) ]
252
223
pub enum PredicateKind < I : Interner > {
253
224
/// Prove a clause
254
225
Clause ( ClauseKind < I > ) ,
@@ -305,25 +276,6 @@ where
305
276
{
306
277
}
307
278
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
279
impl < I : Interner > PartialEq for PredicateKind < I > {
328
280
fn eq ( & self , other : & Self ) -> bool {
329
281
match ( self , other) {
@@ -358,33 +310,6 @@ fn predicate_kind_discriminant<I: Interner>(value: &PredicateKind<I>) -> usize {
358
310
}
359
311
}
360
312
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
-
388
313
impl < CTX : HashStableContext , I : Interner > HashStable < CTX > for PredicateKind < I >
389
314
where
390
315
I :: DefId : HashStable < CTX > ,
0 commit comments