@@ -46,6 +46,9 @@ pub trait Cx: Copy {
4646
4747pub trait Delegate {
4848 type Cx : Cx ;
49+ /// Whether to use the provisional cache. Set to `false` by a fuzzer when
50+ /// validating the search graph.
51+ const ENABLE_PROVISIONAL_CACHE : bool ;
4952 type ValidationScope ;
5053 /// Returning `Some` disables the global cache for the current goal.
5154 ///
@@ -525,12 +528,14 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
525528 } else if D :: inspect_is_noop ( inspect) {
526529 self . insert_global_cache ( cx, input, final_entry, result, dep_node)
527530 }
528- } else {
531+ } else if D :: ENABLE_PROVISIONAL_CACHE {
529532 debug_assert ! ( validate_cache. is_none( ) ) ;
530533 let entry = self . provisional_cache . entry ( input) . or_default ( ) ;
531534 let StackEntry { heads, nested_goals, .. } = final_entry;
532535 let path_from_head = Self :: stack_path_kind ( cx, & self . stack , heads. highest_cycle_head ( ) ) ;
533536 entry. push ( ProvisionalCacheEntry { heads, path_from_head, nested_goals, result } ) ;
537+ } else {
538+ debug_assert ! ( validate_cache. is_none( ) ) ;
534539 }
535540
536541 result
@@ -672,6 +677,10 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
672677 }
673678
674679 fn lookup_provisional_cache ( & mut self , cx : X , input : X :: Input ) -> Option < X :: Result > {
680+ if !D :: ENABLE_PROVISIONAL_CACHE {
681+ return None ;
682+ }
683+
675684 let entries = self . provisional_cache . get ( & input) ?;
676685 for & ProvisionalCacheEntry { ref heads, path_from_head, ref nested_goals, result } in
677686 entries
0 commit comments