55//! mismatches where we have two versions of the same crate that were
66//! compiled from distinct sources.
77
8- use rustc_serialize :: { Decodable , Decoder , Encodable , Encoder } ;
8+ use crate :: fingerprint :: Fingerprint ;
99use std:: fmt;
10- use std:: hash:: { Hash , Hasher } ;
1110
1211use crate :: stable_hasher;
1312
14- #[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
13+ #[ derive( Copy , Clone , PartialEq , Eq , Debug , Encodable , Decodable , Hash ) ]
1514pub struct Svh {
16- hash : u64 ,
15+ hash : Fingerprint ,
1716}
1817
1918impl Svh {
2019 /// Creates a new `Svh` given the hash. If you actually want to
2120 /// compute the SVH from some HIR, you want the `calculate_svh`
2221 /// function found in `rustc_incremental`.
23- pub fn new ( hash : u64 ) -> Svh {
22+ pub fn new ( hash : Fingerprint ) -> Svh {
2423 Svh { hash }
2524 }
2625
2726 pub fn as_u64 ( & self ) -> u64 {
28- self . hash
27+ self . hash . to_smaller_hash ( )
2928 }
3029
3130 pub fn to_string ( & self ) -> String {
32- format ! ( "{:016x}" , self . hash)
33- }
34- }
35-
36- impl Hash for Svh {
37- fn hash < H > ( & self , state : & mut H )
38- where
39- H : Hasher ,
40- {
41- self . hash . to_le ( ) . hash ( state) ;
31+ format ! ( "{:016x}" , self . hash. to_smaller_hash( ) )
4232 }
4333}
4434
@@ -48,18 +38,6 @@ impl fmt::Display for Svh {
4838 }
4939}
5040
51- impl < S : Encoder > Encodable < S > for Svh {
52- fn encode ( & self , s : & mut S ) {
53- s. emit_u64 ( self . as_u64 ( ) . to_le ( ) ) ;
54- }
55- }
56-
57- impl < D : Decoder > Decodable < D > for Svh {
58- fn decode ( d : & mut D ) -> Svh {
59- Svh :: new ( u64:: from_le ( d. read_u64 ( ) ) )
60- }
61- }
62-
6341impl < T > stable_hasher:: HashStable < T > for Svh {
6442 #[ inline]
6543 fn hash_stable ( & self , ctx : & mut T , hasher : & mut stable_hasher:: StableHasher ) {
0 commit comments