@@ -5,8 +5,8 @@ use syn::parse::{Parse, ParseStream, Result};
55use syn:: punctuated:: Punctuated ;
66use syn:: spanned:: Spanned ;
77use syn:: {
8- AttrStyle , Attribute , Block , Error , Expr , Ident , Pat , ReturnType , Token , Type , braced,
9- parenthesized , parse_macro_input, token,
8+ AttrStyle , Attribute , Error , Expr , Ident , Pat , ReturnType , Token , Type , braced, parenthesized ,
9+ parse_macro_input, token,
1010} ;
1111
1212mod kw {
@@ -132,16 +132,11 @@ struct Desc {
132132 expr_list : Punctuated < Expr , Token ! [ , ] > ,
133133}
134134
135- struct CacheOnDiskIf {
136- modifier : Ident ,
137- block : Block ,
138- }
139-
140135/// See `rustc_middle::query::modifiers` for documentation of each query modifier.
141136struct QueryModifiers {
142137 // tidy-alphabetical-start
143138 arena_cache : Option < Ident > ,
144- cache_on_disk_if : Option < CacheOnDiskIf > ,
139+ cache_on_disk : Option < Ident > ,
145140 depth_limit : Option < Ident > ,
146141 desc : Desc ,
147142 eval_always : Option < Ident > ,
@@ -154,7 +149,7 @@ struct QueryModifiers {
154149
155150fn parse_query_modifiers ( input : ParseStream < ' _ > ) -> Result < QueryModifiers > {
156151 let mut arena_cache = None ;
157- let mut cache_on_disk_if = None ;
152+ let mut cache_on_disk = None ;
158153 let mut desc = None ;
159154 let mut no_force = None ;
160155 let mut no_hash = None ;
@@ -182,11 +177,8 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
182177 braced ! ( attr_content in input) ;
183178 let expr_list = attr_content. parse_terminated ( Expr :: parse, Token ! [ , ] ) ?;
184179 try_insert ! ( desc = Desc { modifier, expr_list } ) ;
185- } else if modifier == "cache_on_disk_if" {
186- // Parse a cache-on-disk modifier like:
187- // `cache_on_disk_if { tcx.is_typeck_child(key.to_def_id()) }`
188- let block = input. parse ( ) ?;
189- try_insert ! ( cache_on_disk_if = CacheOnDiskIf { modifier, block } ) ;
180+ } else if modifier == "cache_on_disk" {
181+ try_insert ! ( cache_on_disk = modifier) ;
190182 } else if modifier == "arena_cache" {
191183 try_insert ! ( arena_cache = modifier) ;
192184 } else if modifier == "no_force" {
@@ -210,7 +202,7 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
210202 } ;
211203 Ok ( QueryModifiers {
212204 arena_cache,
213- cache_on_disk_if ,
205+ cache_on_disk ,
214206 desc,
215207 no_force,
216208 no_hash,
@@ -244,7 +236,7 @@ fn make_modifiers_stream(query: &Query) -> proc_macro2::TokenStream {
244236 let QueryModifiers {
245237 // tidy-alphabetical-start
246238 arena_cache,
247- cache_on_disk_if ,
239+ cache_on_disk ,
248240 depth_limit,
249241 desc : _,
250242 eval_always,
@@ -256,7 +248,7 @@ fn make_modifiers_stream(query: &Query) -> proc_macro2::TokenStream {
256248 } = & query. modifiers ;
257249
258250 let arena_cache = arena_cache. is_some ( ) ;
259- let cache_on_disk = cache_on_disk_if . is_some ( ) ;
251+ let cache_on_disk = cache_on_disk . is_some ( ) ;
260252 let depth_limit = depth_limit. is_some ( ) ;
261253 let eval_always = eval_always. is_some ( ) ;
262254 let feedable = feedable. is_some ( ) ;
@@ -321,7 +313,6 @@ fn doc_comment_from_desc(list: &Punctuated<Expr, token::Comma>) -> Result<Attrib
321313#[ derive( Default ) ]
322314struct HelperTokenStreams {
323315 description_fns_stream : proc_macro2:: TokenStream ,
324- cache_on_disk_if_fns_stream : proc_macro2:: TokenStream ,
325316}
326317
327318fn make_helpers_for_query ( query : & Query , streams : & mut HelperTokenStreams ) {
@@ -331,16 +322,6 @@ fn make_helpers_for_query(query: &Query, streams: &mut HelperTokenStreams) {
331322 let mut erased_name = name. clone ( ) ;
332323 erased_name. set_span ( Span :: call_site ( ) ) ;
333324
334- // Generate a function to check whether we should cache the query to disk, for some key.
335- if let Some ( CacheOnDiskIf { block, .. } ) = modifiers. cache_on_disk_if . as_ref ( ) {
336- streams. cache_on_disk_if_fns_stream . extend ( quote ! {
337- #[ allow( unused_variables) ]
338- #[ inline]
339- pub fn #erased_name<' tcx>( tcx: TyCtxt <' tcx>, #key_pat: #key_ty) -> bool
340- #block
341- } ) ;
342- }
343-
344325 let Desc { expr_list, .. } = & modifiers. desc ;
345326
346327 let desc = quote ! {
@@ -368,12 +349,6 @@ fn add_to_analyzer_stream(query: &Query, analyzer_stream: &mut proc_macro2::Toke
368349 crate :: query:: modifiers:: #name;
369350 } ) ;
370351
371- if let Some ( CacheOnDiskIf { modifier, .. } ) = & modifiers. cache_on_disk_if {
372- modifiers_stream. extend ( quote ! {
373- crate :: query:: modifiers:: #modifier;
374- } ) ;
375- }
376-
377352 macro_rules! doc_link {
378353 ( $( $modifier: ident ) ,+ $( , ) ? ) => {
379354 $(
@@ -389,6 +364,7 @@ fn add_to_analyzer_stream(query: &Query, analyzer_stream: &mut proc_macro2::Toke
389364 doc_link ! (
390365 // tidy-alphabetical-start
391366 arena_cache,
367+ cache_on_disk,
392368 depth_limit,
393369 eval_always,
394370 feedable,
@@ -489,7 +465,7 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
489465 make_helpers_for_query ( & query, & mut helpers) ;
490466 }
491467
492- let HelperTokenStreams { description_fns_stream, cache_on_disk_if_fns_stream } = helpers;
468+ let HelperTokenStreams { description_fns_stream } = helpers;
493469
494470 TokenStream :: from ( quote ! {
495471 /// Higher-order macro that invokes the specified macro with (a) a list of all query
@@ -525,14 +501,6 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
525501 #description_fns_stream
526502 }
527503
528- // FIXME(Zalathar): Instead of declaring these functions directly, can
529- // we put them in a macro and then expand that macro downstream in
530- // `rustc_query_impl`, where the functions are actually used?
531- pub mod _cache_on_disk_if_fns {
532- use super :: * ;
533- #cache_on_disk_if_fns_stream
534- }
535-
536504 #errors
537505 } )
538506}
0 commit comments