From 3a4e3c778889fdf2c4ccb7af26f1e81fc324e98b Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 6 Sep 2022 21:26:02 -0500 Subject: Get rid of the emitted `rustc_query_names` and `rustc_cached_queries` macro We can avoid these by adding slightly more information to `rustc_query_append` instead. --- compiler/rustc_macros/src/query.rs | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'compiler/rustc_macros/src/query.rs') diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index 046a144913e..505b2d62a79 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -328,7 +328,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { let mut query_stream = quote! {}; let mut query_description_stream = quote! {}; - let mut all_names = quote! {}; let mut cached_queries = quote! {}; for query in queries.0 { @@ -384,6 +383,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { if let Some(remap_env_constness) = &modifiers.remap_env_constness { attributes.push(quote! { (#remap_env_constness) }); } + // Pass on the const modifier + if modifiers.cache.is_some() { + attributes.push(quote! { (cache) }); + } // This uses the span of the query definition for the commas, // which can be important if we later encounter any ambiguity @@ -400,38 +403,20 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { [#attribute_stream] fn #name(#arg) #result, }); - all_names.extend(quote! { - #(#doc_comments)* - #name, - }); - add_query_description_impl(&query, &mut query_description_stream); } TokenStream::from(quote! { #[macro_export] macro_rules! rustc_query_append { - ($macro:ident!) => { + ($macro:ident! $( [$($other:tt)*] )?) => { $macro! { + $( $($other)* )? #query_stream } } } - #[macro_export] - macro_rules! rustc_query_names { - ($macro:ident! $( [$($other:tt)*] )?) => { - $macro!( - $( $($other)* )? - #all_names - ); - } - } - #[macro_export] - macro_rules! rustc_cached_queries { - ($macro:ident!) => { - $macro!(#cached_queries); - } - } + #[macro_export] macro_rules! rustc_query_description { #query_description_stream -- cgit 1.4.1-3-g733a5