diff options
| author | Joshua Nelson <jnelson@cloudflare.com> | 2022-08-29 17:45:18 -0500 |
|---|---|---|
| committer | Joshua Nelson <jnelson@cloudflare.com> | 2022-09-06 21:43:15 -0500 |
| commit | 05886e28a4c3fbb7bc22d56bf5a52ba7cfa491d9 (patch) | |
| tree | b75824da9685ce91f557a81b3204dbba8c5863ed /compiler/rustc_macros/src | |
| parent | 699bfa882b34a73b333e684e96984c1c565d2eff (diff) | |
Further simplify the macros generated by `rustc_queries`
- Add a new `rustc_query_names` macro. This allows a much simpler syntax for the matchers in the macros passed to it as a callback. - Convert `define_dep_nodes` and `alloc_once` to use `rustc_query_names`. This is possible because they only use the names (despite the quite complicated matchers in `define_dep_nodes`, none of the other arguments are used). - Get rid of `rustc_dep_node_append`.
Diffstat (limited to 'compiler/rustc_macros/src')
| -rw-r--r-- | compiler/rustc_macros/src/query.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index f93fe2d5195..2a1bb10fdfc 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -328,7 +328,7 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { let mut query_stream = quote! {}; let mut query_description_stream = quote! {}; - let mut dep_node_def_stream = quote! {}; + let mut all_names = quote! {}; let mut cached_queries = quote! {}; for query in queries.0 { @@ -344,6 +344,7 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { #name, }); } + all_names.extend(quote! { #name, }); let mut attributes = Vec::new(); @@ -400,35 +401,30 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { [#attribute_stream] fn #name(#arg) #result, }); - // Create a dep node for the query - dep_node_def_stream.extend(quote! { - [#attribute_stream] #name(#arg), - }); - add_query_description_impl(&query, &mut query_description_stream); } TokenStream::from(quote! { #[macro_export] macro_rules! rustc_query_append { - ($macro:ident !) => { + ($macro:ident!) => { $macro! { #query_stream } } } - macro_rules! rustc_dep_node_append { - ($macro:ident! [$($other:tt)*]) => { + #[macro_export] + macro_rules! rustc_query_names { + ($macro:ident! $( [$($other:tt)*] )?) => { $macro!( - $($other)* - - #dep_node_def_stream + $( $($other)* )? + #all_names ); } } #[macro_export] macro_rules! rustc_cached_queries { - ( $macro:ident! ) => { + ($macro:ident!) => { $macro!(#cached_queries); } } |
