1- #[ cfg( feature = "nightly" ) ]
2- use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
31use std:: fmt;
42use std:: ops:: ControlFlow ;
53
@@ -11,7 +9,7 @@ use crate::Interner;
119/// by implied bounds.
1210#[ derive( derivative:: Derivative ) ]
1311#[ derivative( Clone ( bound = "" ) , Hash ( bound = "" ) ) ]
14- #[ cfg_attr( feature = "nightly" , derive( TyEncodable , TyDecodable ) ) ]
12+ #[ cfg_attr( feature = "nightly" , derive( TyEncodable , TyDecodable , HashStable_NoContext ) ) ]
1513pub enum ClauseKind < I : Interner > {
1614 /// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
1715 /// the `Self` type of the trait reference and `A`, `B`, and `C`
@@ -68,47 +66,6 @@ impl<I: Interner> PartialEq for ClauseKind<I> {
6866
6967impl < I : Interner > Eq for ClauseKind < I > { }
7068
71- #[ cfg( feature = "nightly" ) ]
72- fn clause_kind_discriminant < I : Interner > ( value : & ClauseKind < I > ) -> usize {
73- match value {
74- ClauseKind :: Trait ( _) => 0 ,
75- ClauseKind :: RegionOutlives ( _) => 1 ,
76- ClauseKind :: TypeOutlives ( _) => 2 ,
77- ClauseKind :: Projection ( _) => 3 ,
78- ClauseKind :: ConstArgHasType ( _, _) => 4 ,
79- ClauseKind :: WellFormed ( _) => 5 ,
80- ClauseKind :: ConstEvaluatable ( _) => 6 ,
81- }
82- }
83-
84- #[ cfg( feature = "nightly" ) ]
85- impl < CTX : crate :: HashStableContext , I : Interner > HashStable < CTX > for ClauseKind < I >
86- where
87- I :: Ty : HashStable < CTX > ,
88- I :: Const : HashStable < CTX > ,
89- I :: GenericArg : HashStable < CTX > ,
90- I :: TraitPredicate : HashStable < CTX > ,
91- I :: ProjectionPredicate : HashStable < CTX > ,
92- I :: TypeOutlivesPredicate : HashStable < CTX > ,
93- I :: RegionOutlivesPredicate : HashStable < CTX > ,
94- {
95- fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
96- clause_kind_discriminant ( self ) . hash_stable ( hcx, hasher) ;
97- match self {
98- ClauseKind :: Trait ( p) => p. hash_stable ( hcx, hasher) ,
99- ClauseKind :: RegionOutlives ( p) => p. hash_stable ( hcx, hasher) ,
100- ClauseKind :: TypeOutlives ( p) => p. hash_stable ( hcx, hasher) ,
101- ClauseKind :: Projection ( p) => p. hash_stable ( hcx, hasher) ,
102- ClauseKind :: ConstArgHasType ( c, t) => {
103- c. hash_stable ( hcx, hasher) ;
104- t. hash_stable ( hcx, hasher) ;
105- }
106- ClauseKind :: WellFormed ( t) => t. hash_stable ( hcx, hasher) ,
107- ClauseKind :: ConstEvaluatable ( c) => c. hash_stable ( hcx, hasher) ,
108- }
109- }
110- }
111-
11269impl < I : Interner > TypeFoldable < I > for ClauseKind < I >
11370where
11471 I :: Ty : TypeFoldable < I > ,
@@ -164,7 +121,7 @@ where
164121
165122#[ derive( derivative:: Derivative ) ]
166123#[ derivative( Clone ( bound = "" ) , Hash ( bound = "" ) ) ]
167- #[ cfg_attr( feature = "nightly" , derive( TyEncodable , TyDecodable ) ) ]
124+ #[ cfg_attr( feature = "nightly" , derive( TyEncodable , TyDecodable , HashStable_NoContext ) ) ]
168125pub enum PredicateKind < I : Interner > {
169126 /// Prove a clause
170127 Clause ( ClauseKind < I > ) ,
@@ -242,58 +199,6 @@ impl<I: Interner> PartialEq for PredicateKind<I> {
242199
243200impl < I : Interner > Eq for PredicateKind < I > { }
244201
245- #[ cfg( feature = "nightly" ) ]
246- fn predicate_kind_discriminant < I : Interner > ( value : & PredicateKind < I > ) -> usize {
247- match value {
248- PredicateKind :: Clause ( _) => 0 ,
249- PredicateKind :: ObjectSafe ( _) => 1 ,
250- PredicateKind :: ClosureKind ( _, _, _) => 2 ,
251- PredicateKind :: Subtype ( _) => 3 ,
252- PredicateKind :: Coerce ( _) => 4 ,
253- PredicateKind :: ConstEquate ( _, _) => 5 ,
254- PredicateKind :: Ambiguous => 6 ,
255- PredicateKind :: AliasRelate ( _, _, _) => 7 ,
256- }
257- }
258-
259- #[ cfg( feature = "nightly" ) ]
260- impl < CTX : crate :: HashStableContext , I : Interner > HashStable < CTX > for PredicateKind < I >
261- where
262- I :: DefId : HashStable < CTX > ,
263- I :: Const : HashStable < CTX > ,
264- I :: GenericArgs : HashStable < CTX > ,
265- I :: Term : HashStable < CTX > ,
266- I :: CoercePredicate : HashStable < CTX > ,
267- I :: SubtypePredicate : HashStable < CTX > ,
268- I :: ClosureKind : HashStable < CTX > ,
269- ClauseKind < I > : HashStable < CTX > ,
270- {
271- fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
272- predicate_kind_discriminant ( self ) . hash_stable ( hcx, hasher) ;
273- match self {
274- PredicateKind :: Clause ( p) => p. hash_stable ( hcx, hasher) ,
275- PredicateKind :: ObjectSafe ( d) => d. hash_stable ( hcx, hasher) ,
276- PredicateKind :: ClosureKind ( d, g, k) => {
277- d. hash_stable ( hcx, hasher) ;
278- g. hash_stable ( hcx, hasher) ;
279- k. hash_stable ( hcx, hasher) ;
280- }
281- PredicateKind :: Subtype ( p) => p. hash_stable ( hcx, hasher) ,
282- PredicateKind :: Coerce ( p) => p. hash_stable ( hcx, hasher) ,
283- PredicateKind :: ConstEquate ( c1, c2) => {
284- c1. hash_stable ( hcx, hasher) ;
285- c2. hash_stable ( hcx, hasher) ;
286- }
287- PredicateKind :: Ambiguous => { }
288- PredicateKind :: AliasRelate ( t1, t2, r) => {
289- t1. hash_stable ( hcx, hasher) ;
290- t2. hash_stable ( hcx, hasher) ;
291- r. hash_stable ( hcx, hasher) ;
292- }
293- }
294- }
295- }
296-
297202impl < I : Interner > TypeFoldable < I > for PredicateKind < I >
298203where
299204 I :: DefId : TypeFoldable < I > ,
@@ -366,7 +271,7 @@ where
366271}
367272
368273#[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , Copy ) ]
369- #[ cfg_attr( feature = "nightly" , derive( HashStable_Generic , Encodable , Decodable ) ) ]
274+ #[ cfg_attr( feature = "nightly" , derive( HashStable_NoContext , Encodable , Decodable ) ) ]
370275pub enum AliasRelationDirection {
371276 Equate ,
372277 Subtype ,
0 commit comments