@@ -327,7 +327,8 @@ macro_rules! define_maps {
327
327
return Self :: load_from_disk_and_cache_in_memory( tcx,
328
328
key,
329
329
span,
330
- dep_node_index)
330
+ dep_node_index,
331
+ & dep_node)
331
332
}
332
333
}
333
334
@@ -372,7 +373,8 @@ macro_rules! define_maps {
372
373
fn load_from_disk_and_cache_in_memory( tcx: TyCtxt <' a, $tcx, ' lcx>,
373
374
key: $K,
374
375
span: Span ,
375
- dep_node_index: DepNodeIndex )
376
+ dep_node_index: DepNodeIndex ,
377
+ dep_node: & DepNode )
376
378
-> Result <$V, CycleError <' a, $tcx>>
377
379
{
378
380
debug_assert!( tcx. dep_graph. is_green( dep_node_index) ) ;
@@ -390,6 +392,32 @@ macro_rules! define_maps {
390
392
} )
391
393
} ) ?;
392
394
395
+ // If -Zincremental-verify-ich is specified, re-hash results from
396
+ // the cache and make sure that they have the expected fingerprint.
397
+ if tcx. sess. opts. debugging_opts. incremental_verify_ich {
398
+ use rustc_data_structures:: stable_hasher:: { StableHasher , HashStable } ;
399
+ use ich:: Fingerprint ;
400
+
401
+ assert!( Some ( tcx. dep_graph. fingerprint_of( dep_node) ) ==
402
+ tcx. dep_graph. prev_fingerprint_of( dep_node) ,
403
+ "Fingerprint for green query instance not loaded \
404
+ from cache: {:?}", dep_node) ;
405
+
406
+ debug!( "BEGIN verify_ich({:?})" , dep_node) ;
407
+ let mut hcx = tcx. create_stable_hashing_context( ) ;
408
+ let mut hasher = StableHasher :: new( ) ;
409
+
410
+ result. hash_stable( & mut hcx, & mut hasher) ;
411
+
412
+ let new_hash: Fingerprint = hasher. finish( ) ;
413
+ debug!( "END verify_ich({:?})" , dep_node) ;
414
+
415
+ let old_hash = tcx. dep_graph. fingerprint_of( dep_node) ;
416
+
417
+ assert!( new_hash == old_hash, "Found unstable fingerprints \
418
+ for {:?}", dep_node) ;
419
+ }
420
+
393
421
if tcx. sess. opts. debugging_opts. query_dep_graph {
394
422
tcx. dep_graph. mark_loaded_from_cache( dep_node_index, true ) ;
395
423
}
0 commit comments