@@ -12,10 +12,11 @@ use rustc::{
12
12
ty:: { AssocKind , GenericParamDef , GenericParamDefKind } ,
13
13
} ;
14
14
use std:: collections:: { BTreeSet , HashMap , HashSet , VecDeque } ;
15
+ use std:: hash:: { Hash , Hasher } ;
15
16
use syntax:: ast:: Name ;
16
17
17
18
/// A description of an item found in an inherent impl.
18
- #[ derive( Debug , PartialEq , Eq , Hash ) ]
19
+ #[ derive( Debug , PartialEq ) ]
19
20
pub struct InherentEntry {
20
21
/// The parent item's `DefId`.
21
22
pub parent_def_id : DefId ,
@@ -25,6 +26,36 @@ pub struct InherentEntry {
25
26
pub name : Name ,
26
27
}
27
28
29
+ impl Eq for InherentEntry { }
30
+
31
+ fn assert_impl_eq < T : Eq > ( ) { }
32
+
33
+ #[ allow( dead_code) ]
34
+ fn assert_inherent_entry_members_impl_eq ( ) {
35
+ assert_impl_eq :: < DefId > ( ) ;
36
+
37
+ // FIXME derive Eq again once AssocKind impls Eq again.
38
+ // assert_impl_eq::<AssocKind>();
39
+
40
+ assert_impl_eq :: < Name > ( ) ;
41
+ }
42
+
43
+ impl Hash for InherentEntry {
44
+ fn hash < H : Hasher > ( & self , hasher : & mut H ) {
45
+ self . parent_def_id . hash ( hasher) ;
46
+
47
+ // FIXME derive Hash again once AssocKind derives Hash again.
48
+ match self . kind {
49
+ AssocKind :: Const => 0u8 . hash ( hasher) ,
50
+ AssocKind :: Method => 1u8 . hash ( hasher) ,
51
+ AssocKind :: OpaqueTy => 2u8 . hash ( hasher) ,
52
+ AssocKind :: Type => 3u8 . hash ( hasher) ,
53
+ }
54
+
55
+ self . name . hash ( hasher) ;
56
+ }
57
+ }
58
+
28
59
/// A set of pairs of impl- and item `DefId`s for inherent associated items.
29
60
pub type InherentImplSet = BTreeSet < ( DefId , DefId ) > ;
30
61
0 commit comments