@@ -91,9 +91,6 @@ struct QueryModifiers {
9191 /// Cache the query to disk if the `Block` returns true.
9292 cache : Option < ( Option < Pat > , Block ) > ,
9393
94- /// Custom code to load the query from disk.
95- load_cached : Option < ( Ident , Ident , Block ) > ,
96-
9794 /// A cycle error for this query aborting the compilation with a fatal error.
9895 fatal_cycle : Option < Ident > ,
9996
@@ -120,7 +117,6 @@ struct QueryModifiers {
120117}
121118
122119fn parse_query_modifiers ( input : ParseStream < ' _ > ) -> Result < QueryModifiers > {
123- let mut load_cached = None ;
124120 let mut arena_cache = None ;
125121 let mut cache = None ;
126122 let mut desc = None ;
@@ -173,16 +169,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
173169 } ;
174170 let block = input. parse ( ) ?;
175171 try_insert ! ( cache = ( args, block) ) ;
176- } else if modifier == "load_cached" {
177- // Parse a load_cached modifier like:
178- // `load_cached(tcx, id) { tcx.on_disk_cache.try_load_query_result(tcx, id) }`
179- let args;
180- parenthesized ! ( args in input) ;
181- let tcx = args. parse ( ) ?;
182- args. parse :: < Token ! [ , ] > ( ) ?;
183- let id = args. parse ( ) ?;
184- let block = input. parse ( ) ?;
185- try_insert ! ( load_cached = ( tcx, id, block) ) ;
186172 } else if modifier == "arena_cache" {
187173 try_insert ! ( arena_cache = modifier) ;
188174 } else if modifier == "fatal_cycle" {
@@ -209,7 +195,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
209195 return Err ( input. error ( "no description provided" ) ) ;
210196 } ;
211197 Ok ( QueryModifiers {
212- load_cached,
213198 arena_cache,
214199 cache,
215200 desc,
@@ -259,20 +244,6 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
259244
260245 // Find out if we should cache the query on disk
261246 let cache = if let Some ( ( args, expr) ) = modifiers. cache . as_ref ( ) {
262- let try_load_from_disk = if let Some ( ( tcx, id, block) ) = modifiers. load_cached . as_ref ( ) {
263- // Use custom code to load the query from disk
264- quote ! {
265- const TRY_LOAD_FROM_DISK : Option <fn ( QueryCtxt <' tcx>, SerializedDepNodeIndex ) -> Option <Self :: Value >>
266- = Some ( |#tcx, #id| { #block } ) ;
267- }
268- } else {
269- // Use the default code to load the query from disk
270- quote ! {
271- const TRY_LOAD_FROM_DISK : Option <fn ( QueryCtxt <' tcx>, SerializedDepNodeIndex ) -> Option <Self :: Value >>
272- = Some ( |tcx, id| tcx. on_disk_cache( ) . as_ref( ) ?. try_load_query_result( * tcx, id) ) ;
273- }
274- } ;
275-
276247 let tcx = args. as_ref ( ) . map ( |t| quote ! { #t } ) . unwrap_or_else ( || quote ! { _ } ) ;
277248 // expr is a `Block`, meaning that `{ #expr }` gets expanded
278249 // to `{ { stmts... } }`, which triggers the `unused_braces` lint.
@@ -283,12 +254,10 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
283254 #expr
284255 }
285256
286- #try_load_from_disk
257+ const TRY_LOAD_FROM_DISK : Option <fn ( QueryCtxt <' tcx>, SerializedDepNodeIndex ) -> Option <Self :: Value >>
258+ = Some ( |tcx, id| tcx. on_disk_cache( ) . as_ref( ) ?. try_load_query_result( * tcx, id) ) ;
287259 }
288260 } else {
289- if modifiers. load_cached . is_some ( ) {
290- panic ! ( "load_cached modifier on query `{}` without a cache modifier" , name) ;
291- }
292261 quote ! {
293262 #[ inline]
294263 fn cache_on_disk( _: TyCtxt <' tcx>, _: & Self :: Key ) -> bool {
0 commit comments