Remove CacheSelector trait now that we can use GATs

This commit is contained in:
Oli Scherer 2024-03-26 11:03:23 +00:00
parent 73476d4990
commit 3b94f33c23
5 changed files with 57 additions and 102 deletions

View File

@ -9,8 +9,7 @@
use crate::ty::{GenericArg, GenericArgsRef};
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, ModDefId, LOCAL_CRATE};
use rustc_hir::hir_id::{HirId, OwnerId};
use rustc_query_system::query::DefIdCacheSelector;
use rustc_query_system::query::{DefaultCacheSelector, SingleCacheSelector, VecCacheSelector};
use rustc_query_system::query::{DefIdCache, DefaultCache, SingleCache, VecCache};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi;
@ -22,7 +21,7 @@
/// The `Key` trait controls what types can legally be used as the key
/// for a query.
pub trait Key: Sized {
// N.B. Most of the keys down below have `type CacheSelector = DefaultCacheSelector<Self>;`,
// N.B. Most of the keys down below have `type Cache<V> = DefaultCache<Self, V>;`,
// it would be reasonable to use associated type defaults, to remove the duplication...
//
// ...But r-a doesn't support them yet and using a default here causes r-a to not infer
@ -30,7 +29,7 @@ pub trait Key: Sized {
// type defaults, please restrain from using them here <3
//
// r-a issue: <https://github.com/rust-lang/rust-analyzer/issues/13693>
type CacheSelector;
type Cache<V>;
/// In the event that a cycle occurs, if no explicit span has been
/// given for a query with key `self`, what span should we use?
@ -56,7 +55,7 @@ pub trait AsLocalKey: Key {
}
impl Key for () {
type CacheSelector = SingleCacheSelector;
type Cache<V> = SingleCache<V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -64,7 +63,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for ty::InstanceDef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@ -81,7 +80,7 @@ fn as_local_key(&self) -> Option<Self::LocalKey> {
}
impl<'tcx> Key for ty::Instance<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@ -89,7 +88,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for mir::interpret::GlobalId<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.instance.default_span(tcx)
@ -97,7 +96,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -105,7 +104,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for mir::interpret::LitToConstInput<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -113,7 +112,7 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
}
impl Key for CrateNum {
type CacheSelector = VecCacheSelector<Self>;
type Cache<V> = VecCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -130,7 +129,7 @@ fn as_local_key(&self) -> Option<Self::LocalKey> {
}
impl Key for OwnerId {
type CacheSelector = VecCacheSelector<Self>;
type Cache<V> = VecCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.to_def_id().default_span(tcx)
@ -142,7 +141,7 @@ fn key_as_def_id(&self) -> Option<DefId> {
}
impl Key for LocalDefId {
type CacheSelector = VecCacheSelector<Self>;
type Cache<V> = VecCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.to_def_id().default_span(tcx)
@ -154,7 +153,7 @@ fn key_as_def_id(&self) -> Option<DefId> {
}
impl Key for DefId {
type CacheSelector = DefIdCacheSelector;
type Cache<V> = DefIdCache<V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(*self)
@ -176,7 +175,7 @@ fn as_local_key(&self) -> Option<Self::LocalKey> {
}
impl Key for LocalModDefId {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(*self)
@ -189,7 +188,7 @@ fn key_as_def_id(&self) -> Option<DefId> {
}
impl Key for ModDefId {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(*self)
@ -211,7 +210,7 @@ fn as_local_key(&self) -> Option<Self::LocalKey> {
}
impl Key for SimplifiedType {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -219,7 +218,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl Key for (DefId, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
@ -227,7 +226,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -235,7 +234,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl Key for (DefId, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
@ -243,7 +242,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl Key for (LocalDefId, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -251,7 +250,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl Key for (LocalDefId, LocalDefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -259,7 +258,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl Key for (DefId, Ident) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.0)
@ -272,7 +271,7 @@ fn key_as_def_id(&self) -> Option<DefId> {
}
impl Key for (LocalDefId, LocalDefId, Ident) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
@ -280,7 +279,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl Key for (CrateNum, DefId) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.1.default_span(tcx)
@ -297,7 +296,7 @@ fn as_local_key(&self) -> Option<Self::LocalKey> {
}
impl Key for (CrateNum, SimplifiedType) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -314,7 +313,7 @@ fn as_local_key(&self) -> Option<Self::LocalKey> {
}
impl Key for (DefId, SimplifiedType) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -322,7 +321,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for GenericArgsRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -330,7 +329,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (DefId, GenericArgsRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -338,7 +337,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (ty::UnevaluatedConst<'tcx>, ty::UnevaluatedConst<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
(self.0).def.default_span(tcx)
@ -346,7 +345,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (LocalDefId, DefId, GenericArgsRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -354,7 +353,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (ty::ParamEnv<'tcx>, ty::TraitRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.1.def_id)
@ -362,7 +361,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for ty::PolyTraitRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@ -370,7 +369,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for ty::PolyExistentialTraitRef<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.def_id())
@ -378,7 +377,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (ty::PolyTraitRef<'tcx>, ty::PolyTraitRef<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.0.def_id())
@ -386,7 +385,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for GenericArg<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -394,7 +393,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for ty::Const<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -402,7 +401,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for Ty<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -418,7 +417,7 @@ fn ty_def_id(&self) -> Option<DefId> {
}
impl<'tcx> Key for TyAndLayout<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -426,7 +425,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (Ty<'tcx>, Ty<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -434,7 +433,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for &'tcx ty::List<ty::Clause<'tcx>> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -442,7 +441,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for ty::ParamEnv<'tcx> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -450,7 +449,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx, T: Key> Key for ty::ParamEnvAnd<'tcx, T> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.value.default_span(tcx)
@ -462,7 +461,7 @@ fn ty_def_id(&self) -> Option<DefId> {
}
impl Key for Symbol {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -470,7 +469,7 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
}
impl Key for Option<Symbol> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -480,7 +479,7 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
/// Canonical query goals correspond to abstract trait operations that
/// are not tied to any crate in particular.
impl<'tcx, T: Clone> Key for Canonical<'tcx, T> {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -488,7 +487,7 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
}
impl Key for (Symbol, u32, u32) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -496,7 +495,7 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (DefId, Ty<'tcx>, GenericArgsRef<'tcx>, ty::ParamEnv<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -504,7 +503,7 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (Ty<'tcx>, abi::VariantIdx) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -512,7 +511,7 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (ty::Predicate<'tcx>, traits::WellFormedLoc) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -520,7 +519,7 @@ fn default_span(&self, _tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -528,7 +527,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.0.default_span(tcx)
@ -536,7 +535,7 @@ fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
}
impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, _: TyCtxt<'_>) -> Span {
DUMMY_SP
@ -544,7 +543,7 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
}
impl Key for HirId {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.hir().span(*self)
@ -557,7 +556,7 @@ fn key_as_def_id(&self) -> Option<DefId> {
}
impl<'tcx> Key for (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>) {
type CacheSelector = DefaultCacheSelector<Self>;
type Cache<V> = DefaultCache<Self, V>;
// Just forward to `Ty<'tcx>`

View File

@ -73,7 +73,7 @@
use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate};
use rustc_index::IndexVec;
use rustc_query_system::ich::StableHashingContext;
use rustc_query_system::query::{try_get_cached, CacheSelector, QueryCache, QueryMode, QueryState};
use rustc_query_system::query::{try_get_cached, QueryCache, QueryMode, QueryState};
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
use rustc_session::cstore::{CrateDepKind, CrateSource};
use rustc_session::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};

View File

@ -336,9 +336,7 @@ pub fn provided_to_erased<'tcx>(
))
}
pub type Storage<'tcx> = <
<$($K)* as keys::Key>::CacheSelector as CacheSelector<'tcx, Erase<$V>>
>::Cache;
pub type Storage<'tcx> = <$($K)* as keys::Key>::Cache<Erase<$V>>;
// Ensure that keys grow no larger than 64 bytes
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]

View File

@ -9,13 +9,6 @@
use rustc_span::def_id::DefIndex;
use std::fmt::Debug;
use std::hash::Hash;
use std::marker::PhantomData;
pub trait CacheSelector<'tcx, V> {
type Cache
where
V: Copy;
}
pub trait QueryCache: Sized {
type Key: Hash + Eq + Copy + Debug;
@ -29,14 +22,6 @@ pub trait QueryCache: Sized {
fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex));
}
pub struct DefaultCacheSelector<K>(PhantomData<K>);
impl<'tcx, K: Eq + Hash, V: 'tcx> CacheSelector<'tcx, V> for DefaultCacheSelector<K> {
type Cache = DefaultCache<K, V>
where
V: Copy;
}
pub struct DefaultCache<K, V> {
cache: Sharded<FxHashMap<K, (V, DepNodeIndex)>>,
}
@ -81,14 +66,6 @@ fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex)) {
}
}
pub struct SingleCacheSelector;
impl<'tcx, V: 'tcx> CacheSelector<'tcx, V> for SingleCacheSelector {
type Cache = SingleCache<V>
where
V: Copy;
}
pub struct SingleCache<V> {
cache: OnceLock<(V, DepNodeIndex)>,
}
@ -123,14 +100,6 @@ fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex)) {
}
}
pub struct VecCacheSelector<K>(PhantomData<K>);
impl<'tcx, K: Idx, V: 'tcx> CacheSelector<'tcx, V> for VecCacheSelector<K> {
type Cache = VecCache<K, V>
where
V: Copy;
}
pub struct VecCache<K: Idx, V> {
cache: Sharded<IndexVec<K, Option<(V, DepNodeIndex)>>>,
}
@ -174,14 +143,6 @@ fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex)) {
}
}
pub struct DefIdCacheSelector;
impl<'tcx, V: 'tcx> CacheSelector<'tcx, V> for DefIdCacheSelector {
type Cache = DefIdCache<V>
where
V: Copy;
}
pub struct DefIdCache<V> {
/// Stores the local DefIds in a dense map. Local queries are much more often dense, so this is
/// a win over hashing query keys at marginal memory cost (~5% at most) compared to FxHashMap.

View File

@ -9,10 +9,7 @@
};
mod caches;
pub use self::caches::{
CacheSelector, DefIdCacheSelector, DefaultCacheSelector, QueryCache, SingleCacheSelector,
VecCacheSelector,
};
pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache};
mod config;
pub use self::config::{HashResult, QueryConfig};