diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index 5dff30f4c0841..63b78955ba87b 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -51,14 +51,14 @@ use std::fmt; use std::hash::Hash; use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey}; +use rustc_data_structures::stable_hasher::{StableHasher, StableOrd, ToStableHashKey}; use rustc_hir::def_id::DefId; use rustc_hir::definitions::DefPathHash; use rustc_macros::{Decodable, Encodable, HashStable}; use rustc_span::Symbol; use super::{KeyFingerprintStyle, SerializedDepNodeIndex}; -use crate::ich::StableHashingContext; +use crate::dep_graph::DepNodeKey; use crate::mir::mono::MonoItem; use crate::ty::{TyCtxt, tls}; @@ -168,58 +168,6 @@ impl fmt::Debug for DepNode { } } -/// Trait for query keys as seen by dependency-node tracking. -pub trait DepNodeKey<'tcx>: fmt::Debug + Sized { - fn key_fingerprint_style() -> KeyFingerprintStyle; - - /// This method turns a query key into an opaque `Fingerprint` to be used - /// in `DepNode`. - fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint; - - fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String; - - /// This method tries to recover the query key from the given `DepNode`, - /// something which is needed when forcing `DepNode`s during red-green - /// evaluation. The query system will only call this method if - /// `fingerprint_style()` is not `FingerprintStyle::Opaque`. - /// It is always valid to return `None` here, in which case incremental - /// compilation will treat the query as having changed instead of forcing it. - fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option; -} - -// Blanket impl of `DepNodeKey`, which is specialized by other impls elsewhere. -impl<'tcx, T> DepNodeKey<'tcx> for T -where - T: for<'a> HashStable> + fmt::Debug, -{ - #[inline(always)] - default fn key_fingerprint_style() -> KeyFingerprintStyle { - KeyFingerprintStyle::Opaque - } - - #[inline(always)] - default fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint { - tcx.with_stable_hashing_context(|mut hcx| { - let mut hasher = StableHasher::new(); - self.hash_stable(&mut hcx, &mut hasher); - hasher.finish() - }) - } - - #[inline(always)] - default fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String { - // Make sure to print dep node params with reduced queries since printing - // may themselves call queries, which may lead to (possibly untracked!) - // query cycles. - tcx.with_reduced_queries(|| format!("{self:?}")) - } - - #[inline(always)] - default fn try_recover_key(_: TyCtxt<'tcx>, _: &DepNode) -> Option { - None - } -} - /// This struct stores function pointers and other metadata for a particular DepKind. /// /// Information is retrieved by indexing the `DEP_KINDS` array using the integer value diff --git a/compiler/rustc_middle/src/dep_graph/dep_node_key.rs b/compiler/rustc_middle/src/dep_graph/dep_node_key.rs index c488a94712376..10e785ac6b870 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node_key.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node_key.rs @@ -1,11 +1,67 @@ +use std::fmt::Debug; + use rustc_data_structures::fingerprint::Fingerprint; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalModDefId, ModDefId}; use rustc_hir::definitions::DefPathHash; use rustc_hir::{HirId, ItemLocalId, OwnerId}; -use crate::dep_graph::{DepNode, DepNodeKey, KeyFingerprintStyle}; +use crate::dep_graph::{DepNode, KeyFingerprintStyle}; +use crate::ich::StableHashingContext; use crate::ty::TyCtxt; +/// Trait for query keys as seen by dependency-node tracking. +pub trait DepNodeKey<'tcx>: Debug + Sized { + fn key_fingerprint_style() -> KeyFingerprintStyle; + + /// This method turns a query key into an opaque `Fingerprint` to be used + /// in `DepNode`. + fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint; + + fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String; + + /// This method tries to recover the query key from the given `DepNode`, + /// something which is needed when forcing `DepNode`s during red-green + /// evaluation. The query system will only call this method if + /// `fingerprint_style()` is not `FingerprintStyle::Opaque`. + /// It is always valid to return `None` here, in which case incremental + /// compilation will treat the query as having changed instead of forcing it. + fn try_recover_key(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option; +} + +// Blanket impl of `DepNodeKey`, which is specialized by other impls elsewhere. +impl<'tcx, T> DepNodeKey<'tcx> for T +where + T: for<'a> HashStable> + Debug, +{ + #[inline(always)] + default fn key_fingerprint_style() -> KeyFingerprintStyle { + KeyFingerprintStyle::Opaque + } + + #[inline(always)] + default fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint { + tcx.with_stable_hashing_context(|mut hcx| { + let mut hasher = StableHasher::new(); + self.hash_stable(&mut hcx, &mut hasher); + hasher.finish() + }) + } + + #[inline(always)] + default fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String { + // Make sure to print dep node params with reduced queries since printing + // may themselves call queries, which may lead to (possibly untracked!) + // query cycles. + tcx.with_reduced_queries(|| format!("{self:?}")) + } + + #[inline(always)] + default fn try_recover_key(_: TyCtxt<'tcx>, _: &DepNode) -> Option { + None + } +} + impl<'tcx> DepNodeKey<'tcx> for () { #[inline(always)] fn key_fingerprint_style() -> KeyFingerprintStyle { diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index e0ba944d81573..1c922ffb3ef0d 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -3,8 +3,9 @@ use std::panic; use tracing::instrument; pub use self::dep_node::{ - DepKind, DepKindVTable, DepNode, DepNodeKey, WorkProductId, dep_kind_from_label, label_strs, + DepKind, DepKindVTable, DepNode, WorkProductId, dep_kind_from_label, label_strs, }; +pub use self::dep_node_key::DepNodeKey; pub use self::graph::{ DepGraph, DepGraphData, DepNodeIndex, QuerySideEffect, TaskDepsRef, WorkProduct, WorkProductMap, hash_result, diff --git a/compiler/rustc_middle/src/query/caches.rs b/compiler/rustc_middle/src/query/caches.rs index 2adcecc5aaef1..acd1b2cc341d8 100644 --- a/compiler/rustc_middle/src/query/caches.rs +++ b/compiler/rustc_middle/src/query/caches.rs @@ -1,19 +1,13 @@ -use std::fmt::Debug; -use std::hash::Hash; use std::sync::OnceLock; use rustc_data_structures::sharded::ShardedHashMap; -use rustc_data_structures::stable_hasher::HashStable; pub use rustc_data_structures::vec_cache::VecCache; use rustc_hir::def_id::LOCAL_CRATE; use rustc_index::Idx; use rustc_span::def_id::{DefId, DefIndex}; use crate::dep_graph::DepNodeIndex; -use crate::ich::StableHashingContext; - -/// Traits that all query keys must satisfy. -pub trait QueryCacheKey = Hash + Eq + Copy + Debug + for<'a> HashStable>; +use crate::query::keys::QueryKey; /// Trait for types that serve as an in-memory cache for query results, /// for a given key (argument) type and value (return) type. @@ -21,7 +15,7 @@ pub trait QueryCacheKey = Hash + Eq + Copy + Debug + for<'a> HashStable Default for DefaultCache { impl QueryCache for DefaultCache where - K: QueryCacheKey, + K: QueryKey, V: Copy, { type Key = K; @@ -180,7 +174,7 @@ where impl QueryCache for VecCache where - K: Idx + QueryCacheKey, + K: Idx + QueryKey, V: Copy, { type Key = K; diff --git a/compiler/rustc_middle/src/query/keys.rs b/compiler/rustc_middle/src/query/keys.rs index 6652e6e78e761..54b72c5b6714b 100644 --- a/compiler/rustc_middle/src/query/keys.rs +++ b/compiler/rustc_middle/src/query/keys.rs @@ -1,13 +1,17 @@ //! Defines the set of legal keys that can be used in queries. use std::ffi::OsStr; +use std::fmt::Debug; +use std::hash::Hash; use rustc_ast::tokenstream::TokenStream; +use rustc_data_structures::stable_hasher::HashStable; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalModDefId}; use rustc_hir::hir_id::OwnerId; use rustc_span::{DUMMY_SP, Ident, LocalExpnId, Span, Symbol}; use crate::dep_graph::DepNodeIndex; +use crate::ich::StableHashingContext; use crate::infer::canonical::CanonicalQueryInput; use crate::mir::mono::CollectionMode; use crate::query::{DefIdCache, DefaultCache, SingleCache, VecCache}; @@ -20,9 +24,10 @@ use crate::{mir, traits}; #[derive(Copy, Clone, Debug)] pub struct LocalCrate; -/// The `Key` trait controls what types can legally be used as the key -/// for a query. -pub trait Key: Sized { +pub trait QueryKeyBounds = Copy + Debug + Eq + Hash + for<'a> HashStable>; + +/// Controls what types can legally be used as the key for a query. +pub trait QueryKey: Sized + QueryKeyBounds { /// The type of in-memory cache to use for queries with this key type. /// /// In practice the cache type must implement [`QueryCache`], though that @@ -47,15 +52,15 @@ pub trait Key: Sized { } } -pub trait AsLocalKey: Key { - type LocalKey; +pub trait AsLocalQueryKey: QueryKey { + type LocalQueryKey; /// Given an instance of this key, what crate is it referring to? /// This is used to find the provider. - fn as_local_key(&self) -> Option; + fn as_local_key(&self) -> Option; } -impl Key for () { +impl QueryKey for () { type Cache = SingleCache; fn default_span(&self, _: TyCtxt<'_>) -> Span { @@ -63,37 +68,37 @@ impl Key for () { } } -impl<'tcx> Key for ty::InstanceKind<'tcx> { +impl<'tcx> QueryKey for ty::InstanceKind<'tcx> { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(self.def_id()) } } -impl<'tcx> Key for ty::Instance<'tcx> { +impl<'tcx> QueryKey for ty::Instance<'tcx> { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(self.def_id()) } } -impl<'tcx> Key for mir::interpret::GlobalId<'tcx> { +impl<'tcx> QueryKey for mir::interpret::GlobalId<'tcx> { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.instance.default_span(tcx) } } -impl<'tcx> Key for (Ty<'tcx>, Option>) { +impl<'tcx> QueryKey for (Ty<'tcx>, Option>) { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for ty::LitToConstInput<'tcx> { +impl<'tcx> QueryKey for ty::LitToConstInput<'tcx> { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl Key for CrateNum { +impl QueryKey for CrateNum { type Cache = VecCache; fn default_span(&self, _: TyCtxt<'_>) -> Span { @@ -101,16 +106,16 @@ impl Key for CrateNum { } } -impl AsLocalKey for CrateNum { - type LocalKey = LocalCrate; +impl AsLocalQueryKey for CrateNum { + type LocalQueryKey = LocalCrate; #[inline(always)] - fn as_local_key(&self) -> Option { + fn as_local_key(&self) -> Option { (*self == LOCAL_CRATE).then_some(LocalCrate) } } -impl Key for OwnerId { +impl QueryKey for OwnerId { type Cache = VecCache; fn default_span(&self, tcx: TyCtxt<'_>) -> Span { @@ -122,7 +127,7 @@ impl Key for OwnerId { } } -impl Key for LocalDefId { +impl QueryKey for LocalDefId { type Cache = VecCache; fn default_span(&self, tcx: TyCtxt<'_>) -> Span { @@ -134,7 +139,7 @@ impl Key for LocalDefId { } } -impl Key for DefId { +impl QueryKey for DefId { type Cache = DefIdCache; fn default_span(&self, tcx: TyCtxt<'_>) -> Span { @@ -147,16 +152,16 @@ impl Key for DefId { } } -impl AsLocalKey for DefId { - type LocalKey = LocalDefId; +impl AsLocalQueryKey for DefId { + type LocalQueryKey = LocalDefId; #[inline(always)] - fn as_local_key(&self) -> Option { + fn as_local_key(&self) -> Option { self.as_local() } } -impl Key for LocalModDefId { +impl QueryKey for LocalModDefId { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(*self) } @@ -167,19 +172,19 @@ impl Key for LocalModDefId { } } -impl Key for SimplifiedType { +impl QueryKey for SimplifiedType { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl Key for (DefId, DefId) { +impl QueryKey for (DefId, DefId) { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.1.default_span(tcx) } } -impl Key for (DefId, Ident) { +impl QueryKey for (DefId, Ident) { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(self.0) } @@ -190,73 +195,73 @@ impl Key for (DefId, Ident) { } } -impl Key for (LocalDefId, LocalDefId, Ident) { +impl QueryKey for (LocalDefId, LocalDefId, Ident) { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.1.default_span(tcx) } } -impl Key for (CrateNum, DefId) { +impl QueryKey for (CrateNum, DefId) { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.1.default_span(tcx) } } -impl AsLocalKey for (CrateNum, DefId) { - type LocalKey = DefId; +impl AsLocalQueryKey for (CrateNum, DefId) { + type LocalQueryKey = DefId; #[inline(always)] - fn as_local_key(&self) -> Option { + fn as_local_key(&self) -> Option { (self.0 == LOCAL_CRATE).then(|| self.1) } } -impl Key for (CrateNum, SimplifiedType) { +impl QueryKey for (CrateNum, SimplifiedType) { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl AsLocalKey for (CrateNum, SimplifiedType) { - type LocalKey = SimplifiedType; +impl AsLocalQueryKey for (CrateNum, SimplifiedType) { + type LocalQueryKey = SimplifiedType; #[inline(always)] - fn as_local_key(&self) -> Option { + fn as_local_key(&self) -> Option { (self.0 == LOCAL_CRATE).then(|| self.1) } } -impl Key for (DefId, ty::SizedTraitKind) { +impl QueryKey for (DefId, ty::SizedTraitKind) { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.0.default_span(tcx) } } -impl<'tcx> Key for GenericArgsRef<'tcx> { +impl<'tcx> QueryKey for GenericArgsRef<'tcx> { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>) { +impl<'tcx> QueryKey for (DefId, GenericArgsRef<'tcx>) { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.0.default_span(tcx) } } -impl<'tcx> Key for ty::TraitRef<'tcx> { +impl<'tcx> QueryKey for ty::TraitRef<'tcx> { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { tcx.def_span(self.def_id) } } -impl<'tcx> Key for GenericArg<'tcx> { +impl<'tcx> QueryKey for GenericArg<'tcx> { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for Ty<'tcx> { +impl<'tcx> QueryKey for Ty<'tcx> { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } @@ -270,19 +275,19 @@ impl<'tcx> Key for Ty<'tcx> { } } -impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) { +impl<'tcx> QueryKey for (Ty<'tcx>, Ty<'tcx>) { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for ty::Clauses<'tcx> { +impl<'tcx> QueryKey for ty::Clauses<'tcx> { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx, T: Key> Key for ty::PseudoCanonicalInput<'tcx, T> { +impl<'tcx, T: QueryKey> QueryKey for ty::PseudoCanonicalInput<'tcx, T> { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.value.default_span(tcx) } @@ -292,19 +297,19 @@ impl<'tcx, T: Key> Key for ty::PseudoCanonicalInput<'tcx, T> { } } -impl Key for Symbol { +impl QueryKey for Symbol { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl Key for Option { +impl QueryKey for Option { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for &'tcx OsStr { +impl<'tcx> QueryKey for &'tcx OsStr { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } @@ -312,55 +317,55 @@ impl<'tcx> Key for &'tcx OsStr { /// Canonical query goals correspond to abstract trait operations that /// are not tied to any crate in particular. -impl<'tcx, T: Clone> Key for CanonicalQueryInput<'tcx, T> { +impl<'tcx, T: QueryKeyBounds> QueryKey for CanonicalQueryInput<'tcx, T> { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx, T: Clone> Key for (CanonicalQueryInput<'tcx, T>, bool) { +impl<'tcx, T: QueryKeyBounds> QueryKey for (CanonicalQueryInput<'tcx, T>, bool) { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for (Ty<'tcx>, rustc_abi::VariantIdx) { +impl<'tcx> QueryKey for (Ty<'tcx>, rustc_abi::VariantIdx) { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) { +impl<'tcx> QueryKey for (ty::Predicate<'tcx>, traits::WellFormedLoc) { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List>) { +impl<'tcx> QueryKey for (ty::PolyFnSig<'tcx>, &'tcx ty::List>) { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List>) { +impl<'tcx> QueryKey for (ty::Instance<'tcx>, &'tcx ty::List>) { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.0.default_span(tcx) } } -impl<'tcx> Key for ty::Value<'tcx> { +impl<'tcx> QueryKey for ty::Value<'tcx> { fn default_span(&self, _: TyCtxt<'_>) -> Span { DUMMY_SP } } -impl<'tcx> Key for (LocalExpnId, &'tcx TokenStream) { +impl<'tcx> QueryKey for (LocalExpnId, &'tcx TokenStream) { fn default_span(&self, _tcx: TyCtxt<'_>) -> Span { self.0.expn_data().call_site } } -impl<'tcx> Key for (ValidityRequirement, ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) { +impl<'tcx> QueryKey for (ValidityRequirement, ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) { // Just forward to `Ty<'tcx>` fn default_span(&self, _: TyCtxt<'_>) -> Span { @@ -375,7 +380,7 @@ impl<'tcx> Key for (ValidityRequirement, ty::PseudoCanonicalInput<'tcx, Ty<'tcx> } } -impl<'tcx> Key for (ty::Instance<'tcx>, CollectionMode) { +impl<'tcx> QueryKey for (ty::Instance<'tcx>, CollectionMode) { fn default_span(&self, tcx: TyCtxt<'_>) -> Span { self.0.default_span(tcx) } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index bb457ab03fb55..eb252f18bbb98 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1,10 +1,8 @@ use rustc_hir::def_id::LocalDefId; -pub use self::caches::{ - DefIdCache, DefaultCache, QueryCache, QueryCacheKey, SingleCache, VecCache, -}; +pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache}; pub use self::job::{QueryInfo, QueryJob, QueryJobId, QueryLatch, QueryWaiter}; -pub use self::keys::{AsLocalKey, Key, LocalCrate}; +pub use self::keys::{AsLocalQueryKey, LocalCrate, QueryKey}; pub use self::plumbing::{ ActiveKeyStatus, CycleError, CycleErrorHandling, EnsureMode, IntoQueryParam, QueryMode, QueryState, TyCtxtAt, TyCtxtEnsureDone, TyCtxtEnsureOk, diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index c2d524d200dee..247b62a69f0f2 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -383,7 +383,7 @@ macro_rules! define_callbacks { pub type LocalKey<'tcx> = if_separate_provide_extern!( [$($modifiers)*] - ( as $crate::query::AsLocalKey>::LocalKey) + ( as $crate::query::AsLocalQueryKey>::LocalQueryKey) (Key<'tcx>) ); @@ -427,8 +427,8 @@ macro_rules! define_callbacks { erase::erase_val(value) } - pub type Storage<'tcx> = - as $crate::query::Key>::Cache>>; + pub type Cache<'tcx> = + as $crate::query::QueryKey>::Cache>>; // Ensure that keys grow no larger than 88 bytes by accident. // Increase this limit if necessary, but do try to keep the size low if possible @@ -575,7 +575,7 @@ macro_rules! define_callbacks { /// Holds a `QueryVTable` for each query. pub struct QueryVTables<'tcx> { $( - pub $name: ::rustc_middle::query::plumbing::QueryVTable<'tcx, $name::Storage<'tcx>>, + pub $name: ::rustc_middle::query::plumbing::QueryVTable<'tcx, $name::Cache<'tcx>>, )* } diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/errors.rs index 34720fc2f2958..820becd7031a4 100644 --- a/compiler/rustc_mir_transform/src/errors.rs +++ b/compiler/rustc_mir_transform/src/errors.rs @@ -4,7 +4,7 @@ use rustc_errors::{ }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::mir::AssertKind; -use rustc_middle::query::Key; +use rustc_middle::query::QueryKey; use rustc_middle::ty::TyCtxt; use rustc_session::lint::{self, Lint}; use rustc_span::def_id::DefId; diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs index afb41f69b5ebb..1b93ffe945b3d 100644 --- a/compiler/rustc_query_impl/src/lib.rs +++ b/compiler/rustc_query_impl/src/lib.rs @@ -13,7 +13,7 @@ use rustc_middle::dep_graph; use rustc_middle::queries::{self, ExternProviders, Providers}; use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache}; use rustc_middle::query::plumbing::{QuerySystem, QueryVTable}; -use rustc_middle::query::{AsLocalKey, QueryCache, QueryMode}; +use rustc_middle::query::{AsLocalQueryKey, QueryCache, QueryMode}; use rustc_middle::ty::TyCtxt; use rustc_span::Span; diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 275fe5b63d8b0..abfa681467042 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -19,7 +19,8 @@ use rustc_middle::query::on_disk_cache::{ }; use rustc_middle::query::plumbing::QueryVTable; use rustc_middle::query::{ - Key, QueryCache, QueryJobId, QueryStackDeferred, QueryStackFrame, QueryStackFrameExtra, erase, + QueryCache, QueryJobId, QueryKey, QueryStackDeferred, QueryStackFrame, QueryStackFrameExtra, + erase, }; use rustc_middle::ty::codec::TyEncoder; use rustc_middle::ty::print::with_reduced_queries; @@ -274,7 +275,7 @@ fn mk_query_stack_frame_extra<'tcx, Cache>( ) -> QueryStackFrameExtra where Cache: QueryCache, - Cache::Key: Key, + Cache::Key: QueryKey, { let def_id = key.key_as_def_id(); @@ -313,7 +314,7 @@ pub(crate) fn create_deferred_query_stack_frame<'tcx, C>( ) -> QueryStackFrame> where C: QueryCache, - C::Key: Key + DynSend + DynSync, + C::Key: QueryKey + DynSend + DynSync, QueryVTable<'tcx, C>: DynSync, { let kind = vtable.dep_kind; @@ -549,7 +550,7 @@ macro_rules! define_queries { } pub(crate) fn make_query_vtable<'tcx>(incremental: bool) - -> QueryVTable<'tcx, queries::$name::Storage<'tcx>> + -> QueryVTable<'tcx, queries::$name::Cache<'tcx>> { QueryVTable { name: stringify!($name), @@ -615,7 +616,7 @@ macro_rules! define_queries { pub(crate) enum VTableGetter {} impl<'tcx> GetQueryVTable<'tcx> for VTableGetter { - type Cache = rustc_middle::queries::$name::Storage<'tcx>; + type Cache = rustc_middle::queries::$name::Cache<'tcx>; #[inline(always)] fn query_vtable(tcx: TyCtxt<'tcx>) -> &'tcx QueryVTable<'tcx, Self::Cache> {