Simplify the implementation of rustc_queries

This commit is contained in:
Joshua Nelson 2022-09-01 21:21:29 -05:00
parent fb0c36a3fe
commit b7c9687d2e

View File

@ -344,43 +344,26 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
let mut attributes = Vec::new(); let mut attributes = Vec::new();
// Pass on the fatal_cycle modifier macro_rules! passthrough {
if let Some(fatal_cycle) = &modifiers.fatal_cycle { ( $( $modifier:ident ),+ $(,)? ) => {
attributes.push(quote! { (#fatal_cycle) }); $( if let Some($modifier) = &modifiers.$modifier {
}; attributes.push(quote! { (#$modifier) });
// Pass on the arena modifier }; )+
if let Some(ref arena_cache) = modifiers.arena_cache { }
attributes.push(quote! {span=> (#arena_cache) });
};
// Pass on the cycle_delay_bug modifier
if let Some(cycle_delay_bug) = &modifiers.cycle_delay_bug {
attributes.push(quote! { (#cycle_delay_bug) });
};
// Pass on the no_hash modifier
if let Some(no_hash) = &modifiers.no_hash {
attributes.push(quote! { (#no_hash) });
};
// Pass on the anon modifier
if let Some(anon) = &modifiers.anon {
attributes.push(quote! { (#anon) });
};
// Pass on the eval_always modifier
if let Some(eval_always) = &modifiers.eval_always {
attributes.push(quote! { (#eval_always) });
};
// Pass on the depth_limit modifier
if let Some(depth_limit) = &modifiers.depth_limit {
attributes.push(quote! { (#depth_limit) });
};
// Pass on the separate_provide_extern modifier
if let Some(separate_provide_extern) = &modifiers.separate_provide_extern {
attributes.push(quote! { (#separate_provide_extern) });
}
// Pass on the remap_env_constness modifier
if let Some(remap_env_constness) = &modifiers.remap_env_constness {
attributes.push(quote! { (#remap_env_constness) });
} }
passthrough!(
fatal_cycle,
arena_cache,
cycle_delay_bug,
no_hash,
anon,
eval_always,
depth_limit,
separate_provide_extern,
remap_env_constness,
);
// This uses the span of the query definition for the commas, // This uses the span of the query definition for the commas,
// which can be important if we later encounter any ambiguity // which can be important if we later encounter any ambiguity
// errors with any of the numerous macro_rules! macros that // errors with any of the numerous macro_rules! macros that