@@ -36,7 +36,7 @@ use util::nodemap::NodeMap;
3636pub struct DefPathTable {
3737 index_to_key : [ Vec < DefKey > ; 2 ] ,
3838 key_to_index : FxHashMap < DefKey , DefIndex > ,
39- def_path_hashes : [ Vec < Fingerprint > ; 2 ] ,
39+ def_path_hashes : [ Vec < DefPathHash > ; 2 ] ,
4040}
4141
4242// Unfortunately we have to provide a manual impl of Clone because of the
@@ -57,7 +57,7 @@ impl DefPathTable {
5757
5858 fn allocate ( & mut self ,
5959 key : DefKey ,
60- def_path_hash : Fingerprint ,
60+ def_path_hash : DefPathHash ,
6161 address_space : DefIndexAddressSpace )
6262 -> DefIndex {
6363 let index = {
@@ -81,7 +81,7 @@ impl DefPathTable {
8181 }
8282
8383 #[ inline( always) ]
84- pub fn def_path_hash ( & self , index : DefIndex ) -> Fingerprint {
84+ pub fn def_path_hash ( & self , index : DefIndex ) -> DefPathHash {
8585 self . def_path_hashes [ index. address_space ( ) . index ( ) ]
8686 [ index. as_array_index ( ) ]
8787 }
@@ -148,8 +148,8 @@ impl Decodable for DefPathTable {
148148 let index_to_key_lo: Vec < DefKey > = Decodable :: decode ( d) ?;
149149 let index_to_key_hi: Vec < DefKey > = Decodable :: decode ( d) ?;
150150
151- let def_path_hashes_lo: Vec < Fingerprint > = Decodable :: decode ( d) ?;
152- let def_path_hashes_hi: Vec < Fingerprint > = Decodable :: decode ( d) ?;
151+ let def_path_hashes_lo: Vec < DefPathHash > = Decodable :: decode ( d) ?;
152+ let def_path_hashes_hi: Vec < DefPathHash > = Decodable :: decode ( d) ?;
153153
154154 let index_to_key = [ index_to_key_lo, index_to_key_hi] ;
155155 let def_path_hashes = [ def_path_hashes_lo, def_path_hashes_hi] ;
@@ -216,25 +216,25 @@ pub struct DefKey {
216216}
217217
218218impl DefKey {
219- fn compute_stable_hash ( & self , parent_hash : Fingerprint ) -> Fingerprint {
219+ fn compute_stable_hash ( & self , parent_hash : DefPathHash ) -> DefPathHash {
220220 let mut hasher = StableHasher :: new ( ) ;
221221
222222 // We hash a 0u8 here to disambiguate between regular DefPath hashes,
223223 // and the special "root_parent" below.
224224 0u8 . hash ( & mut hasher) ;
225225 parent_hash. hash ( & mut hasher) ;
226226 self . disambiguated_data . hash ( & mut hasher) ;
227- hasher. finish ( )
227+ DefPathHash ( hasher. finish ( ) )
228228 }
229229
230- fn root_parent_stable_hash ( crate_name : & str , crate_disambiguator : & str ) -> Fingerprint {
230+ fn root_parent_stable_hash ( crate_name : & str , crate_disambiguator : & str ) -> DefPathHash {
231231 let mut hasher = StableHasher :: new ( ) ;
232232 // Disambiguate this from a regular DefPath hash,
233233 // see compute_stable_hash() above.
234234 1u8 . hash ( & mut hasher) ;
235235 crate_name. hash ( & mut hasher) ;
236236 crate_disambiguator. hash ( & mut hasher) ;
237- hasher. finish ( )
237+ DefPathHash ( hasher. finish ( ) )
238238 }
239239}
240240
@@ -372,6 +372,12 @@ pub enum DefPathData {
372372 Typeof ,
373373}
374374
375+ #[ derive( Copy , Clone , Hash , PartialEq , Eq , PartialOrd , Ord , Debug ,
376+ RustcEncodable , RustcDecodable ) ]
377+ pub struct DefPathHash ( pub Fingerprint ) ;
378+
379+ impl_stable_hash_for ! ( tuple_struct DefPathHash { fingerprint } ) ;
380+
375381impl Definitions {
376382 /// Create new empty definition map.
377383 pub fn new ( ) -> Definitions {
@@ -404,7 +410,7 @@ impl Definitions {
404410 }
405411
406412 #[ inline( always) ]
407- pub fn def_path_hash ( & self , index : DefIndex ) -> Fingerprint {
413+ pub fn def_path_hash ( & self , index : DefIndex ) -> DefPathHash {
408414 self . table . def_path_hash ( index)
409415 }
410416
0 commit comments