mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
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`.
This commit is contained in:
parent
699bfa882b
commit
05886e28a4
@ -328,7 +328,7 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
let mut query_stream = quote! {};
|
let mut query_stream = quote! {};
|
||||||
let mut query_description_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! {};
|
let mut cached_queries = quote! {};
|
||||||
|
|
||||||
for query in queries.0 {
|
for query in queries.0 {
|
||||||
@ -344,6 +344,7 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
|
|||||||
#name,
|
#name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
all_names.extend(quote! { #name, });
|
||||||
|
|
||||||
let mut attributes = Vec::new();
|
let mut attributes = Vec::new();
|
||||||
|
|
||||||
@ -400,35 +401,30 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
|
|||||||
[#attribute_stream] fn #name(#arg) #result,
|
[#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);
|
add_query_description_impl(&query, &mut query_description_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenStream::from(quote! {
|
TokenStream::from(quote! {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! rustc_query_append {
|
macro_rules! rustc_query_append {
|
||||||
($macro:ident !) => {
|
($macro:ident!) => {
|
||||||
$macro! {
|
$macro! {
|
||||||
#query_stream
|
#query_stream
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
macro_rules! rustc_dep_node_append {
|
#[macro_export]
|
||||||
($macro:ident! [$($other:tt)*]) => {
|
macro_rules! rustc_query_names {
|
||||||
|
($macro:ident! $( [$($other:tt)*] )?) => {
|
||||||
$macro!(
|
$macro!(
|
||||||
$($other)*
|
$( $($other)* )?
|
||||||
|
#all_names
|
||||||
#dep_node_def_stream
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! rustc_cached_queries {
|
macro_rules! rustc_cached_queries {
|
||||||
( $macro:ident! ) => {
|
($macro:ident!) => {
|
||||||
$macro!(#cached_queries);
|
$macro!(#cached_queries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,10 +144,7 @@ impl DepKind {
|
|||||||
|
|
||||||
macro_rules! define_dep_nodes {
|
macro_rules! define_dep_nodes {
|
||||||
(
|
(
|
||||||
$(
|
$( $variant:ident, )*
|
||||||
[$($attrs:tt)*]
|
|
||||||
$variant:ident $(( $tuple_arg_ty:ty $(,)? ))*
|
|
||||||
,)*
|
|
||||||
) => (
|
) => (
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_dep_kind_array {
|
macro_rules! make_dep_kind_array {
|
||||||
@ -179,21 +176,14 @@ macro_rules! define_dep_nodes {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
rustc_dep_node_append!(define_dep_nodes![
|
rustc_query_names!(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,
|
||||||
|
|
||||||
// We use this to create a forever-red node.
|
// We use this to create a forever-red node.
|
||||||
[] Red,
|
Red,
|
||||||
|
TraitSelect,
|
||||||
[anon] TraitSelect,
|
CompileCodegenUnit,
|
||||||
|
CompileMonoItem,
|
||||||
// WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
|
|
||||||
[] CompileCodegenUnit(Symbol),
|
|
||||||
|
|
||||||
// WARNING: if `MonoItem` is changed, make sure you update `make_compile_mono_item` below.
|
|
||||||
// Only used by rustc_codegen_cranelift
|
|
||||||
[] CompileMonoItem(MonoItem),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
|
// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
|
||||||
|
@ -307,7 +307,7 @@ pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
|
|||||||
|
|
||||||
macro_rules! alloc_once {
|
macro_rules! alloc_once {
|
||||||
(
|
(
|
||||||
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident($K:ty) -> $V:ty,)*
|
$($name:ident,)*
|
||||||
) => {
|
) => {
|
||||||
$({
|
$({
|
||||||
alloc_self_profile_query_strings_for_query_cache(
|
alloc_self_profile_query_strings_for_query_cache(
|
||||||
@ -320,5 +320,5 @@ pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rustc_query_append! { alloc_once! }
|
rustc_query_names! { alloc_once! }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user