@@ -557,10 +557,17 @@ where
557
557
// can be forced from `DepNode`.
558
558
debug_assert ! (
559
559
!qcx. dep_context( ) . fingerprint_style( dep_node. kind) . reconstructible( ) ,
560
- "missing on-disk cache entry for {dep_node:?}"
560
+ "missing on-disk cache entry for reconstructible {dep_node:?}"
561
561
) ;
562
562
}
563
563
564
+ // Sanity check for the logic in `ensure`: if the node is green and the result loadable,
565
+ // we should actually be able to load it.
566
+ debug_assert ! (
567
+ !query. loadable_from_disk( qcx, & key, prev_dep_node_index) ,
568
+ "missing on-disk cache entry for loadable {dep_node:?}"
569
+ ) ;
570
+
564
571
// We could not load a result from the on-disk cache, so
565
572
// recompute.
566
573
let prof_timer = qcx. dep_context ( ) . profiler ( ) . query_provider ( ) ;
@@ -719,22 +726,25 @@ where
719
726
let dep_node = query. construct_dep_node ( * qcx. dep_context ( ) , key) ;
720
727
721
728
let dep_graph = qcx. dep_context ( ) . dep_graph ( ) ;
722
- match dep_graph. try_mark_green ( qcx, & dep_node) {
729
+ let serialized_dep_node_index = match dep_graph. try_mark_green ( qcx, & dep_node) {
723
730
None => {
724
731
// A None return from `try_mark_green` means that this is either
725
732
// a new dep node or that the dep node has already been marked red.
726
733
// Either way, we can't call `dep_graph.read()` as we don't have the
727
734
// DepNodeIndex. We must invoke the query itself. The performance cost
728
735
// this introduces should be negligible as we'll immediately hit the
729
736
// in-memory cache, or another query down the line will.
730
- ( true , Some ( dep_node) )
737
+ return ( true , Some ( dep_node) ) ;
731
738
}
732
- Some ( ( _ , dep_node_index) ) => {
739
+ Some ( ( serialized_dep_node_index , dep_node_index) ) => {
733
740
dep_graph. read_index ( dep_node_index) ;
734
741
qcx. dep_context ( ) . profiler ( ) . query_cache_hit ( dep_node_index. into ( ) ) ;
735
- ( false , None )
742
+ serialized_dep_node_index
736
743
}
737
- }
744
+ } ;
745
+
746
+ let loadable = query. loadable_from_disk ( qcx, key, serialized_dep_node_index) ;
747
+ ( !loadable, Some ( dep_node) )
738
748
}
739
749
740
750
#[ derive( Debug ) ]
0 commit comments