Skip to content

Commit 4065b89

Browse files
committed
Auto merge of rust-lang#100946 - jyn514:query-system-3, r=cjgillot
Simplify the arguments to macros generated by the `rustc_queries` proc macro Very small cleanup. Based on rust-lang#100436 which modifies some of the same code. r? `@cjgillot`
2 parents d0e1491 + b061550 commit 4065b89

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

Diff for: compiler/rustc_macros/src/query.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
265265
let try_load_from_disk = if let Some((tcx, id, block)) = modifiers.load_cached.as_ref() {
266266
// Use custom code to load the query from disk
267267
quote! {
268-
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<$tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
268+
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
269269
= Some(|#tcx, #id| { #block });
270270
}
271271
} else {
272272
// Use the default code to load the query from disk
273273
quote! {
274-
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<$tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
274+
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
275275
= Some(|tcx, id| tcx.on_disk_cache().as_ref()?.try_load_query_result(*tcx, id));
276276
}
277277
};
@@ -298,7 +298,7 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
298298
false
299299
}
300300

301-
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<$tcx>, SerializedDepNodeIndex) -> Option<Self::Value>> = None;
301+
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>> = None;
302302
}
303303
};
304304

@@ -307,7 +307,7 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
307307

308308
let desc = quote! {
309309
#[allow(unused_variables)]
310-
fn describe(tcx: QueryCtxt<$tcx>, key: Self::Key) -> String {
310+
fn describe(tcx: QueryCtxt<'tcx>, key: Self::Key) -> String {
311311
let (#tcx, #key) = (*tcx, key);
312312
::rustc_middle::ty::print::with_no_trimmed_paths!(
313313
format!(#desc)
@@ -316,7 +316,7 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
316316
};
317317

318318
impls.extend(quote! {
319-
(#name<$tcx:tt>) => {
319+
(#name) => {
320320
#desc
321321
#cache
322322
};
@@ -411,15 +411,15 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
411411
TokenStream::from(quote! {
412412
#[macro_export]
413413
macro_rules! rustc_query_append {
414-
([$($macro:tt)*]) => {
415-
$($macro)* {
414+
($macro:ident !) => {
415+
$macro! {
416416
#query_stream
417417
}
418418
}
419419
}
420420
macro_rules! rustc_dep_node_append {
421-
([$($macro:tt)*][$($other:tt)*]) => {
422-
$($macro)*(
421+
($macro:ident! [$($other:tt)*]) => {
422+
$macro!(
423423
$($other)*
424424

425425
#dep_node_def_stream
@@ -428,8 +428,8 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
428428
}
429429
#[macro_export]
430430
macro_rules! rustc_cached_queries {
431-
($($macro:tt)*) => {
432-
$($macro)*(#cached_queries);
431+
( $macro:ident! ) => {
432+
$macro!(#cached_queries);
433433
}
434434
}
435435
#[macro_export]

Diff for: compiler/rustc_middle/src/dep_graph/dep_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ macro_rules! define_dep_nodes {
179179
);
180180
}
181181

182-
rustc_dep_node_append!([define_dep_nodes!][
182+
rustc_dep_node_append!(define_dep_nodes![
183183
// We use this for most things when incr. comp. is turned off.
184184
[] Null,
185185

Diff for: compiler/rustc_middle/src/ty/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ macro_rules! define_callbacks {
332332
// Queries marked with `fatal_cycle` do not need the latter implementation,
333333
// as they will raise an fatal error on query cycles instead.
334334

335-
rustc_query_append! { [define_callbacks!] }
335+
rustc_query_append! { define_callbacks! }
336336

337337
mod sealed {
338338
use super::{DefId, LocalDefId};

Diff for: compiler/rustc_query_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
5454
}
5555
}
5656

57-
rustc_query_append! { [define_queries!] }
57+
rustc_query_append! { define_queries! }
5858

5959
impl<'tcx> Queries<'tcx> {
6060
// Force codegen in the dyn-trait transformation in this crate.

Diff for: compiler/rustc_query_impl/src/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ macro_rules! define_queries {
339339
}
340340

341341
impl<'tcx> QueryDescription<QueryCtxt<'tcx>> for queries::$name<'tcx> {
342-
rustc_query_description! { $name<'tcx> }
342+
rustc_query_description! { $name }
343343

344344
type Cache = query_storage::$name<'tcx>;
345345

Diff for: compiler/rustc_query_impl/src/profiling_support.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,5 +320,5 @@ pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
320320
}
321321
}
322322

323-
rustc_query_append! { [alloc_once!] }
323+
rustc_query_append! { alloc_once! }
324324
}

0 commit comments

Comments
 (0)