1
Fork 0

Remove CacheSelector.

This commit is contained in:
Camille GILLOT 2022-10-31 16:08:09 +00:00
parent 07f1948043
commit aee4d132e7
3 changed files with 4 additions and 29 deletions

View file

@ -120,15 +120,9 @@ macro_rules! query_helper_param_ty {
} }
macro_rules! query_storage { macro_rules! query_storage {
([][$K:ty, $V:ty]) => { ([][$K:ty, $V:ty]) => { DefaultCache<$K, $V> };
<DefaultCacheSelector as CacheSelector<$K, $V>>::Cache ([(arena_cache) $($rest:tt)*][$K:ty, $V:ty]) => { ArenaCache<'tcx, $K, $V> };
}; ([$other:tt $($modifiers:tt)*][$($args:tt)*]) => { query_storage!([$($modifiers)*][$($args)*]) };
([(arena_cache) $($rest:tt)*][$K:ty, $V:ty]) => {
<ArenaCacheSelector<'tcx> as CacheSelector<$K, $V>>::Cache
};
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
query_storage!([$($modifiers)*][$($args)*])
};
} }
macro_rules! separate_provide_extern_decl { macro_rules! separate_provide_extern_decl {

View file

@ -11,11 +11,6 @@ use rustc_data_structures::sync::WorkerLocal;
use std::default::Default; use std::default::Default;
use std::fmt::Debug; use std::fmt::Debug;
use std::hash::Hash; use std::hash::Hash;
use std::marker::PhantomData;
pub trait CacheSelector<K, V> {
type Cache;
}
pub trait QueryStorage { pub trait QueryStorage {
type Value: Debug; type Value: Debug;
@ -47,12 +42,6 @@ pub trait QueryCache: QueryStorage + Sized {
fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex)); fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex));
} }
pub struct DefaultCacheSelector;
impl<K: Eq + Hash, V: Clone> CacheSelector<K, V> for DefaultCacheSelector {
type Cache = DefaultCache<K, V>;
}
pub struct DefaultCache<K, V> { pub struct DefaultCache<K, V> {
#[cfg(parallel_compiler)] #[cfg(parallel_compiler)]
cache: Sharded<FxHashMap<K, (V, DepNodeIndex)>>, cache: Sharded<FxHashMap<K, (V, DepNodeIndex)>>,
@ -134,12 +123,6 @@ where
} }
} }
pub struct ArenaCacheSelector<'tcx>(PhantomData<&'tcx ()>);
impl<'tcx, K: Eq + Hash, V: 'tcx> CacheSelector<K, V> for ArenaCacheSelector<'tcx> {
type Cache = ArenaCache<'tcx, K, V>;
}
pub struct ArenaCache<'tcx, K, V> { pub struct ArenaCache<'tcx, K, V> {
arena: WorkerLocal<TypedArena<(V, DepNodeIndex)>>, arena: WorkerLocal<TypedArena<(V, DepNodeIndex)>>,
#[cfg(parallel_compiler)] #[cfg(parallel_compiler)]

View file

@ -7,9 +7,7 @@ pub use self::job::deadlock;
pub use self::job::{print_query_stack, QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryMap}; pub use self::job::{print_query_stack, QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryMap};
mod caches; mod caches;
pub use self::caches::{ pub use self::caches::{ArenaCache, DefaultCache, QueryCache, QueryStorage};
ArenaCacheSelector, CacheSelector, DefaultCacheSelector, QueryCache, QueryStorage,
};
mod config; mod config;
pub use self::config::{QueryConfig, QueryDescription, QueryVTable}; pub use self::config::{QueryConfig, QueryDescription, QueryVTable};