File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ use hir::def_id::{DefId, DefIndex};
13
13
use hir:: map:: def_collector:: DefCollector ;
14
14
use rustc_data_structures:: fnv:: FnvHashMap ;
15
15
use std:: fmt:: Write ;
16
+ use std:: hash:: { Hash , Hasher , SipHasher } ;
16
17
use syntax:: { ast, visit} ;
17
18
use syntax:: parse:: token:: InternedString ;
18
19
use ty:: TyCtxt ;
@@ -133,6 +134,18 @@ impl DefPath {
133
134
134
135
s
135
136
}
137
+
138
+ pub fn deterministic_hash ( & self , tcx : TyCtxt ) -> u64 {
139
+ let mut state = SipHasher :: new ( ) ;
140
+ self . deterministic_hash_to ( tcx, & mut state) ;
141
+ state. finish ( )
142
+ }
143
+
144
+ pub fn deterministic_hash_to < H : Hasher > ( & self , tcx : TyCtxt , state : & mut H ) {
145
+ tcx. crate_name ( self . krate ) . hash ( state) ;
146
+ tcx. crate_disambiguator ( self . krate ) . hash ( state) ;
147
+ self . data . hash ( state) ;
148
+ }
136
149
}
137
150
138
151
/// Root of an inlined item. We track the `DefPath` of the item within
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ mod svh_visitor {
144
144
}
145
145
146
146
fn hash_def_path ( & mut self , path : & DefPath ) {
147
- path. to_string ( self . tcx ) . hash ( self . st ) ;
147
+ path. deterministic_hash_to ( self . tcx , self . st ) ;
148
148
}
149
149
}
150
150
You can’t perform that action at this time.
0 commit comments