@@ -46,6 +46,9 @@ pub trait Cx: Copy {
46
46
47
47
pub trait Delegate {
48
48
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 ;
49
52
type ValidationScope ;
50
53
/// Returning `Some` disables the global cache for the current goal.
51
54
///
@@ -525,12 +528,14 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
525
528
} else if D :: inspect_is_noop ( inspect) {
526
529
self . insert_global_cache ( cx, input, final_entry, result, dep_node)
527
530
}
528
- } else {
531
+ } else if D :: ENABLE_PROVISIONAL_CACHE {
529
532
debug_assert ! ( validate_cache. is_none( ) ) ;
530
533
let entry = self . provisional_cache . entry ( input) . or_default ( ) ;
531
534
let StackEntry { heads, nested_goals, .. } = final_entry;
532
535
let path_from_head = Self :: stack_path_kind ( cx, & self . stack , heads. highest_cycle_head ( ) ) ;
533
536
entry. push ( ProvisionalCacheEntry { heads, path_from_head, nested_goals, result } ) ;
537
+ } else {
538
+ debug_assert ! ( validate_cache. is_none( ) ) ;
534
539
}
535
540
536
541
result
@@ -672,6 +677,10 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
672
677
}
673
678
674
679
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
+
675
684
let entries = self . provisional_cache . get ( & input) ?;
676
685
for & ProvisionalCacheEntry { ref heads, path_from_head, ref nested_goals, result } in
677
686
entries
0 commit comments