Skip to content

Commit c630c87

Browse files
committed
Support doc-comments in define_dep_nodes
1 parent 05886e2 commit c630c87

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

compiler/rustc_macros/src/query.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
344344
#name,
345345
});
346346
}
347-
all_names.extend(quote! { #name, });
348347

349348
let mut attributes = Vec::new();
350349

@@ -394,13 +393,18 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
394393
// be very useful.
395394
let span = name.span();
396395
let attribute_stream = quote_spanned! {span=> #(#attributes),*};
397-
let doc_comments = query.doc_comments.iter();
396+
let doc_comments = &query.doc_comments;
398397
// Add the query to the group
399398
query_stream.extend(quote! {
400399
#(#doc_comments)*
401400
[#attribute_stream] fn #name(#arg) #result,
402401
});
403402

403+
all_names.extend(quote! {
404+
#(#doc_comments)*
405+
#name,
406+
});
407+
404408
add_query_description_impl(&query, &mut query_description_stream);
405409
}
406410

compiler/rustc_middle/src/dep_graph/dep_node.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl DepKind {
144144

145145
macro_rules! define_dep_nodes {
146146
(
147-
$( $variant:ident, )*
147+
$( $( #[$attr:meta] )* $variant:ident, )+
148148
) => (
149149
#[macro_export]
150150
macro_rules! make_dep_kind_array {
@@ -155,7 +155,7 @@ macro_rules! define_dep_nodes {
155155
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
156156
#[allow(non_camel_case_types)]
157157
pub enum DepKind {
158-
$($variant),*
158+
$( $( #[$attr] )* $variant),*
159159
}
160160

161161
fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
@@ -177,9 +177,9 @@ macro_rules! define_dep_nodes {
177177
}
178178

179179
rustc_query_names!(define_dep_nodes![
180-
// We use this for most things when incr. comp. is turned off.
180+
/// We use this for most things when incr. comp. is turned off.
181181
Null,
182-
// We use this to create a forever-red node.
182+
/// We use this to create a forever-red node.
183183
Red,
184184
TraitSelect,
185185
CompileCodegenUnit,

compiler/rustc_query_impl/src/profiling_support.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
307307

308308
macro_rules! alloc_once {
309309
(
310-
$($name:ident,)*
310+
$( $( #[$attr:meta] )* $name:ident, )+
311311
) => {
312312
$({
313313
alloc_self_profile_query_strings_for_query_cache(
@@ -316,7 +316,7 @@ pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
316316
&tcx.query_caches.$name,
317317
&mut string_cache,
318318
);
319-
})*
319+
})+
320320
}
321321
}
322322

0 commit comments

Comments
 (0)