1
Fork 0

Simplify the syntax for macros generated by rustc_queries

- Disallow multiple macros callbacks in the same invocation. In practice, this was never used.
- Remove the `[]` brackets around the macro name
- Require an `ident`, not an arbitrary `tt`
This commit is contained in:
Joshua Nelson 2022-08-24 00:02:37 -05:00
parent e188868014
commit 7b8e2a52ff
5 changed files with 10 additions and 10 deletions

View file

@ -400,15 +400,15 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
TokenStream::from(quote! { TokenStream::from(quote! {
#[macro_export] #[macro_export]
macro_rules! rustc_query_append { macro_rules! rustc_query_append {
([$($macro:tt)*]) => { ($macro:ident !) => {
$($macro)* { $macro! {
#query_stream #query_stream
} }
} }
} }
macro_rules! rustc_dep_node_append { macro_rules! rustc_dep_node_append {
([$($macro:tt)*][$($other:tt)*]) => { ($macro:ident! [$($other:tt)*]) => {
$($macro)*( $macro!(
$($other)* $($other)*
#dep_node_def_stream #dep_node_def_stream
@ -417,8 +417,8 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
} }
#[macro_export] #[macro_export]
macro_rules! rustc_cached_queries { macro_rules! rustc_cached_queries {
($($macro:tt)*) => { ( $macro:ident! ) => {
$($macro)*(#cached_queries); $macro!(#cached_queries);
} }
} }
#[macro_export] #[macro_export]

View file

@ -179,7 +179,7 @@ macro_rules! define_dep_nodes {
); );
} }
rustc_dep_node_append!([define_dep_nodes!][ rustc_dep_node_append!(define_dep_nodes![
// We use this for most things when incr. comp. is turned off. // We use this for most things when incr. comp. is turned off.
[] Null, [] Null,

View file

@ -332,7 +332,7 @@ macro_rules! define_callbacks {
// Queries marked with `fatal_cycle` do not need the latter implementation, // Queries marked with `fatal_cycle` do not need the latter implementation,
// as they will raise an fatal error on query cycles instead. // as they will raise an fatal error on query cycles instead.
rustc_query_append! { [define_callbacks!] } rustc_query_append! { define_callbacks! }
mod sealed { mod sealed {
use super::{DefId, LocalDefId}; use super::{DefId, LocalDefId};

View file

@ -54,7 +54,7 @@ fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
} }
} }
rustc_query_append! { [define_queries!] } rustc_query_append! { define_queries! }
impl<'tcx> Queries<'tcx> { impl<'tcx> Queries<'tcx> {
// Force codegen in the dyn-trait transformation in this crate. // Force codegen in the dyn-trait transformation in this crate.

View file

@ -320,5 +320,5 @@ pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
} }
} }
rustc_query_append! { [alloc_once!] } rustc_query_append! { alloc_once! }
} }