@@ -91,9 +91,6 @@ struct QueryModifiers {
91
91
/// Cache the query to disk if the `Block` returns true.
92
92
cache : Option < ( Option < Pat > , Block ) > ,
93
93
94
- /// Custom code to load the query from disk.
95
- load_cached : Option < ( Ident , Ident , Block ) > ,
96
-
97
94
/// A cycle error for this query aborting the compilation with a fatal error.
98
95
fatal_cycle : Option < Ident > ,
99
96
@@ -120,7 +117,6 @@ struct QueryModifiers {
120
117
}
121
118
122
119
fn parse_query_modifiers ( input : ParseStream < ' _ > ) -> Result < QueryModifiers > {
123
- let mut load_cached = None ;
124
120
let mut arena_cache = None ;
125
121
let mut cache = None ;
126
122
let mut desc = None ;
@@ -173,16 +169,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
173
169
} ;
174
170
let block = input. parse ( ) ?;
175
171
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) ) ;
186
172
} else if modifier == "arena_cache" {
187
173
try_insert ! ( arena_cache = modifier) ;
188
174
} else if modifier == "fatal_cycle" {
@@ -209,7 +195,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
209
195
return Err ( input. error ( "no description provided" ) ) ;
210
196
} ;
211
197
Ok ( QueryModifiers {
212
- load_cached,
213
198
arena_cache,
214
199
cache,
215
200
desc,
@@ -259,20 +244,6 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
259
244
260
245
// Find out if we should cache the query on disk
261
246
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
-
276
247
let tcx = args. as_ref ( ) . map ( |t| quote ! { #t } ) . unwrap_or_else ( || quote ! { _ } ) ;
277
248
// expr is a `Block`, meaning that `{ #expr }` gets expanded
278
249
// to `{ { stmts... } }`, which triggers the `unused_braces` lint.
@@ -283,12 +254,10 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
283
254
#expr
284
255
}
285
256
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) ) ;
287
259
}
288
260
} else {
289
- if modifiers. load_cached . is_some ( ) {
290
- panic ! ( "load_cached modifier on query `{}` without a cache modifier" , name) ;
291
- }
292
261
quote ! {
293
262
#[ inline]
294
263
fn cache_on_disk( _: TyCtxt <' tcx>, _: & Self :: Key ) -> bool {
0 commit comments