Skip to content

Commit 285524f

Browse files
Rollup merge of #81609 - Julian-Wollersberger:no-query-categories, r=davidtwco
Remove the remains of query categories Back in October 2020 in #77830 ``@cjgillot`` removed the query categories information from the profiler, but the actual definitions which query was in which category remained, although unused. Here I clean that up, to simplify the query definitions even further. It's unfortunate that this loses all the context for `git blame`, ~~but I'm working on moving those query definitions into `rustc_query_system`, which will lose that context anyway.~~ EDIT: Might not work out. The functional changes are in the first commit. The second one only changes the indentation.
2 parents 255e076 + 988d93c commit 285524f

File tree

2 files changed

+1392
-1506
lines changed

2 files changed

+1392
-1506
lines changed

compiler/rustc_macros/src/query.rs

+52-73
Original file line numberDiff line numberDiff line change
@@ -189,25 +189,6 @@ impl<T: Parse> Parse for List<T> {
189189
}
190190
}
191191

192-
/// A named group containing queries.
193-
///
194-
/// For now, the name is not used any more, but the capability remains interesting for future
195-
/// developments of the query system.
196-
struct Group {
197-
#[allow(unused)]
198-
name: Ident,
199-
queries: List<Query>,
200-
}
201-
202-
impl Parse for Group {
203-
fn parse(input: ParseStream<'_>) -> Result<Self> {
204-
let name: Ident = input.parse()?;
205-
let content;
206-
braced!(content in input);
207-
Ok(Group { name, queries: content.parse()? })
208-
}
209-
}
210-
211192
struct QueryModifiers {
212193
/// The description of the query.
213194
desc: (Option<Ident>, Punctuated<Expr, Token![,]>),
@@ -450,72 +431,70 @@ fn add_query_description_impl(
450431
}
451432

452433
pub fn rustc_queries(input: TokenStream) -> TokenStream {
453-
let groups = parse_macro_input!(input as List<Group>);
434+
let queries = parse_macro_input!(input as List<Query>);
454435

455436
let mut query_stream = quote! {};
456437
let mut query_description_stream = quote! {};
457438
let mut dep_node_def_stream = quote! {};
458439
let mut cached_queries = quote! {};
459440

460-
for group in groups.0 {
461-
for mut query in group.queries.0 {
462-
let modifiers = process_modifiers(&mut query);
463-
let name = &query.name;
464-
let arg = &query.arg;
465-
let result_full = &query.result;
466-
let result = match query.result {
467-
ReturnType::Default => quote! { -> () },
468-
_ => quote! { #result_full },
469-
};
441+
for mut query in queries.0 {
442+
let modifiers = process_modifiers(&mut query);
443+
let name = &query.name;
444+
let arg = &query.arg;
445+
let result_full = &query.result;
446+
let result = match query.result {
447+
ReturnType::Default => quote! { -> () },
448+
_ => quote! { #result_full },
449+
};
470450

471-
if modifiers.cache.is_some() {
472-
cached_queries.extend(quote! {
473-
#name,
474-
});
475-
}
451+
if modifiers.cache.is_some() {
452+
cached_queries.extend(quote! {
453+
#name,
454+
});
455+
}
476456

477-
let mut attributes = Vec::new();
457+
let mut attributes = Vec::new();
478458

479-
// Pass on the fatal_cycle modifier
480-
if modifiers.fatal_cycle {
481-
attributes.push(quote! { fatal_cycle });
482-
};
483-
// Pass on the storage modifier
484-
if let Some(ref ty) = modifiers.storage {
485-
attributes.push(quote! { storage(#ty) });
486-
};
487-
// Pass on the cycle_delay_bug modifier
488-
if modifiers.cycle_delay_bug {
489-
attributes.push(quote! { cycle_delay_bug });
490-
};
491-
// Pass on the no_hash modifier
492-
if modifiers.no_hash {
493-
attributes.push(quote! { no_hash });
494-
};
495-
// Pass on the anon modifier
496-
if modifiers.anon {
497-
attributes.push(quote! { anon });
498-
};
499-
// Pass on the eval_always modifier
500-
if modifiers.eval_always {
501-
attributes.push(quote! { eval_always });
502-
};
459+
// Pass on the fatal_cycle modifier
460+
if modifiers.fatal_cycle {
461+
attributes.push(quote! { fatal_cycle });
462+
};
463+
// Pass on the storage modifier
464+
if let Some(ref ty) = modifiers.storage {
465+
attributes.push(quote! { storage(#ty) });
466+
};
467+
// Pass on the cycle_delay_bug modifier
468+
if modifiers.cycle_delay_bug {
469+
attributes.push(quote! { cycle_delay_bug });
470+
};
471+
// Pass on the no_hash modifier
472+
if modifiers.no_hash {
473+
attributes.push(quote! { no_hash });
474+
};
475+
// Pass on the anon modifier
476+
if modifiers.anon {
477+
attributes.push(quote! { anon });
478+
};
479+
// Pass on the eval_always modifier
480+
if modifiers.eval_always {
481+
attributes.push(quote! { eval_always });
482+
};
503483

504-
let attribute_stream = quote! {#(#attributes),*};
505-
let doc_comments = query.doc_comments.iter();
506-
// Add the query to the group
507-
query_stream.extend(quote! {
508-
#(#doc_comments)*
509-
[#attribute_stream] fn #name(#arg) #result,
510-
});
484+
let attribute_stream = quote! {#(#attributes),*};
485+
let doc_comments = query.doc_comments.iter();
486+
// Add the query to the group
487+
query_stream.extend(quote! {
488+
#(#doc_comments)*
489+
[#attribute_stream] fn #name(#arg) #result,
490+
});
511491

512-
// Create a dep node for the query
513-
dep_node_def_stream.extend(quote! {
514-
[#attribute_stream] #name(#arg),
515-
});
492+
// Create a dep node for the query
493+
dep_node_def_stream.extend(quote! {
494+
[#attribute_stream] #name(#arg),
495+
});
516496

517-
add_query_description_impl(&query, modifiers, &mut query_description_stream);
518-
}
497+
add_query_description_impl(&query, modifiers, &mut query_description_stream);
519498
}
520499

521500
TokenStream::from(quote! {

0 commit comments

Comments
 (0)