@@ -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,17 +132,12 @@ 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 anon : Option < Ident > ,
144139 arena_cache : Option < Ident > ,
145- cache_on_disk_if : Option < CacheOnDiskIf > ,
140+ cache_on_disk : Option < Ident > ,
146141 cycle_delay_bug : Option < Ident > ,
147142 cycle_stash : Option < Ident > ,
148143 depth_limit : Option < Ident > ,
@@ -157,7 +152,7 @@ struct QueryModifiers {
157152
158153fn parse_query_modifiers ( input : ParseStream < ' _ > ) -> Result < QueryModifiers > {
159154 let mut arena_cache = None ;
160- let mut cache_on_disk_if = None ;
155+ let mut cache_on_disk = None ;
161156 let mut desc = None ;
162157 let mut cycle_delay_bug = None ;
163158 let mut cycle_stash = None ;
@@ -188,11 +183,8 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
188183 braced ! ( attr_content in input) ;
189184 let expr_list = attr_content. parse_terminated ( Expr :: parse, Token ! [ , ] ) ?;
190185 try_insert ! ( desc = Desc { modifier, expr_list } ) ;
191- } else if modifier == "cache_on_disk_if" {
192- // Parse a cache-on-disk modifier like:
193- // `cache_on_disk_if { tcx.is_typeck_child(key.to_def_id()) }`
194- let block = input. parse ( ) ?;
195- try_insert ! ( cache_on_disk_if = CacheOnDiskIf { modifier, block } ) ;
186+ } else if modifier == "cache_on_disk" {
187+ try_insert ! ( cache_on_disk = modifier) ;
196188 } else if modifier == "arena_cache" {
197189 try_insert ! ( arena_cache = modifier) ;
198190 } else if modifier == "cycle_delay_bug" {
@@ -222,7 +214,7 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
222214 } ;
223215 Ok ( QueryModifiers {
224216 arena_cache,
225- cache_on_disk_if ,
217+ cache_on_disk ,
226218 desc,
227219 cycle_delay_bug,
228220 cycle_stash,
@@ -241,7 +233,7 @@ fn make_modifiers_stream(query: &Query, modifiers: &QueryModifiers) -> proc_macr
241233 // tidy-alphabetical-start
242234 anon,
243235 arena_cache,
244- cache_on_disk_if ,
236+ cache_on_disk ,
245237 cycle_delay_bug,
246238 cycle_stash,
247239 depth_limit,
@@ -256,7 +248,7 @@ fn make_modifiers_stream(query: &Query, modifiers: &QueryModifiers) -> proc_macr
256248
257249 let anon = anon. is_some ( ) ;
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
261253 let cycle_error_handling = if cycle_delay_bug. is_some ( ) {
262254 quote ! { DelayBug }
@@ -330,7 +322,6 @@ fn doc_comment_from_desc(list: &Punctuated<Expr, token::Comma>) -> Result<Attrib
330322#[ derive( Default ) ]
331323struct HelperTokenStreams {
332324 description_fns_stream : proc_macro2:: TokenStream ,
333- cache_on_disk_if_fns_stream : proc_macro2:: TokenStream ,
334325}
335326
336327fn make_helpers_for_query ( query : & Query , streams : & mut HelperTokenStreams ) {
@@ -340,18 +331,6 @@ fn make_helpers_for_query(query: &Query, streams: &mut HelperTokenStreams) {
340331 let mut erased_name = name. clone ( ) ;
341332 erased_name. set_span ( Span :: call_site ( ) ) ;
342333
343- // Generate a function to check whether we should cache the query to disk, for some key.
344- if let Some ( CacheOnDiskIf { block, .. } ) = modifiers. cache_on_disk_if . as_ref ( ) {
345- // `disallowed_pass_by_ref` is needed because some keys are `rustc_pass_by_value`.
346- streams. cache_on_disk_if_fns_stream . extend ( quote ! {
347- #[ cfg_attr( not( bootstrap) , allow( unused_variables, rustc:: disallowed_pass_by_ref) ) ]
348- #[ cfg_attr( bootstrap, allow( unused_variables, rustc:: pass_by_value) ) ]
349- #[ inline]
350- pub fn #erased_name<' tcx>( tcx: TyCtxt <' tcx>, #key_pat: & #key_ty) -> bool
351- #block
352- } ) ;
353- }
354-
355334 let Desc { expr_list, .. } = & modifiers. desc ;
356335
357336 let desc = quote ! {
@@ -379,12 +358,6 @@ fn add_to_analyzer_stream(query: &Query, analyzer_stream: &mut proc_macro2::Toke
379358 crate :: query:: modifiers:: #name;
380359 } ) ;
381360
382- if let Some ( CacheOnDiskIf { modifier, .. } ) = & modifiers. cache_on_disk_if {
383- modifiers_stream. extend ( quote ! {
384- crate :: query:: modifiers:: #modifier;
385- } ) ;
386- }
387-
388361 macro_rules! doc_link {
389362 ( $( $modifier: ident ) ,+ $( , ) ? ) => {
390363 $(
@@ -399,6 +372,7 @@ fn add_to_analyzer_stream(query: &Query, analyzer_stream: &mut proc_macro2::Toke
399372
400373 doc_link ! (
401374 arena_cache,
375+ cache_on_disk,
402376 cycle_delay_bug,
403377 cycle_stash,
404378 no_hash,
@@ -506,7 +480,7 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
506480 make_helpers_for_query ( & query, & mut helpers) ;
507481 }
508482
509- let HelperTokenStreams { description_fns_stream, cache_on_disk_if_fns_stream } = helpers;
483+ let HelperTokenStreams { description_fns_stream } = helpers;
510484
511485 TokenStream :: from ( quote ! {
512486 /// Higher-order macro that invokes the specified macro with (a) a list of all query
@@ -542,14 +516,6 @@ pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
542516 #description_fns_stream
543517 }
544518
545- // FIXME(Zalathar): Instead of declaring these functions directly, can
546- // we put them in a macro and then expand that macro downstream in
547- // `rustc_query_impl`, where the functions are actually used?
548- pub mod _cache_on_disk_if_fns {
549- use super :: * ;
550- #cache_on_disk_if_fns_stream
551- }
552-
553519 #errors
554520 } )
555521}
0 commit comments