Skip to content

Commit fb0c36a

Browse files
committed
Make the storage query modifier less general
In practice, it was only ever used with `ArenaCacheSelector`. Change it to a single boolean `arena_cache` rather than allowing queries to specify an arbitrary type.
1 parent 1d37ed6 commit fb0c36a

File tree

3 files changed

+59
-63
lines changed

3 files changed

+59
-63
lines changed

compiler/rustc_macros/src/query.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct QueryModifiers {
8686
desc: (Option<Ident>, Punctuated<Expr, Token![,]>),
8787

8888
/// Use this type for the in-memory cache.
89-
storage: Option<Type>,
89+
arena_cache: Option<Ident>,
9090

9191
/// Cache the query to disk if the `Block` returns true.
9292
cache: Option<(Option<Pat>, Block)>,
@@ -121,7 +121,7 @@ struct QueryModifiers {
121121

122122
fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
123123
let mut load_cached = None;
124-
let mut storage = None;
124+
let mut arena_cache = None;
125125
let mut cache = None;
126126
let mut desc = None;
127127
let mut fatal_cycle = None;
@@ -183,11 +183,8 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
183183
let id = args.parse()?;
184184
let block = input.parse()?;
185185
try_insert!(load_cached = (tcx, id, block));
186-
} else if modifier == "storage" {
187-
let args;
188-
parenthesized!(args in input);
189-
let ty = args.parse()?;
190-
try_insert!(storage = ty);
186+
} else if modifier == "arena_cache" {
187+
try_insert!(arena_cache = modifier);
191188
} else if modifier == "fatal_cycle" {
192189
try_insert!(fatal_cycle = modifier);
193190
} else if modifier == "cycle_delay_bug" {
@@ -213,7 +210,7 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
213210
};
214211
Ok(QueryModifiers {
215212
load_cached,
216-
storage,
213+
arena_cache,
217214
cache,
218215
desc,
219216
fatal_cycle,
@@ -351,10 +348,9 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
351348
if let Some(fatal_cycle) = &modifiers.fatal_cycle {
352349
attributes.push(quote! { (#fatal_cycle) });
353350
};
354-
// Pass on the storage modifier
355-
if let Some(ref ty) = modifiers.storage {
356-
let span = ty.span();
357-
attributes.push(quote_spanned! {span=> (storage #ty) });
351+
// Pass on the arena modifier
352+
if let Some(ref arena_cache) = modifiers.arena_cache {
353+
attributes.push(quote! {span=> (#arena_cache) });
358354
};
359355
// Pass on the cycle_delay_bug modifier
360356
if let Some(cycle_delay_bug) = &modifiers.cycle_delay_bug {

0 commit comments

Comments
 (0)