@@ -12,10 +12,11 @@ use rustc::{
1212 ty:: { AssocKind , GenericParamDef , GenericParamDefKind } ,
1313} ;
1414use std:: collections:: { BTreeSet , HashMap , HashSet , VecDeque } ;
15+ use std:: hash:: { Hash , Hasher } ;
1516use syntax:: ast:: Name ;
1617
1718/// A description of an item found in an inherent impl.
18- #[ derive( Debug , PartialEq , Eq , Hash ) ]
19+ #[ derive( Debug , PartialEq ) ]
1920pub struct InherentEntry {
2021 /// The parent item's `DefId`.
2122 pub parent_def_id : DefId ,
@@ -25,6 +26,36 @@ pub struct InherentEntry {
2526 pub name : Name ,
2627}
2728
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+
2859/// A set of pairs of impl- and item `DefId`s for inherent associated items.
2960pub type InherentImplSet = BTreeSet < ( DefId , DefId ) > ;
3061
0 commit comments