Skip to content

Commit

Permalink
Remove unused category from macros.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 22, 2020
1 parent 0a4d948 commit de76370
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
11 changes: 5 additions & 6 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ impl<T: Parse> Parse for List<T> {
}

/// A named group containing queries.
///
/// For now, the name is not used any more, but the capability remains interesting for future
/// developments of the query system.
struct Group {
#[allow(unused)]
name: Ident,
queries: List<Query>,
}
Expand Down Expand Up @@ -422,7 +426,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
let mut cached_queries = quote! {};

for group in groups.0 {
let mut group_stream = quote! {};
for mut query in group.queries.0 {
let modifiers = process_modifiers(&mut query);
let name = &query.name;
Expand Down Expand Up @@ -485,7 +488,7 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
let attribute_stream = quote! {#(#attributes),*};
let doc_comments = query.doc_comments.iter();
// Add the query to the group
group_stream.extend(quote! {
query_stream.extend(quote! {
#(#doc_comments)*
[#attribute_stream] fn #name: #name(#arg) #result,
});
Expand Down Expand Up @@ -514,10 +517,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {

add_query_description_impl(&query, modifiers, &mut query_description_stream);
}
let name = &group.name;
query_stream.extend(quote! {
#name { #group_stream },
});
}

dep_node_force_stream.extend(quote! {
Expand Down
14 changes: 2 additions & 12 deletions compiler/rustc_middle/src/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,24 +242,14 @@ macro_rules! hash_result {
};
}

macro_rules! define_queries {
(<$tcx:tt> $($category:tt {
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident: $node:ident($($K:tt)*) -> $V:ty,)*
},)*) => {
define_queries_inner! { <$tcx>
$($( $(#[$attr])* category<$category> [$($modifiers)*] fn $name: $node($($K)*) -> $V,)*)*
}
}
}

macro_rules! query_helper_param_ty {
(DefId) => { impl IntoQueryParam<DefId> };
($K:ty) => { $K };
}

macro_rules! define_queries_inner {
macro_rules! define_queries {
(<$tcx:tt>
$($(#[$attr:meta])* category<$category:tt>
$($(#[$attr:meta])*
[$($modifiers:tt)*] fn $name:ident: $node:ident($($K:tt)*) -> $V:ty,)*) => {

use std::mem;
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/ty/query/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ pub fn print_stats(tcx: TyCtxt<'_>) {
}

macro_rules! print_stats {
(<$tcx:tt> $($category:tt {
(<$tcx:tt>
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*
},)*) => {
) => {
fn query_stats(tcx: TyCtxt<'_>) -> Vec<QueryStats> {
let mut queries = Vec::new();

$($(
$(
queries.push(stats::<
crate::dep_graph::DepKind,
<TyCtxt<'_> as QueryContext>::Query,
Expand All @@ -135,7 +135,7 @@ macro_rules! print_stats {
stringify!($name),
&tcx.queries.$name,
));
)*)*
)*

queries
}
Expand Down

0 comments on commit de76370

Please sign in to comment.