1+ use crate :: HashStableContext ;
2+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
13use rustc_data_structures:: AtomicRef ;
24use rustc_index:: vec:: Idx ;
35use rustc_serialize:: { Decoder , Encoder } ;
@@ -18,15 +20,6 @@ pub enum CrateNum {
1820 Index ( CrateId ) ,
1921}
2022
21- impl :: std:: fmt:: Debug for CrateNum {
22- fn fmt ( & self , fmt : & mut :: std:: fmt:: Formatter < ' _ > ) -> :: std:: fmt:: Result {
23- match self {
24- CrateNum :: Index ( id) => write ! ( fmt, "crate{}" , id. private) ,
25- CrateNum :: ReservedForIncrCompCache => write ! ( fmt, "crate for decoding incr comp cache" ) ,
26- }
27- }
28- }
29-
3023/// Item definitions in the currently-compiled crate would have the `CrateNum`
3124/// `LOCAL_CRATE` in their `DefId`.
3225pub const LOCAL_CRATE : CrateNum = CrateNum :: Index ( CrateId :: from_u32_const ( 0 ) ) ;
@@ -100,6 +93,15 @@ impl rustc_serialize::UseSpecializedDecodable for CrateNum {
10093 }
10194}
10295
96+ impl :: std:: fmt:: Debug for CrateNum {
97+ fn fmt ( & self , fmt : & mut :: std:: fmt:: Formatter < ' _ > ) -> :: std:: fmt:: Result {
98+ match self {
99+ CrateNum :: Index ( id) => write ! ( fmt, "crate{}" , id. private) ,
100+ CrateNum :: ReservedForIncrCompCache => write ! ( fmt, "crate for decoding incr comp cache" ) ,
101+ }
102+ }
103+ }
104+
103105rustc_index:: newtype_index! {
104106 /// A DefIndex is an index into the hir-map for a crate, identifying a
105107 /// particular definition. It should really be considered an interned
@@ -207,3 +209,9 @@ impl fmt::Debug for LocalDefId {
207209
208210impl rustc_serialize:: UseSpecializedEncodable for LocalDefId { }
209211impl rustc_serialize:: UseSpecializedDecodable for LocalDefId { }
212+
213+ impl < CTX : HashStableContext > HashStable < CTX > for DefId {
214+ fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
215+ hcx. hash_def_id ( * self , hasher)
216+ }
217+ }
0 commit comments