Auto merge of #101173 - jyn514:simplify-macro-arguments, r=cjgillot
Further simplify the macros generated by `rustc_queries` This doesn't actually move anything outside the macros, but it makes them simpler to read. - 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`. r? `@cjgillot`
This commit is contained in:
commit
294f0eef73
4 changed files with 40 additions and 52 deletions
|
@ -289,7 +289,6 @@ 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 cached_queries = quote! {};
|
||||
|
||||
for query in queries.0 {
|
||||
|
@ -328,6 +327,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
|
|||
remap_env_constness,
|
||||
);
|
||||
|
||||
if modifiers.cache.is_some() {
|
||||
attributes.push(quote! { (cache) });
|
||||
}
|
||||
// Pass on the cache modifier
|
||||
if modifiers.cache.is_some() {
|
||||
attributes.push(quote! { (cache) });
|
||||
}
|
||||
|
@ -340,45 +343,27 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
|
|||
// be very useful.
|
||||
let span = name.span();
|
||||
let attribute_stream = quote_spanned! {span=> #(#attributes),*};
|
||||
let doc_comments = query.doc_comments.iter();
|
||||
let doc_comments = &query.doc_comments;
|
||||
// Add the query to the group
|
||||
query_stream.extend(quote! {
|
||||
#(#doc_comments)*
|
||||
[#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! $( [$($other:tt)*] )?) => {
|
||||
$macro! {
|
||||
$( $($other)* )?
|
||||
#query_stream
|
||||
}
|
||||
}
|
||||
}
|
||||
macro_rules! rustc_dep_node_append {
|
||||
($macro:ident! [$($other:tt)*]) => {
|
||||
$macro!(
|
||||
$($other)*
|
||||
|
||||
#dep_node_def_stream
|
||||
);
|
||||
}
|
||||
}
|
||||
#[macro_export]
|
||||
macro_rules! rustc_cached_queries {
|
||||
( $macro:ident! ) => {
|
||||
$macro!(#cached_queries);
|
||||
}
|
||||
}
|
||||
#[macro_export]
|
||||
macro_rules! rustc_query_description {
|
||||
#query_description_stream
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue