Skip to content

Commit 76531be

Browse files
committed
Auto merge of rust-lang#100436 - jyn514:macro-query-system, r=cjgillot
try and simplify some things in the query system
2 parents 9b9bc63 + e188868 commit 76531be

File tree

7 files changed

+120
-113
lines changed

7 files changed

+120
-113
lines changed

compiler/rustc_macros/src/query.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,8 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
400400
TokenStream::from(quote! {
401401
#[macro_export]
402402
macro_rules! rustc_query_append {
403-
([$($macro:tt)*][$($other:tt)*]) => {
403+
([$($macro:tt)*]) => {
404404
$($macro)* {
405-
$($other)*
406-
407405
#query_stream
408406
}
409407
}

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ impl ProcessQueryValue<'_, Option<DeprecationEntry>> for Option<Deprecation> {
7676
}
7777

7878
macro_rules! provide_one {
79-
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => { table }) => {
79+
($tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => { table }) => {
8080
provide_one! {
81-
<$lt> $tcx, $def_id, $other, $cdata, $name => {
81+
$tcx, $def_id, $other, $cdata, $name => {
8282
$cdata
8383
.root
8484
.tables
@@ -89,9 +89,9 @@ macro_rules! provide_one {
8989
}
9090
}
9191
};
92-
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => { table_direct }) => {
92+
($tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => { table_direct }) => {
9393
provide_one! {
94-
<$lt> $tcx, $def_id, $other, $cdata, $name => {
94+
$tcx, $def_id, $other, $cdata, $name => {
9595
// We don't decode `table_direct`, since it's not a Lazy, but an actual value
9696
$cdata
9797
.root
@@ -102,11 +102,11 @@ macro_rules! provide_one {
102102
}
103103
}
104104
};
105-
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => $compute:block) => {
106-
fn $name<$lt>(
107-
$tcx: TyCtxt<$lt>,
108-
def_id_arg: ty::query::query_keys::$name<$lt>,
109-
) -> ty::query::query_values::$name<$lt> {
105+
($tcx:ident, $def_id:ident, $other:ident, $cdata:ident, $name:ident => $compute:block) => {
106+
fn $name<'tcx>(
107+
$tcx: TyCtxt<'tcx>,
108+
def_id_arg: ty::query::query_keys::$name<'tcx>,
109+
) -> ty::query::query_values::$name<'tcx> {
110110
let _prof_timer =
111111
$tcx.prof.generic_activity(concat!("metadata_decode_entry_", stringify!($name)));
112112

@@ -130,11 +130,11 @@ macro_rules! provide_one {
130130
}
131131

132132
macro_rules! provide {
133-
(<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
133+
($tcx:ident, $def_id:ident, $other:ident, $cdata:ident,
134134
$($name:ident => { $($compute:tt)* })*) => {
135135
pub fn provide_extern(providers: &mut ExternProviders) {
136136
$(provide_one! {
137-
<$lt> $tcx, $def_id, $other, $cdata, $name => { $($compute)* }
137+
$tcx, $def_id, $other, $cdata, $name => { $($compute)* }
138138
})*
139139

140140
*providers = ExternProviders {
@@ -187,7 +187,7 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
187187
}
188188
}
189189

190-
provide! { <'tcx> tcx, def_id, other, cdata,
190+
provide! { tcx, def_id, other, cdata,
191191
explicit_item_bounds => { table }
192192
explicit_predicates_of => { table }
193193
generics_of => { table }

compiler/rustc_middle/src/dep_graph/dep_node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl DepKind {
143143
}
144144

145145
macro_rules! define_dep_nodes {
146-
(<$tcx:tt>
146+
(
147147
$(
148148
[$($attrs:tt)*]
149149
$variant:ident $(( $tuple_arg_ty:ty $(,)? ))*
@@ -179,7 +179,7 @@ macro_rules! define_dep_nodes {
179179
);
180180
}
181181

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

compiler/rustc_middle/src/ty/query.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ macro_rules! opt_remap_env_constness {
173173
}
174174

175175
macro_rules! define_callbacks {
176-
(<$tcx:tt>
176+
(
177177
$($(#[$attr:meta])*
178178
[$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {
179179

@@ -187,33 +187,33 @@ macro_rules! define_callbacks {
187187
pub mod query_keys {
188188
use super::*;
189189

190-
$(pub type $name<$tcx> = $($K)*;)*
190+
$(pub type $name<'tcx> = $($K)*;)*
191191
}
192192
#[allow(nonstandard_style, unused_lifetimes)]
193193
pub mod query_values {
194194
use super::*;
195195

196-
$(pub type $name<$tcx> = $V;)*
196+
$(pub type $name<'tcx> = $V;)*
197197
}
198198
#[allow(nonstandard_style, unused_lifetimes)]
199199
pub mod query_storage {
200200
use super::*;
201201

202-
$(pub type $name<$tcx> = query_storage!([$($modifiers)*][$($K)*, $V]);)*
202+
$(pub type $name<'tcx> = query_storage!([$($modifiers)*][$($K)*, $V]);)*
203203
}
204204
#[allow(nonstandard_style, unused_lifetimes)]
205205
pub mod query_stored {
206206
use super::*;
207207

208-
$(pub type $name<$tcx> = <query_storage::$name<$tcx> as QueryStorage>::Stored;)*
208+
$(pub type $name<'tcx> = <query_storage::$name<'tcx> as QueryStorage>::Stored;)*
209209
}
210210

211211
#[derive(Default)]
212-
pub struct QueryCaches<$tcx> {
213-
$($(#[$attr])* pub $name: query_storage::$name<$tcx>,)*
212+
pub struct QueryCaches<'tcx> {
213+
$($(#[$attr])* pub $name: query_storage::$name<'tcx>,)*
214214
}
215215

216-
impl<$tcx> TyCtxtEnsure<$tcx> {
216+
impl<'tcx> TyCtxtEnsure<'tcx> {
217217
$($(#[$attr])*
218218
#[inline(always)]
219219
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
@@ -231,20 +231,20 @@ macro_rules! define_callbacks {
231231
})*
232232
}
233233

234-
impl<$tcx> TyCtxt<$tcx> {
234+
impl<'tcx> TyCtxt<'tcx> {
235235
$($(#[$attr])*
236236
#[inline(always)]
237237
#[must_use]
238-
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<$tcx>
238+
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<'tcx>
239239
{
240240
self.at(DUMMY_SP).$name(key)
241241
})*
242242
}
243243

244-
impl<$tcx> TyCtxtAt<$tcx> {
244+
impl<'tcx> TyCtxtAt<'tcx> {
245245
$($(#[$attr])*
246246
#[inline(always)]
247-
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<$tcx>
247+
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<'tcx>
248248
{
249249
let key = key.into_query_param();
250250
opt_remap_env_constness!([$($modifiers)*][key]);
@@ -311,11 +311,11 @@ macro_rules! define_callbacks {
311311
$($(#[$attr])*
312312
fn $name(
313313
&'tcx self,
314-
tcx: TyCtxt<$tcx>,
314+
tcx: TyCtxt<'tcx>,
315315
span: Span,
316-
key: query_keys::$name<$tcx>,
316+
key: query_keys::$name<'tcx>,
317317
mode: QueryMode,
318-
) -> Option<query_stored::$name<$tcx>>;)*
318+
) -> Option<query_stored::$name<'tcx>>;)*
319319
}
320320
};
321321
}
@@ -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!][<'tcx>] }
335+
rustc_query_append! { [define_callbacks!] }
336336

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

compiler/rustc_query_impl/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ extern crate rustc_macros;
1515
#[macro_use]
1616
extern crate rustc_middle;
1717

18-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1918
use rustc_data_structures::sync::AtomicU64;
2019
use rustc_middle::arena::Arena;
2120
use rustc_middle::dep_graph::{self, DepKindStruct, SerializedDepNodeIndex};
@@ -55,7 +54,7 @@ fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
5554
}
5655
}
5756

58-
rustc_query_append! { [define_queries!][<'tcx>] }
57+
rustc_query_append! { [define_queries!] }
5958

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

0 commit comments

Comments
 (0)