diff options
| author | Joshua Nelson <jnelson@cloudflare.com> | 2022-09-01 21:21:29 -0500 |
|---|---|---|
| committer | Joshua Nelson <jnelson@cloudflare.com> | 2022-09-09 20:16:47 -0500 |
| commit | b7c9687d2e2504de0e0047b19fec00c54efc08a7 (patch) | |
| tree | 11118a623f7a2042ccb0a81d67445daa5d0c0afe | |
| parent | fb0c36a3fe8d6da31c221cf3b65e6e316e7d9c8e (diff) | |
| download | rust-b7c9687d2e2504de0e0047b19fec00c54efc08a7.tar.gz rust-b7c9687d2e2504de0e0047b19fec00c54efc08a7.zip | |
Simplify the implementation of `rustc_queries`
| -rw-r--r-- | compiler/rustc_macros/src/query.rs | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index a99cba817d9..77fb997dc48 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -344,43 +344,26 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { let mut attributes = Vec::new(); - // Pass on the fatal_cycle modifier - if let Some(fatal_cycle) = &modifiers.fatal_cycle { - attributes.push(quote! { (#fatal_cycle) }); - }; - // 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) }); + macro_rules! passthrough { + ( $( $modifier:ident ),+ $(,)? ) => { + $( if let Some($modifier) = &modifiers.$modifier { + attributes.push(quote! { (#$modifier) }); + }; )+ + } } + 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, // which can be important if we later encounter any ambiguity // errors with any of the numerous macro_rules! macros that |
