Skip to content

Commit 7b8e2a5

Browse files
committed
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`
1 parent e188868 commit 7b8e2a5

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

Diff for: compiler/rustc_macros/src/query.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,15 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
400400
TokenStream::from(quote! {
401401
#[macro_export]
402402
macro_rules! rustc_query_append {
403-
([$($macro:tt)*]) => {
404-
$($macro)* {
403+
($macro:ident !) => {
404+
$macro! {
405405
#query_stream
406406
}
407407
}
408408
}
409409
macro_rules! rustc_dep_node_append {
410-
([$($macro:tt)*][$($other:tt)*]) => {
411-
$($macro)*(
410+
($macro:ident! [$($other:tt)*]) => {
411+
$macro!(
412412
$($other)*
413413

414414
#dep_node_def_stream
@@ -417,8 +417,8 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
417417
}
418418
#[macro_export]
419419
macro_rules! rustc_cached_queries {
420-
($($macro:tt)*) => {
421-
$($macro)*(#cached_queries);
420+
( $macro:ident! ) => {
421+
$macro!(#cached_queries);
422422
}
423423
}
424424
#[macro_export]

Diff for: compiler/rustc_middle/src/dep_graph/dep_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ macro_rules! define_dep_nodes {
179179
);
180180
}
181181

182-
rustc_dep_node_append!([define_dep_nodes!][
182+
rustc_dep_node_append!(define_dep_nodes![
183183
// We use this for most things when incr. comp. is turned off.
184184
[] Null,
185185

Diff for: compiler/rustc_middle/src/ty/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ macro_rules! define_callbacks {
332332
// Queries marked with `fatal_cycle` do not need the latter implementation,
333333
// as they will raise an fatal error on query cycles instead.
334334

335-
rustc_query_append! { [define_callbacks!] }
335+
rustc_query_append! { define_callbacks! }
336336

337337
mod sealed {
338338
use super::{DefId, LocalDefId};

Diff for: compiler/rustc_query_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
5454
}
5555
}
5656

57-
rustc_query_append! { [define_queries!] }
57+
rustc_query_append! { define_queries! }
5858

5959
impl<'tcx> Queries<'tcx> {
6060
// Force codegen in the dyn-trait transformation in this crate.

Diff for: compiler/rustc_query_impl/src/profiling_support.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,5 +320,5 @@ pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
320320
}
321321
}
322322

323-
rustc_query_append! { [alloc_once!] }
323+
rustc_query_append! { alloc_once! }
324324
}

0 commit comments

Comments
 (0)