mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Rollup merge of #107758 - Zoxc:arena-enref, r=cjgillot
Change `arena_cache` to not alter the declared query result This makes the return types a bit clearer, limiting `arena_cache`'s effect to just the computation side. It also makes it easier to potentially remove `arena_cache`. r? ```@cjgillot```
This commit is contained in:
commit
abc2203e36
@ -54,14 +54,14 @@ rustc_queries! {
|
||||
/// This is because the `hir_crate` query gives you access to all other items.
|
||||
/// To avoid this fate, do not call `tcx.hir().krate()`; instead,
|
||||
/// prefer wrappers like `tcx.visit_all_items_in_krate()`.
|
||||
query hir_crate(key: ()) -> Crate<'tcx> {
|
||||
query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "getting the crate HIR" }
|
||||
}
|
||||
|
||||
/// All items in the crate.
|
||||
query hir_crate_items(_: ()) -> rustc_middle::hir::ModuleItems {
|
||||
query hir_crate_items(_: ()) -> &'tcx rustc_middle::hir::ModuleItems {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "getting HIR crate items" }
|
||||
@ -71,7 +71,7 @@ rustc_queries! {
|
||||
///
|
||||
/// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
|
||||
/// Avoid calling this query directly.
|
||||
query hir_module_items(key: LocalDefId) -> rustc_middle::hir::ModuleItems {
|
||||
query hir_module_items(key: LocalDefId) -> &'tcx rustc_middle::hir::ModuleItems {
|
||||
arena_cache
|
||||
desc { |tcx| "getting HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
cache_on_disk_if { true }
|
||||
@ -183,7 +183,7 @@ rustc_queries! {
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
query unsizing_params_for_adt(key: DefId) -> rustc_index::bit_set::BitSet<u32>
|
||||
query unsizing_params_for_adt(key: DefId) -> &'tcx rustc_index::bit_set::BitSet<u32>
|
||||
{
|
||||
arena_cache
|
||||
desc { |tcx|
|
||||
@ -218,7 +218,7 @@ rustc_queries! {
|
||||
|
||||
/// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
|
||||
/// associated generics.
|
||||
query generics_of(key: DefId) -> ty::Generics {
|
||||
query generics_of(key: DefId) -> &'tcx ty::Generics {
|
||||
desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) }
|
||||
arena_cache
|
||||
cache_on_disk_if { key.is_local() }
|
||||
@ -295,19 +295,19 @@ rustc_queries! {
|
||||
/// These are assembled from the following places:
|
||||
/// - `extern` blocks (depending on their `link` attributes)
|
||||
/// - the `libs` (`-l`) option
|
||||
query native_libraries(_: CrateNum) -> Vec<NativeLib> {
|
||||
query native_libraries(_: CrateNum) -> &'tcx Vec<NativeLib> {
|
||||
arena_cache
|
||||
desc { "looking up the native libraries of a linked crate" }
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
query shallow_lint_levels_on(key: hir::OwnerId) -> rustc_middle::lint::ShallowLintLevelMap {
|
||||
query shallow_lint_levels_on(key: hir::OwnerId) -> &'tcx rustc_middle::lint::ShallowLintLevelMap {
|
||||
eval_always // fetches `resolutions`
|
||||
arena_cache
|
||||
desc { |tcx| "looking up lint levels for `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
}
|
||||
|
||||
query lint_expectations(_: ()) -> Vec<(LintExpectationId, LintExpectation)> {
|
||||
query lint_expectations(_: ()) -> &'tcx Vec<(LintExpectationId, LintExpectation)> {
|
||||
arena_cache
|
||||
desc { "computing `#[expect]`ed lints in this crate" }
|
||||
}
|
||||
@ -347,7 +347,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Set of param indexes for type params that are in the type's representation
|
||||
query params_in_repr(key: DefId) -> rustc_index::bit_set::BitSet<u32> {
|
||||
query params_in_repr(key: DefId) -> &'tcx rustc_index::bit_set::BitSet<u32> {
|
||||
desc { "finding type parameters in the representation" }
|
||||
arena_cache
|
||||
no_hash
|
||||
@ -364,14 +364,14 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Create a THIR tree for debugging.
|
||||
query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> String {
|
||||
query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx String {
|
||||
no_hash
|
||||
arena_cache
|
||||
desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key.did.to_def_id()) }
|
||||
}
|
||||
|
||||
/// Create a list-like THIR representation for debugging.
|
||||
query thir_flat(key: ty::WithOptConstParam<LocalDefId>) -> String {
|
||||
query thir_flat(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx String {
|
||||
no_hash
|
||||
arena_cache
|
||||
desc { |tcx| "constructing flat THIR representation for `{}`", tcx.def_path_str(key.did.to_def_id()) }
|
||||
@ -380,7 +380,7 @@ rustc_queries! {
|
||||
/// Set of all the `DefId`s in this crate that have MIR associated with
|
||||
/// them. This includes all the body owners, but also things like struct
|
||||
/// constructors.
|
||||
query mir_keys(_: ()) -> rustc_data_structures::fx::FxIndexSet<LocalDefId> {
|
||||
query mir_keys(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexSet<LocalDefId> {
|
||||
arena_cache
|
||||
desc { "getting a list of all mir_keys" }
|
||||
}
|
||||
@ -478,7 +478,7 @@ rustc_queries! {
|
||||
|
||||
query symbols_for_closure_captures(
|
||||
key: (LocalDefId, LocalDefId)
|
||||
) -> Vec<rustc_span::Symbol> {
|
||||
) -> &'tcx Vec<rustc_span::Symbol> {
|
||||
arena_cache
|
||||
desc {
|
||||
|tcx| "finding symbols for captures of closure `{}` in `{}`",
|
||||
@ -487,7 +487,7 @@ rustc_queries! {
|
||||
}
|
||||
}
|
||||
|
||||
query mir_generator_witnesses(key: DefId) -> mir::GeneratorLayout<'tcx> {
|
||||
query mir_generator_witnesses(key: DefId) -> &'tcx mir::GeneratorLayout<'tcx> {
|
||||
arena_cache
|
||||
desc { |tcx| "generator witness types for `{}`", tcx.def_path_str(key) }
|
||||
cache_on_disk_if { key.is_local() }
|
||||
@ -508,14 +508,14 @@ rustc_queries! {
|
||||
|
||||
/// Returns coverage summary info for a function, after executing the `InstrumentCoverage`
|
||||
/// MIR pass (assuming the -Cinstrument-coverage option is enabled).
|
||||
query coverageinfo(key: ty::InstanceDef<'tcx>) -> mir::CoverageInfo {
|
||||
query coverageinfo(key: ty::InstanceDef<'tcx>) -> &'tcx mir::CoverageInfo {
|
||||
desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
|
||||
arena_cache
|
||||
}
|
||||
|
||||
/// Returns the `CodeRegions` for a function that has instrumented coverage, in case the
|
||||
/// function was optimized out before codegen, and before being added to the Coverage Map.
|
||||
query covered_code_regions(key: DefId) -> Vec<&'tcx mir::coverage::CodeRegion> {
|
||||
query covered_code_regions(key: DefId) -> &'tcx Vec<&'tcx mir::coverage::CodeRegion> {
|
||||
desc {
|
||||
|tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`",
|
||||
tcx.def_path_str(key)
|
||||
@ -557,7 +557,7 @@ rustc_queries! {
|
||||
desc { "erasing regions from `{}`", ty }
|
||||
}
|
||||
|
||||
query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> {
|
||||
query wasm_import_module_map(_: CrateNum) -> &'tcx FxHashMap<DefId, String> {
|
||||
arena_cache
|
||||
desc { "getting wasm import module map" }
|
||||
}
|
||||
@ -632,7 +632,7 @@ rustc_queries! {
|
||||
desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir().ty_param_name(key.1) }
|
||||
}
|
||||
|
||||
query trait_def(key: DefId) -> ty::TraitDef {
|
||||
query trait_def(key: DefId) -> &'tcx ty::TraitDef {
|
||||
desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) }
|
||||
arena_cache
|
||||
cache_on_disk_if { key.is_local() }
|
||||
@ -703,7 +703,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Gets a map with the variance of every item; use `item_variance` instead.
|
||||
query crate_variances(_: ()) -> ty::CrateVariancesMap<'tcx> {
|
||||
query crate_variances(_: ()) -> &'tcx ty::CrateVariancesMap<'tcx> {
|
||||
arena_cache
|
||||
desc { "computing the variances for items in this crate" }
|
||||
}
|
||||
@ -716,7 +716,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Maps from thee `DefId` of a type to its (inferred) outlives.
|
||||
query inferred_outlives_crate(_: ()) -> ty::CratePredicatesMap<'tcx> {
|
||||
query inferred_outlives_crate(_: ()) -> &'tcx ty::CratePredicatesMap<'tcx> {
|
||||
arena_cache
|
||||
desc { "computing the inferred outlives predicates for items in this crate" }
|
||||
}
|
||||
@ -729,7 +729,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Maps from a trait item to the trait item "descriptor".
|
||||
query associated_item(key: DefId) -> ty::AssocItem {
|
||||
query associated_item(key: DefId) -> &'tcx ty::AssocItem {
|
||||
desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) }
|
||||
arena_cache
|
||||
cache_on_disk_if { key.is_local() }
|
||||
@ -737,7 +737,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Collects the associated items defined on a trait or impl.
|
||||
query associated_items(key: DefId) -> ty::AssocItems<'tcx> {
|
||||
query associated_items(key: DefId) -> &'tcx ty::AssocItems<'tcx> {
|
||||
arena_cache
|
||||
desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
@ -763,7 +763,7 @@ rustc_queries! {
|
||||
///
|
||||
/// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
|
||||
///`{ 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) -> &'tcx FxHashMap<DefId, DefId> {
|
||||
arena_cache
|
||||
desc { |tcx| "comparing impl items against trait for `{}`", tcx.def_path_str(impl_id) }
|
||||
}
|
||||
@ -884,7 +884,7 @@ rustc_queries! {
|
||||
///
|
||||
/// The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone) and
|
||||
/// their respective impl (i.e., part of the derive macro)
|
||||
query live_symbols_and_ignored_derived_traits(_: ()) -> (
|
||||
query live_symbols_and_ignored_derived_traits(_: ()) -> &'tcx (
|
||||
FxHashSet<LocalDefId>,
|
||||
FxHashMap<LocalDefId, Vec<(DefId, DefId)>>
|
||||
) {
|
||||
@ -964,7 +964,7 @@ rustc_queries! {
|
||||
|
||||
/// Gets a complete map from all types to their inherent impls.
|
||||
/// Not meant to be used directly outside of coherence.
|
||||
query crate_inherent_impls(k: ()) -> CrateInherentImpls {
|
||||
query crate_inherent_impls(k: ()) -> &'tcx CrateInherentImpls {
|
||||
arena_cache
|
||||
desc { "finding all inherent impls defined in crate" }
|
||||
}
|
||||
@ -1099,7 +1099,7 @@ rustc_queries! {
|
||||
desc { "checking for private elements in public interfaces" }
|
||||
}
|
||||
|
||||
query reachable_set(_: ()) -> FxHashSet<LocalDefId> {
|
||||
query reachable_set(_: ()) -> &'tcx FxHashSet<LocalDefId> {
|
||||
arena_cache
|
||||
desc { "reachability" }
|
||||
}
|
||||
@ -1111,7 +1111,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Generates a MIR body for the shim.
|
||||
query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> {
|
||||
query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Body<'tcx> {
|
||||
arena_cache
|
||||
desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ rustc_queries! {
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs {
|
||||
query codegen_fn_attrs(def_id: DefId) -> &'tcx CodegenFnAttrs {
|
||||
desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
|
||||
arena_cache
|
||||
cache_on_disk_if { def_id.is_local() }
|
||||
@ -1209,7 +1209,7 @@ rustc_queries! {
|
||||
}
|
||||
/// Gets the rendered value of the specified constant or associated constant.
|
||||
/// Used by rustdoc.
|
||||
query rendered_const(def_id: DefId) -> String {
|
||||
query rendered_const(def_id: DefId) -> &'tcx String {
|
||||
arena_cache
|
||||
desc { |tcx| "rendering constant initializer of `{}`", tcx.def_path_str(def_id) }
|
||||
cache_on_disk_if { def_id.is_local() }
|
||||
@ -1268,12 +1268,12 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// 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) -> &'tcx ty::trait_def::TraitImpls {
|
||||
arena_cache
|
||||
desc { |tcx| "finding 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) -> &'tcx specialization_graph::Graph {
|
||||
arena_cache
|
||||
desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
|
||||
cache_on_disk_if { true }
|
||||
@ -1403,7 +1403,7 @@ rustc_queries! {
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
|
||||
query dependency_formats(_: ()) -> &'tcx Lrc<crate::middle::dependency_format::Dependencies> {
|
||||
arena_cache
|
||||
desc { "getting the linkage format of all dependencies" }
|
||||
}
|
||||
@ -1503,7 +1503,7 @@ rustc_queries! {
|
||||
// Does not include external symbols that don't have a corresponding DefId,
|
||||
// like the compiler-generated `main` function and so on.
|
||||
query reachable_non_generics(_: CrateNum)
|
||||
-> DefIdMap<SymbolExportInfo> {
|
||||
-> &'tcx DefIdMap<SymbolExportInfo> {
|
||||
arena_cache
|
||||
desc { "looking up the exported symbols of a crate" }
|
||||
separate_provide_extern
|
||||
@ -1526,7 +1526,7 @@ rustc_queries! {
|
||||
/// added or removed in any upstream crate. Instead use the narrower
|
||||
/// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
|
||||
/// better, `Instance::upstream_monomorphization()`.
|
||||
query upstream_monomorphizations(_: ()) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
|
||||
query upstream_monomorphizations(_: ()) -> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
|
||||
arena_cache
|
||||
desc { "collecting available upstream monomorphizations" }
|
||||
}
|
||||
@ -1568,7 +1568,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Returns a list of all `extern` blocks of a crate.
|
||||
query foreign_modules(_: CrateNum) -> FxHashMap<DefId, ForeignModule> {
|
||||
query foreign_modules(_: CrateNum) -> &'tcx FxHashMap<DefId, ForeignModule> {
|
||||
arena_cache
|
||||
desc { "looking up the foreign modules of a linked crate" }
|
||||
separate_provide_extern
|
||||
@ -1602,7 +1602,7 @@ rustc_queries! {
|
||||
|
||||
/// Gets the extra data to put in each output filename for a crate.
|
||||
/// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
|
||||
query extra_filename(_: CrateNum) -> String {
|
||||
query extra_filename(_: CrateNum) -> &'tcx String {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "looking up the extra filename for a crate" }
|
||||
@ -1610,7 +1610,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Gets the paths where the crate came from in the file system.
|
||||
query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
|
||||
query crate_extern_paths(_: CrateNum) -> &'tcx Vec<PathBuf> {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "looking up the paths for extern crates" }
|
||||
@ -1641,7 +1641,7 @@ rustc_queries! {
|
||||
/// Does lifetime resolution on items. Importantly, we can't resolve
|
||||
/// lifetimes directly on things like trait methods, because of trait params.
|
||||
/// See `rustc_resolve::late::lifetimes for details.
|
||||
query resolve_lifetimes(_: hir::OwnerId) -> ResolveLifetimes {
|
||||
query resolve_lifetimes(_: hir::OwnerId) -> &'tcx ResolveLifetimes {
|
||||
arena_cache
|
||||
desc { "resolving lifetimes" }
|
||||
}
|
||||
@ -1712,7 +1712,7 @@ rustc_queries! {
|
||||
desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
|
||||
}
|
||||
|
||||
query lib_features(_: ()) -> LibFeatures {
|
||||
query lib_features(_: ()) -> &'tcx LibFeatures {
|
||||
arena_cache
|
||||
desc { "calculating the lib features map" }
|
||||
}
|
||||
@ -1720,7 +1720,7 @@ rustc_queries! {
|
||||
desc { "calculating the lib features defined in a crate" }
|
||||
separate_provide_extern
|
||||
}
|
||||
query stability_implications(_: CrateNum) -> FxHashMap<Symbol, Symbol> {
|
||||
query stability_implications(_: CrateNum) -> &'tcx FxHashMap<Symbol, Symbol> {
|
||||
arena_cache
|
||||
desc { "calculating the implications between `#[unstable]` features defined in a crate" }
|
||||
separate_provide_extern
|
||||
@ -1731,14 +1731,14 @@ rustc_queries! {
|
||||
separate_provide_extern
|
||||
}
|
||||
/// Returns the lang items defined in another crate by loading it from metadata.
|
||||
query get_lang_items(_: ()) -> LanguageItems {
|
||||
query get_lang_items(_: ()) -> &'tcx LanguageItems {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "calculating the lang items map" }
|
||||
}
|
||||
|
||||
/// Returns all diagnostic items defined in all crates.
|
||||
query all_diagnostic_items(_: ()) -> rustc_hir::diagnostic_items::DiagnosticItems {
|
||||
query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "calculating the diagnostic items map" }
|
||||
@ -1751,7 +1751,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Returns the diagnostic items defined in a crate.
|
||||
query diagnostic_items(_: CrateNum) -> rustc_hir::diagnostic_items::DiagnosticItems {
|
||||
query diagnostic_items(_: CrateNum) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
|
||||
arena_cache
|
||||
desc { "calculating the diagnostic items map in a crate" }
|
||||
separate_provide_extern
|
||||
@ -1761,11 +1761,11 @@ rustc_queries! {
|
||||
desc { "calculating the missing lang items in a crate" }
|
||||
separate_provide_extern
|
||||
}
|
||||
query visible_parent_map(_: ()) -> DefIdMap<DefId> {
|
||||
query visible_parent_map(_: ()) -> &'tcx DefIdMap<DefId> {
|
||||
arena_cache
|
||||
desc { "calculating the visible parent map" }
|
||||
}
|
||||
query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
|
||||
query trimmed_def_paths(_: ()) -> &'tcx FxHashMap<DefId, Symbol> {
|
||||
arena_cache
|
||||
desc { "calculating trimmed def paths" }
|
||||
}
|
||||
@ -1774,14 +1774,14 @@ rustc_queries! {
|
||||
desc { "seeing if we're missing an `extern crate` item for this crate" }
|
||||
separate_provide_extern
|
||||
}
|
||||
query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
|
||||
query used_crate_source(_: CrateNum) -> &'tcx Lrc<CrateSource> {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "looking at the source for a crate" }
|
||||
separate_provide_extern
|
||||
}
|
||||
/// Returns the debugger visualizers defined for this crate.
|
||||
query debugger_visualizers(_: CrateNum) -> Vec<rustc_span::DebuggerVisualizerFile> {
|
||||
query debugger_visualizers(_: CrateNum) -> &'tcx Vec<rustc_span::DebuggerVisualizerFile> {
|
||||
arena_cache
|
||||
desc { "looking up the debugger visualizers for this crate" }
|
||||
separate_provide_extern
|
||||
@ -1819,7 +1819,7 @@ rustc_queries! {
|
||||
desc { |tcx| "finding names imported by glob use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
|
||||
}
|
||||
|
||||
query stability_index(_: ()) -> stability::Index {
|
||||
query stability_index(_: ()) -> &'tcx stability::Index {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "calculating the stability index for the local crate" }
|
||||
@ -1883,7 +1883,7 @@ rustc_queries! {
|
||||
///
|
||||
/// This query returns an `&Arc` because codegen backends need the value even after the `TyCtxt`
|
||||
/// has been destroyed.
|
||||
query output_filenames(_: ()) -> Arc<OutputFilenames> {
|
||||
query output_filenames(_: ()) -> &'tcx Arc<OutputFilenames> {
|
||||
feedable
|
||||
desc { "getting output filenames" }
|
||||
arena_cache
|
||||
@ -2056,7 +2056,7 @@ rustc_queries! {
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
|
||||
query supported_target_features(_: CrateNum) -> &'tcx FxHashMap<String, Option<Symbol>> {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "looking up supported target features" }
|
||||
@ -2115,23 +2115,24 @@ rustc_queries! {
|
||||
/// span) for an *existing* error. Therefore, it is best-effort, and may never handle
|
||||
/// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
|
||||
/// 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)
|
||||
) -> &'tcx Option<traits::ObligationCause<'tcx>> {
|
||||
arena_cache
|
||||
eval_always
|
||||
no_hash
|
||||
desc { "performing HIR wf-checking for predicate `{:?}` at item `{:?}`", key.0, key.1 }
|
||||
}
|
||||
|
||||
|
||||
/// The list of backend features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
|
||||
/// `--target` and similar).
|
||||
query global_backend_features(_: ()) -> Vec<String> {
|
||||
query global_backend_features(_: ()) -> &'tcx Vec<String> {
|
||||
arena_cache
|
||||
eval_always
|
||||
desc { "computing the backend features for CLI flags" }
|
||||
}
|
||||
|
||||
query generator_diagnostic_data(key: DefId) -> Option<GeneratorDiagnosticData<'tcx>> {
|
||||
query generator_diagnostic_data(key: DefId) -> &'tcx Option<GeneratorDiagnosticData<'tcx>> {
|
||||
arena_cache
|
||||
desc { |tcx| "looking up generator diagnostic data of `{}`", tcx.def_path_str(key) }
|
||||
separate_provide_extern
|
||||
|
@ -112,15 +112,15 @@ macro_rules! query_helper_param_ty {
|
||||
($K:ty) => { $K };
|
||||
}
|
||||
|
||||
macro_rules! query_storage {
|
||||
([][$K:ty, $V:ty]) => {
|
||||
<<$K as Key>::CacheSelector as CacheSelector<'tcx, $V>>::Cache
|
||||
macro_rules! query_if_arena {
|
||||
([] $arena:ty, $no_arena:ty) => {
|
||||
$no_arena
|
||||
};
|
||||
([(arena_cache) $($rest:tt)*][$K:ty, $V:ty]) => {
|
||||
<<$K as Key>::CacheSelector as CacheSelector<'tcx, $V>>::ArenaCache
|
||||
([(arena_cache) $($rest:tt)*] $arena:ty, $no_arena:ty) => {
|
||||
$arena
|
||||
};
|
||||
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
|
||||
query_storage!([$($modifiers)*][$($args)*])
|
||||
([$other:tt $($modifiers:tt)*]$($args:tt)*) => {
|
||||
query_if_arena!([$($modifiers)*]$($args)*)
|
||||
};
|
||||
}
|
||||
|
||||
@ -184,23 +184,30 @@ macro_rules! define_callbacks {
|
||||
|
||||
$(pub type $name<'tcx> = $($K)*;)*
|
||||
}
|
||||
#[allow(nonstandard_style, unused_lifetimes)]
|
||||
#[allow(nonstandard_style, unused_lifetimes, unused_parens)]
|
||||
pub mod query_values {
|
||||
use super::*;
|
||||
|
||||
$(pub type $name<'tcx> = $V;)*
|
||||
$(pub type $name<'tcx> = query_if_arena!([$($modifiers)*] <$V as Deref>::Target, $V);)*
|
||||
}
|
||||
#[allow(nonstandard_style, unused_lifetimes)]
|
||||
#[allow(nonstandard_style, unused_lifetimes, unused_parens)]
|
||||
pub mod query_storage {
|
||||
use super::*;
|
||||
|
||||
$(pub type $name<'tcx> = query_storage!([$($modifiers)*][$($K)*, $V]);)*
|
||||
$(
|
||||
pub type $name<'tcx> = query_if_arena!([$($modifiers)*]
|
||||
<<$($K)* as Key>::CacheSelector
|
||||
as CacheSelector<'tcx, <$V as Deref>::Target>>::ArenaCache,
|
||||
<<$($K)* as Key>::CacheSelector as CacheSelector<'tcx, $V>>::Cache
|
||||
);
|
||||
)*
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style, unused_lifetimes)]
|
||||
pub mod query_stored {
|
||||
use super::*;
|
||||
|
||||
$(pub type $name<'tcx> = <query_storage::$name<'tcx> as QueryStorage>::Stored;)*
|
||||
$(pub type $name<'tcx> = $V;)*
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -226,7 +233,7 @@ macro_rules! define_callbacks {
|
||||
$($(#[$attr])*
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<'tcx>
|
||||
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V
|
||||
{
|
||||
self.at(DUMMY_SP).$name(key)
|
||||
})*
|
||||
@ -235,7 +242,7 @@ macro_rules! define_callbacks {
|
||||
impl<'tcx> TyCtxtAt<'tcx> {
|
||||
$($(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> query_stored::$name<'tcx>
|
||||
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V
|
||||
{
|
||||
let key = key.into_query_param();
|
||||
opt_remap_env_constness!([$($modifiers)*][key]);
|
||||
@ -306,7 +313,7 @@ macro_rules! define_callbacks {
|
||||
span: Span,
|
||||
key: query_keys::$name<'tcx>,
|
||||
mode: QueryMode,
|
||||
) -> Option<query_stored::$name<'tcx>>;)*
|
||||
) -> Option<$V>;)*
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -328,7 +335,7 @@ macro_rules! define_feedable {
|
||||
$(impl<'tcx, K: IntoQueryParam<$($K)*> + Copy> TyCtxtFeed<'tcx, K> {
|
||||
$(#[$attr])*
|
||||
#[inline(always)]
|
||||
pub fn $name(self, value: $V) -> query_stored::$name<'tcx> {
|
||||
pub fn $name(self, value: query_values::$name<'tcx>) -> $V {
|
||||
let key = self.key().into_query_param();
|
||||
opt_remap_env_constness!([$($modifiers)*][key]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user