@@ -14,7 +14,7 @@ use crate::dep_graph::{DepKind, DepNodeIndex, QuerySideEffect, SerializedDepNode
1414use crate :: ich:: StableHashState ;
1515use crate :: queries:: { ExternProviders , Providers , QueryArenas , QueryVTables , TaggedQueryKey } ;
1616use crate :: query:: on_disk_cache:: OnDiskCache ;
17- use crate :: query:: { IntoQueryKey , QueryCache , QueryJob , QueryStackFrame } ;
17+ use crate :: query:: { IntoQueryKey , QueryCache , QueryJob , QueryKey , QueryStackFrame } ;
1818use crate :: ty:: { self , TyCtxt } ;
1919
2020/// For a particular query, keeps track of "active" keys, i.e. keys whose
@@ -86,6 +86,9 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
8686 /// True if this query has the `feedable` modifier.
8787 pub feedable : bool ,
8888
89+ pub cache_on_disk_local : bool ,
90+ pub separate_provide_extern : bool ,
91+
8992 pub dep_kind : DepKind ,
9093 pub state : QueryState < ' tcx , C :: Key > ,
9194 pub cache : C ,
@@ -97,11 +100,9 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
97100 /// This should be the only code that calls the provider function.
98101 pub invoke_provider_fn : fn ( tcx : TyCtxt < ' tcx > , key : C :: Key ) -> C :: Value ,
99102
100- pub will_cache_on_disk_for_key_fn : fn ( key : C :: Key ) -> bool ,
101-
102103 /// Function pointer that tries to load a query value from disk.
103104 ///
104- /// This should only be called after a successful check of `will_cache_on_disk_for_key_fn` .
105+ /// This should only be called after a successful check of [`Self::will_cache_on_disk_for_key`] .
105106 pub try_load_from_disk_fn :
106107 fn ( tcx : TyCtxt < ' tcx > , prev_index : SerializedDepNodeIndex ) -> Option < C :: Value > ,
107108
@@ -133,6 +134,12 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
133134 pub execute_query_fn : fn ( TyCtxt < ' tcx > , Span , C :: Key , QueryMode ) -> Option < C :: Value > ,
134135}
135136
137+ impl < ' tcx , C : QueryCache > QueryVTable < ' tcx , C > {
138+ pub fn will_cache_on_disk_for_key ( & self , key : C :: Key ) -> bool {
139+ self . cache_on_disk_local && ( !self . separate_provide_extern || key. as_local_key ( ) . is_some ( ) )
140+ }
141+ }
142+
136143impl < ' tcx , C : QueryCache > fmt:: Debug for QueryVTable < ' tcx , C > {
137144 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
138145 // When debug-printing a query vtable (e.g. for ICE or tracing),
@@ -328,7 +335,7 @@ macro_rules! define_callbacks {
328335 /// This query has the `separate_provide_extern` modifier.
329336 #[ cfg( $separate_provide_extern) ]
330337 pub type LocalKey <' tcx> =
331- <Key <' tcx> as $crate:: query:: AsLocalQueryKey >:: LocalQueryKey ;
338+ <Key <' tcx> as $crate:: query:: QueryKey >:: LocalQueryKey ;
332339 /// Key type used by provider functions in `local_providers`.
333340 #[ cfg( not( $separate_provide_extern) ) ]
334341 pub type LocalKey <' tcx> = Key <' tcx>;
0 commit comments