]> git.lizzy.rs Git - rust.git/commitdiff
Simplify the syntax for macros generated by `rustc_queries`
authorJoshua Nelson <jnelson@cloudflare.com>
Wed, 24 Aug 2022 05:02:37 +0000 (00:02 -0500)
committerJoshua Nelson <jnelson@cloudflare.com>
Wed, 24 Aug 2022 05:37:49 +0000 (00:37 -0500)
- 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`

compiler/rustc_macros/src/query.rs
compiler/rustc_middle/src/dep_graph/dep_node.rs
compiler/rustc_middle/src/ty/query.rs
compiler/rustc_query_impl/src/lib.rs
compiler/rustc_query_impl/src/profiling_support.rs

index 32a15413c6fefda6d6d9ff962faae45b82aa2fe7..d80d35cb1fa322d09c5ac1ac3a42c404d1b29631 100644 (file)
@@ -400,15 +400,15 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
     TokenStream::from(quote! {
         #[macro_export]
         macro_rules! rustc_query_append {
-            ([$($macro:tt)*]) => {
-                $($macro)* {
+            ($macro:ident !) => {
+                $macro! {
                     #query_stream
                 }
             }
         }
         macro_rules! rustc_dep_node_append {
-            ([$($macro:tt)*][$($other:tt)*]) => {
-                $($macro)*(
+            ($macro:ident! [$($other:tt)*]) => {
+                $macro!(
                     $($other)*
 
                     #dep_node_def_stream
@@ -417,8 +417,8 @@ macro_rules! rustc_dep_node_append {
         }
         #[macro_export]
         macro_rules! rustc_cached_queries {
-            ($($macro:tt)*) => {
-                $($macro)*(#cached_queries);
+            ( $macro:ident! ) => {
+                $macro!(#cached_queries);
             }
         }
         #[macro_export]
index 156a9641272f57ecbc2b44f61cf4c1f3285b2ab6..65fc8a2e9cf5a4413e309a96726c9ea85126aae2 100644 (file)
@@ -179,7 +179,7 @@ pub mod label_strs {
     );
 }
 
-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.
     [] Null,
 
index 736ab69c81219059987ab1ffaaf736fd50bee441..5665bb866d46c68218d2cf9a09f7fd6a99d184d4 100644 (file)
@@ -332,7 +332,7 @@ fn $name(
 // Queries marked with `fatal_cycle` do not need the latter implementation,
 // as they will raise an fatal error on query cycles instead.
 
-rustc_query_append! { [define_callbacks!] }
+rustc_query_append! { define_callbacks! }
 
 mod sealed {
     use super::{DefId, LocalDefId};
index 946bc34fea101878eb41931ee40e8c36624e9c7a..8ea09880694eab7e4f57dbd735cf6d56322d0080 100644 (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> {
     // Force codegen in the dyn-trait transformation in this crate.
index 3458675094713c4ba1b84c696320e3d38899b8b8..260af0d54081560e6c35e9fff98d248f862bb422 100644 (file)
@@ -320,5 +320,5 @@ macro_rules! alloc_once {
         }
     }
 
-    rustc_query_append! { [alloc_once!] }
+    rustc_query_append! { alloc_once! }
 }