@@ -27,7 +27,8 @@ use syntax::symbol::Symbol;
27
27
use syntax_pos:: Span ;
28
28
29
29
use rustc_data_structures:: stable_hasher:: { HashStable , StableHashingContextProvider ,
30
- StableHasher , StableHasherResult } ;
30
+ StableHasher , StableHasherResult ,
31
+ ToStableHashKey } ;
31
32
use rustc_data_structures:: accumulate_vec:: AccumulateVec ;
32
33
33
34
/// This is the context state available during incr. comp. hashing. It contains
@@ -48,9 +49,7 @@ pub struct StableHashingContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
48
49
#[ derive( PartialEq , Eq , Clone , Copy ) ]
49
50
pub enum NodeIdHashingMode {
50
51
Ignore ,
51
- CheckedIgnore ,
52
52
HashDefPath ,
53
- HashTraitsInScope ,
54
53
}
55
54
56
55
impl < ' a , ' gcx , ' tcx > StableHashingContext < ' a , ' gcx , ' tcx > {
@@ -150,7 +149,7 @@ impl<'a, 'gcx, 'tcx> StableHashingContext<'a, 'gcx, 'tcx> {
150
149
self . overflow_checks_enabled = true ;
151
150
}
152
151
let prev_hash_node_ids = self . node_id_hashing_mode ;
153
- self . node_id_hashing_mode = NodeIdHashingMode :: CheckedIgnore ;
152
+ self . node_id_hashing_mode = NodeIdHashingMode :: Ignore ;
154
153
155
154
f ( self ) ;
156
155
@@ -207,41 +206,28 @@ impl<'a, 'gcx, 'tcx> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for ast::N
207
206
fn hash_stable < W : StableHasherResult > ( & self ,
208
207
hcx : & mut StableHashingContext < ' a , ' gcx , ' tcx > ,
209
208
hasher : & mut StableHasher < W > ) {
210
- let hir_id = hcx. tcx . hir . node_to_hir_id ( * self ) ;
211
209
match hcx. node_id_hashing_mode {
212
210
NodeIdHashingMode :: Ignore => {
213
211
// Don't do anything.
214
212
}
215
- NodeIdHashingMode :: CheckedIgnore => {
216
- // Most NodeIds in the HIR can be ignored, but if there is a
217
- // corresponding entry in the `trait_map` we need to hash that.
218
- // Make sure we don't ignore too much by checking that there is
219
- // no entry in a debug_assert!().
220
- debug_assert ! ( hcx. tcx. in_scope_traits( hir_id) . is_none( ) ) ;
221
- }
222
213
NodeIdHashingMode :: HashDefPath => {
223
- hir_id. hash_stable ( hcx, hasher) ;
224
- }
225
- NodeIdHashingMode :: HashTraitsInScope => {
226
- if let Some ( traits) = hcx. tcx . in_scope_traits ( hir_id) {
227
- // The ordering of the candidates is not fixed. So we hash
228
- // the def-ids and then sort them and hash the collection.
229
- let mut candidates: AccumulateVec < [ _ ; 8 ] > =
230
- traits. iter ( )
231
- . map ( |& hir:: TraitCandidate { def_id, import_id : _ } | {
232
- hcx. def_path_hash ( def_id)
233
- } )
234
- . collect ( ) ;
235
- if traits. len ( ) > 1 {
236
- candidates. sort ( ) ;
237
- }
238
- candidates. hash_stable ( hcx, hasher) ;
239
- }
214
+ hcx. tcx . hir . node_to_hir_id ( * self ) . hash_stable ( hcx, hasher) ;
240
215
}
241
216
}
242
217
}
243
218
}
244
219
220
+ impl < ' a , ' gcx , ' tcx > ToStableHashKey < StableHashingContext < ' a , ' gcx , ' tcx > > for ast:: NodeId {
221
+ type KeyType = ( DefPathHash , hir:: ItemLocalId ) ;
222
+
223
+ #[ inline]
224
+ fn to_stable_hash_key ( & self ,
225
+ hcx : & StableHashingContext < ' a , ' gcx , ' tcx > )
226
+ -> ( DefPathHash , hir:: ItemLocalId ) {
227
+ hcx. tcx . hir . node_to_hir_id ( * self ) . to_stable_hash_key ( hcx)
228
+ }
229
+ }
230
+
245
231
impl < ' a , ' gcx , ' tcx > HashStable < StableHashingContext < ' a , ' gcx , ' tcx > > for Span {
246
232
247
233
// Hash a span in a stable way. We can't directly hash the span's BytePos
0 commit comments