33//! manage the caches, and so forth.
44
55use crate :: keys:: Key ;
6+ use crate :: on_disk_cache:: CacheDecoder ;
67use crate :: { on_disk_cache, Queries } ;
78use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
89use rustc_data_structures:: sync:: Lock ;
@@ -19,6 +20,7 @@ use rustc_query_system::query::{
1920 QuerySideEffects , QueryStackFrame ,
2021} ;
2122use rustc_query_system:: Value ;
23+ use rustc_serialize:: Decodable ;
2224use std:: any:: Any ;
2325use std:: num:: NonZeroU64 ;
2426use thin_vec:: ThinVec ;
@@ -253,6 +255,18 @@ macro_rules! get_provider {
253255 } ;
254256}
255257
258+ macro_rules! should_ever_cache_on_disk {
259+ ( [ ] ) => { {
260+ None
261+ } } ;
262+ ( [ ( cache) $( $rest: tt) * ] ) => { {
263+ Some ( $crate:: plumbing:: try_load_from_disk:: <Self :: Value >)
264+ } } ;
265+ ( [ $other: tt $( $modifiers: tt) * ] ) => {
266+ should_ever_cache_on_disk!( [ $( $modifiers) * ] )
267+ } ;
268+ }
269+
256270pub ( crate ) fn create_query_frame <
257271 ' tcx ,
258272 K : Copy + Key + for < ' a > HashStable < StableHashingContext < ' a > > ,
@@ -313,6 +327,16 @@ where
313327 }
314328}
315329
330+ pub ( crate ) fn try_load_from_disk < ' tcx , V > (
331+ tcx : QueryCtxt < ' tcx > ,
332+ id : SerializedDepNodeIndex ,
333+ ) -> Option < V >
334+ where
335+ V : for < ' a > Decodable < CacheDecoder < ' a , ' tcx > > ,
336+ {
337+ tcx. on_disk_cache ( ) . as_ref ( ) ?. try_load_query_result ( * tcx, id)
338+ }
339+
316340fn force_from_dep_node < ' tcx , Q > ( tcx : TyCtxt < ' tcx > , dep_node : DepNode ) -> bool
317341where
318342 Q : QueryDescription < QueryCtxt < ' tcx > > ,
0 commit comments