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.
This commit is contained in:
Joshua Nelson 2022-09-01 21:17:35 -05:00
parent 1d37ed661a
commit fb0c36a3fe
3 changed files with 59 additions and 63 deletions

View File

@ -86,7 +86,7 @@ struct QueryModifiers {
desc: (Option<Ident>, Punctuated<Expr, Token![,]>), desc: (Option<Ident>, Punctuated<Expr, Token![,]>),
/// Use this type for the in-memory cache. /// Use this type for the in-memory cache.
storage: Option<Type>, arena_cache: Option<Ident>,
/// Cache the query to disk if the `Block` returns true. /// Cache the query to disk if the `Block` returns true.
cache: Option<(Option<Pat>, Block)>, cache: Option<(Option<Pat>, Block)>,
@ -121,7 +121,7 @@ struct QueryModifiers {
fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> { fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
let mut load_cached = None; let mut load_cached = None;
let mut storage = None; let mut arena_cache = None;
let mut cache = None; let mut cache = None;
let mut desc = None; let mut desc = None;
let mut fatal_cycle = None; let mut fatal_cycle = None;
@ -183,11 +183,8 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
let id = args.parse()?; let id = args.parse()?;
let block = input.parse()?; let block = input.parse()?;
try_insert!(load_cached = (tcx, id, block)); try_insert!(load_cached = (tcx, id, block));
} else if modifier == "storage" { } else if modifier == "arena_cache" {
let args; try_insert!(arena_cache = modifier);
parenthesized!(args in input);
let ty = args.parse()?;
try_insert!(storage = ty);
} else if modifier == "fatal_cycle" { } else if modifier == "fatal_cycle" {
try_insert!(fatal_cycle = modifier); try_insert!(fatal_cycle = modifier);
} else if modifier == "cycle_delay_bug" { } else if modifier == "cycle_delay_bug" {
@ -213,7 +210,7 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
}; };
Ok(QueryModifiers { Ok(QueryModifiers {
load_cached, load_cached,
storage, arena_cache,
cache, cache,
desc, desc,
fatal_cycle, fatal_cycle,
@ -351,10 +348,9 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
if let Some(fatal_cycle) = &modifiers.fatal_cycle { if let Some(fatal_cycle) = &modifiers.fatal_cycle {
attributes.push(quote! { (#fatal_cycle) }); attributes.push(quote! { (#fatal_cycle) });
}; };
// Pass on the storage modifier // Pass on the arena modifier
if let Some(ref ty) = modifiers.storage { if let Some(ref arena_cache) = modifiers.arena_cache {
let span = ty.span(); attributes.push(quote! {span=> (#arena_cache) });
attributes.push(quote_spanned! {span=> (storage #ty) });
}; };
// Pass on the cycle_delay_bug modifier // Pass on the cycle_delay_bug modifier
if let Some(cycle_delay_bug) = &modifiers.cycle_delay_bug { if let Some(cycle_delay_bug) = &modifiers.cycle_delay_bug {

View File

@ -47,14 +47,14 @@ rustc_queries! {
/// To avoid this fate, do not call `tcx.hir().krate()`; instead, /// To avoid this fate, do not call `tcx.hir().krate()`; instead,
/// prefer wrappers like `tcx.visit_all_items_in_krate()`. /// prefer wrappers like `tcx.visit_all_items_in_krate()`.
query hir_crate(key: ()) -> Crate<'tcx> { query hir_crate(key: ()) -> Crate<'tcx> {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "get the crate HIR" } desc { "get the crate HIR" }
} }
/// All items in the crate. /// All items in the crate.
query hir_crate_items(_: ()) -> rustc_middle::hir::ModuleItems { query hir_crate_items(_: ()) -> rustc_middle::hir::ModuleItems {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "get HIR crate items" } desc { "get HIR crate items" }
} }
@ -64,7 +64,7 @@ rustc_queries! {
/// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`. /// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
/// Avoid calling this query directly. /// Avoid calling this query directly.
query hir_module_items(key: LocalDefId) -> rustc_middle::hir::ModuleItems { query hir_module_items(key: LocalDefId) -> rustc_middle::hir::ModuleItems {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) } desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) }
cache_on_disk_if { true } cache_on_disk_if { true }
} }
@ -196,7 +196,7 @@ rustc_queries! {
/// associated generics. /// associated generics.
query generics_of(key: DefId) -> ty::Generics { query generics_of(key: DefId) -> ty::Generics {
desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) } desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) }
storage(ArenaCacheSelector<'tcx>) arena_cache
cache_on_disk_if { key.is_local() } cache_on_disk_if { key.is_local() }
separate_provide_extern separate_provide_extern
} }
@ -268,13 +268,13 @@ rustc_queries! {
} }
query native_libraries(_: CrateNum) -> Vec<NativeLib> { query native_libraries(_: CrateNum) -> Vec<NativeLib> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "looking up the native libraries of a linked crate" } desc { "looking up the native libraries of a linked crate" }
separate_provide_extern separate_provide_extern
} }
query lint_levels(_: ()) -> LintLevelMap { query lint_levels(_: ()) -> LintLevelMap {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "computing the lint levels for items in this crate" } desc { "computing the lint levels for items in this crate" }
} }
@ -307,7 +307,7 @@ rustc_queries! {
/// Create a THIR tree for debugging. /// Create a THIR tree for debugging.
query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> String { query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> String {
no_hash no_hash
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key.did.to_def_id()) } desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key.did.to_def_id()) }
} }
@ -315,7 +315,7 @@ rustc_queries! {
/// them. This includes all the body owners, but also things like struct /// them. This includes all the body owners, but also things like struct
/// constructors. /// constructors.
query mir_keys(_: ()) -> rustc_data_structures::fx::FxIndexSet<LocalDefId> { query mir_keys(_: ()) -> rustc_data_structures::fx::FxIndexSet<LocalDefId> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "getting a list of all mir_keys" } desc { "getting a list of all mir_keys" }
} }
@ -422,7 +422,7 @@ rustc_queries! {
query symbols_for_closure_captures( query symbols_for_closure_captures(
key: (LocalDefId, LocalDefId) key: (LocalDefId, LocalDefId)
) -> Vec<rustc_span::Symbol> { ) -> Vec<rustc_span::Symbol> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { desc {
|tcx| "symbols for captures of closure `{}` in `{}`", |tcx| "symbols for captures of closure `{}` in `{}`",
tcx.def_path_str(key.1.to_def_id()), tcx.def_path_str(key.1.to_def_id()),
@ -442,7 +442,7 @@ rustc_queries! {
/// MIR pass (assuming the -Cinstrument-coverage option is enabled). /// MIR pass (assuming the -Cinstrument-coverage option is enabled).
query coverageinfo(key: ty::InstanceDef<'tcx>) -> mir::CoverageInfo { query coverageinfo(key: ty::InstanceDef<'tcx>) -> mir::CoverageInfo {
desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key.def_id()) } desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
storage(ArenaCacheSelector<'tcx>) arena_cache
} }
/// Returns the `CodeRegions` for a function that has instrumented coverage, in case the /// Returns the `CodeRegions` for a function that has instrumented coverage, in case the
@ -452,7 +452,7 @@ rustc_queries! {
|tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`", |tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`",
tcx.def_path_str(key) tcx.def_path_str(key)
} }
storage(ArenaCacheSelector<'tcx>) arena_cache
cache_on_disk_if { key.is_local() } cache_on_disk_if { key.is_local() }
} }
@ -490,7 +490,7 @@ rustc_queries! {
} }
query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> { query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "wasm import module map" } desc { "wasm import module map" }
} }
@ -566,7 +566,7 @@ rustc_queries! {
query trait_def(key: DefId) -> ty::TraitDef { query trait_def(key: DefId) -> ty::TraitDef {
desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) } desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) }
storage(ArenaCacheSelector<'tcx>) arena_cache
cache_on_disk_if { key.is_local() } cache_on_disk_if { key.is_local() }
separate_provide_extern separate_provide_extern
} }
@ -644,7 +644,7 @@ rustc_queries! {
/// Gets a map with the variance of every item; use `item_variance` instead. /// Gets a map with the variance of every item; use `item_variance` instead.
query crate_variances(_: ()) -> ty::CrateVariancesMap<'tcx> { query crate_variances(_: ()) -> ty::CrateVariancesMap<'tcx> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "computing the variances for items in this crate" } desc { "computing the variances for items in this crate" }
} }
@ -657,7 +657,7 @@ rustc_queries! {
/// Maps from thee `DefId` of a type to its (inferred) outlives. /// Maps from thee `DefId` of a type to its (inferred) outlives.
query inferred_outlives_crate(_: ()) -> ty::CratePredicatesMap<'tcx> { query inferred_outlives_crate(_: ()) -> ty::CratePredicatesMap<'tcx> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "computing the inferred outlives predicates for items in this crate" } desc { "computing the inferred outlives predicates for items in this crate" }
} }
@ -671,14 +671,14 @@ rustc_queries! {
/// Maps from a trait item to the trait item "descriptor". /// Maps from a trait item to the trait item "descriptor".
query associated_item(key: DefId) -> ty::AssocItem { query associated_item(key: DefId) -> ty::AssocItem {
desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) } desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) }
storage(ArenaCacheSelector<'tcx>) arena_cache
cache_on_disk_if { key.is_local() } cache_on_disk_if { key.is_local() }
separate_provide_extern separate_provide_extern
} }
/// Collects the associated items defined on a trait or impl. /// Collects the associated items defined on a trait or impl.
query associated_items(key: DefId) -> ty::AssocItems<'tcx> { query associated_items(key: DefId) -> ty::AssocItems<'tcx> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) } desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) }
} }
@ -704,7 +704,7 @@ rustc_queries! {
/// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be /// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
///`{ trait_f: impl_f, trait_g: impl_g }` ///`{ trait_f: impl_f, trait_g: impl_g }`
query impl_item_implementor_ids(impl_id: DefId) -> FxHashMap<DefId, DefId> { query impl_item_implementor_ids(impl_id: DefId) -> FxHashMap<DefId, DefId> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "comparing impl items against trait for {}", tcx.def_path_str(impl_id) } desc { |tcx| "comparing impl items against trait for {}", tcx.def_path_str(impl_id) }
} }
@ -837,7 +837,7 @@ rustc_queries! {
FxHashSet<LocalDefId>, FxHashSet<LocalDefId>,
FxHashMap<LocalDefId, Vec<(DefId, DefId)>> FxHashMap<LocalDefId, Vec<(DefId, DefId)>>
) { ) {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "find live symbols in crate" } desc { "find live symbols in crate" }
} }
@ -921,7 +921,7 @@ rustc_queries! {
/// Gets a complete map from all types to their inherent impls. /// Gets a complete map from all types to their inherent impls.
/// Not meant to be used directly outside of coherence. /// Not meant to be used directly outside of coherence.
query crate_inherent_impls(k: ()) -> CrateInherentImpls { query crate_inherent_impls(k: ()) -> CrateInherentImpls {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "all inherent impls defined in crate" } desc { "all inherent impls defined in crate" }
} }
@ -1054,7 +1054,7 @@ rustc_queries! {
} }
query reachable_set(_: ()) -> FxHashSet<LocalDefId> { query reachable_set(_: ()) -> FxHashSet<LocalDefId> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "reachability" } desc { "reachability" }
} }
@ -1066,7 +1066,7 @@ rustc_queries! {
/// Generates a MIR body for the shim. /// Generates a MIR body for the shim.
query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> { query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) } desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
} }
@ -1140,7 +1140,7 @@ rustc_queries! {
query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs { query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs {
desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) } desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
storage(ArenaCacheSelector<'tcx>) arena_cache
cache_on_disk_if { def_id.is_local() } cache_on_disk_if { def_id.is_local() }
separate_provide_extern separate_provide_extern
} }
@ -1157,7 +1157,7 @@ rustc_queries! {
/// Gets the rendered value of the specified constant or associated constant. /// Gets the rendered value of the specified constant or associated constant.
/// Used by rustdoc. /// Used by rustdoc.
query rendered_const(def_id: DefId) -> String { query rendered_const(def_id: DefId) -> String {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "rendering constant initializer of `{}`", tcx.def_path_str(def_id) } desc { |tcx| "rendering constant initializer of `{}`", tcx.def_path_str(def_id) }
cache_on_disk_if { def_id.is_local() } cache_on_disk_if { def_id.is_local() }
separate_provide_extern separate_provide_extern
@ -1219,12 +1219,12 @@ rustc_queries! {
/// Given a trait `trait_id`, return all known `impl` blocks. /// Given a trait `trait_id`, return all known `impl` blocks.
query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls { query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "trait impls of `{}`", tcx.def_path_str(trait_id) } desc { |tcx| "trait impls of `{}`", tcx.def_path_str(trait_id) }
} }
query specialization_graph_of(trait_id: DefId) -> specialization_graph::Graph { query specialization_graph_of(trait_id: DefId) -> specialization_graph::Graph {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) } desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
cache_on_disk_if { true } cache_on_disk_if { true }
} }
@ -1351,7 +1351,7 @@ rustc_queries! {
} }
query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> { query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "get the linkage format of all dependencies" } desc { "get the linkage format of all dependencies" }
} }
@ -1444,7 +1444,7 @@ rustc_queries! {
// like the compiler-generated `main` function and so on. // like the compiler-generated `main` function and so on.
query reachable_non_generics(_: CrateNum) query reachable_non_generics(_: CrateNum)
-> DefIdMap<SymbolExportInfo> { -> DefIdMap<SymbolExportInfo> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "looking up the exported symbols of a crate" } desc { "looking up the exported symbols of a crate" }
separate_provide_extern separate_provide_extern
} }
@ -1467,7 +1467,7 @@ rustc_queries! {
/// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
/// better, `Instance::upstream_monomorphization()`. /// better, `Instance::upstream_monomorphization()`.
query upstream_monomorphizations(_: ()) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> { query upstream_monomorphizations(_: ()) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "collecting available upstream monomorphizations" } desc { "collecting available upstream monomorphizations" }
} }
@ -1481,7 +1481,7 @@ rustc_queries! {
query upstream_monomorphizations_for(def_id: DefId) query upstream_monomorphizations_for(def_id: DefId)
-> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>>
{ {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| desc { |tcx|
"collecting available upstream monomorphizations for `{}`", "collecting available upstream monomorphizations for `{}`",
tcx.def_path_str(def_id), tcx.def_path_str(def_id),
@ -1509,7 +1509,7 @@ rustc_queries! {
} }
query foreign_modules(_: CrateNum) -> FxHashMap<DefId, ForeignModule> { query foreign_modules(_: CrateNum) -> FxHashMap<DefId, ForeignModule> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "looking up the foreign modules of a linked crate" } desc { "looking up the foreign modules of a linked crate" }
separate_provide_extern separate_provide_extern
} }
@ -1535,13 +1535,13 @@ rustc_queries! {
separate_provide_extern separate_provide_extern
} }
query extra_filename(_: CrateNum) -> String { query extra_filename(_: CrateNum) -> String {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "looking up the extra filename for a crate" } desc { "looking up the extra filename for a crate" }
separate_provide_extern separate_provide_extern
} }
query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> { query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "looking up the paths for extern crates" } desc { "looking up the paths for extern crates" }
separate_provide_extern separate_provide_extern
@ -1583,14 +1583,14 @@ rustc_queries! {
/// the same lifetimes and is responsible for diagnostics. /// the same lifetimes and is responsible for diagnostics.
/// See `rustc_resolve::late::lifetimes for details. /// See `rustc_resolve::late::lifetimes for details.
query resolve_lifetimes_trait_definition(_: LocalDefId) -> ResolveLifetimes { query resolve_lifetimes_trait_definition(_: LocalDefId) -> ResolveLifetimes {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "resolving lifetimes for a trait definition" } desc { "resolving lifetimes for a trait definition" }
} }
/// Does lifetime resolution on items. Importantly, we can't resolve /// Does lifetime resolution on items. Importantly, we can't resolve
/// lifetimes directly on things like trait methods, because of trait params. /// lifetimes directly on things like trait methods, because of trait params.
/// See `rustc_resolve::late::lifetimes for details. /// See `rustc_resolve::late::lifetimes for details.
query resolve_lifetimes(_: LocalDefId) -> ResolveLifetimes { query resolve_lifetimes(_: LocalDefId) -> ResolveLifetimes {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "resolving lifetimes" } desc { "resolving lifetimes" }
} }
query named_region_map(_: LocalDefId) -> query named_region_map(_: LocalDefId) ->
@ -1650,7 +1650,7 @@ rustc_queries! {
} }
query lib_features(_: ()) -> LibFeatures { query lib_features(_: ()) -> LibFeatures {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "calculating the lib features map" } desc { "calculating the lib features map" }
} }
query defined_lib_features(_: CrateNum) -> &'tcx [(Symbol, Option<Symbol>)] { query defined_lib_features(_: CrateNum) -> &'tcx [(Symbol, Option<Symbol>)] {
@ -1658,7 +1658,7 @@ rustc_queries! {
separate_provide_extern separate_provide_extern
} }
query stability_implications(_: CrateNum) -> FxHashMap<Symbol, Symbol> { query stability_implications(_: CrateNum) -> FxHashMap<Symbol, Symbol> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "calculating the implications between `#[unstable]` features defined in a crate" } desc { "calculating the implications between `#[unstable]` features defined in a crate" }
separate_provide_extern separate_provide_extern
} }
@ -1669,14 +1669,14 @@ rustc_queries! {
} }
/// Returns the lang items defined in another crate by loading it from metadata. /// Returns the lang items defined in another crate by loading it from metadata.
query get_lang_items(_: ()) -> LanguageItems { query get_lang_items(_: ()) -> LanguageItems {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "calculating the lang items map" } desc { "calculating the lang items map" }
} }
/// Returns all diagnostic items defined in all crates. /// Returns all diagnostic items defined in all crates.
query all_diagnostic_items(_: ()) -> rustc_hir::diagnostic_items::DiagnosticItems { query all_diagnostic_items(_: ()) -> rustc_hir::diagnostic_items::DiagnosticItems {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "calculating the diagnostic items map" } desc { "calculating the diagnostic items map" }
} }
@ -1689,7 +1689,7 @@ rustc_queries! {
/// Returns the diagnostic items defined in a crate. /// Returns the diagnostic items defined in a crate.
query diagnostic_items(_: CrateNum) -> rustc_hir::diagnostic_items::DiagnosticItems { query diagnostic_items(_: CrateNum) -> rustc_hir::diagnostic_items::DiagnosticItems {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "calculating the diagnostic items map in a crate" } desc { "calculating the diagnostic items map in a crate" }
separate_provide_extern separate_provide_extern
} }
@ -1699,11 +1699,11 @@ rustc_queries! {
separate_provide_extern separate_provide_extern
} }
query visible_parent_map(_: ()) -> DefIdMap<DefId> { query visible_parent_map(_: ()) -> DefIdMap<DefId> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "calculating the visible parent map" } desc { "calculating the visible parent map" }
} }
query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> { query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "calculating trimmed def paths" } desc { "calculating trimmed def paths" }
} }
query missing_extern_crate_item(_: CrateNum) -> bool { query missing_extern_crate_item(_: CrateNum) -> bool {
@ -1712,14 +1712,14 @@ rustc_queries! {
separate_provide_extern separate_provide_extern
} }
query used_crate_source(_: CrateNum) -> Lrc<CrateSource> { query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "looking at the source for a crate" } desc { "looking at the source for a crate" }
separate_provide_extern separate_provide_extern
} }
/// Returns the debugger visualizers defined for this crate. /// Returns the debugger visualizers defined for this crate.
query debugger_visualizers(_: CrateNum) -> Vec<rustc_span::DebuggerVisualizerFile> { query debugger_visualizers(_: CrateNum) -> Vec<rustc_span::DebuggerVisualizerFile> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { "looking up the debugger visualizers for this crate" } desc { "looking up the debugger visualizers for this crate" }
separate_provide_extern separate_provide_extern
} }
@ -1753,7 +1753,7 @@ rustc_queries! {
} }
query stability_index(_: ()) -> stability::Index { query stability_index(_: ()) -> stability::Index {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "calculating the stability index for the local crate" } desc { "calculating the stability index for the local crate" }
} }
@ -1994,7 +1994,7 @@ rustc_queries! {
} }
query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> { query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "looking up supported target features" } desc { "looking up supported target features" }
} }
@ -2064,7 +2064,7 @@ rustc_queries! {
/// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine, /// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
/// because the `ty::Ty`-based wfcheck is always run. /// because the `ty::Ty`-based wfcheck is always run.
query diagnostic_hir_wf_check(key: (ty::Predicate<'tcx>, traits::WellFormedLoc)) -> Option<traits::ObligationCause<'tcx>> { query diagnostic_hir_wf_check(key: (ty::Predicate<'tcx>, traits::WellFormedLoc)) -> Option<traits::ObligationCause<'tcx>> {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
no_hash no_hash
desc { "performing HIR wf-checking for predicate {:?} at item {:?}", key.0, key.1 } desc { "performing HIR wf-checking for predicate {:?} at item {:?}", key.0, key.1 }
@ -2074,13 +2074,13 @@ rustc_queries! {
/// The list of backend features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`, /// The list of backend features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
/// `--target` and similar). /// `--target` and similar).
query global_backend_features(_: ()) -> Vec<String> { query global_backend_features(_: ()) -> Vec<String> {
storage(ArenaCacheSelector<'tcx>) arena_cache
eval_always eval_always
desc { "computing the backend features for CLI flags" } desc { "computing the backend features for CLI flags" }
} }
query generator_diagnostic_data(key: DefId) -> Option<GeneratorDiagnosticData<'tcx>> { query generator_diagnostic_data(key: DefId) -> Option<GeneratorDiagnosticData<'tcx>> {
storage(ArenaCacheSelector<'tcx>) arena_cache
desc { |tcx| "looking up generator diagnostic data of `{}`", tcx.def_path_str(key) } desc { |tcx| "looking up generator diagnostic data of `{}`", tcx.def_path_str(key) }
separate_provide_extern separate_provide_extern
} }

View File

@ -121,8 +121,8 @@ macro_rules! query_storage {
([][$K:ty, $V:ty]) => { ([][$K:ty, $V:ty]) => {
<DefaultCacheSelector as CacheSelector<$K, $V>>::Cache <DefaultCacheSelector as CacheSelector<$K, $V>>::Cache
}; };
([(storage $ty:ty) $($rest:tt)*][$K:ty, $V:ty]) => { ([(arena_cache) $($rest:tt)*][$K:ty, $V:ty]) => {
<$ty as CacheSelector<$K, $V>>::Cache <ArenaCacheSelector<'tcx> as CacheSelector<$K, $V>>::Cache
}; };
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => { ([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
query_storage!([$($modifiers)*][$($args)*]) query_storage!([$($modifiers)*][$($args)*])