@@ -557,10 +557,17 @@ where
557557 // can be forced from `DepNode`.
558558 debug_assert ! (
559559 !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:?}"
561561 ) ;
562562 }
563563
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+
564571 // We could not load a result from the on-disk cache, so
565572 // recompute.
566573 let prof_timer = qcx. dep_context ( ) . profiler ( ) . query_provider ( ) ;
@@ -719,22 +726,25 @@ where
719726 let dep_node = query. construct_dep_node ( * qcx. dep_context ( ) , key) ;
720727
721728 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) {
723730 None => {
724731 // A None return from `try_mark_green` means that this is either
725732 // a new dep node or that the dep node has already been marked red.
726733 // Either way, we can't call `dep_graph.read()` as we don't have the
727734 // DepNodeIndex. We must invoke the query itself. The performance cost
728735 // this introduces should be negligible as we'll immediately hit the
729736 // in-memory cache, or another query down the line will.
730- ( true , Some ( dep_node) )
737+ return ( true , Some ( dep_node) ) ;
731738 }
732- Some ( ( _ , dep_node_index) ) => {
739+ Some ( ( serialized_dep_node_index , dep_node_index) ) => {
733740 dep_graph. read_index ( dep_node_index) ;
734741 qcx. dep_context ( ) . profiler ( ) . query_cache_hit ( dep_node_index. into ( ) ) ;
735- ( false , None )
742+ serialized_dep_node_index
736743 }
737- }
744+ } ;
745+
746+ let loadable = query. loadable_from_disk ( qcx, key, serialized_dep_node_index) ;
747+ ( !loadable, Some ( dep_node) )
738748}
739749
740750#[ derive( Debug ) ]
0 commit comments