1
Fork 0

Auto merge of #107644 - Zoxc:query-cache-tweak, r=cjgillot

Remove QueryStorage::store_nocache

This method was added in https://github.com/rust-lang/rust/pull/70674 but it doesn't seem to serve any purpose.
This commit is contained in:
bors 2023-02-08 16:59:18 +00:00
commit 9433ba6394
2 changed files with 4 additions and 37 deletions

View file

@ -23,10 +23,6 @@ pub trait CacheSelector<'tcx, V> {
pub trait QueryStorage { pub trait QueryStorage {
type Value: Debug; type Value: Debug;
type Stored: Copy; type Stored: Copy;
/// Store a value without putting it in the cache.
/// This is meant to be used with cycle errors.
fn store_nocache(&self, value: Self::Value) -> Self::Stored;
} }
pub trait QueryCache: QueryStorage + Sized { pub trait QueryCache: QueryStorage + Sized {
@ -68,12 +64,6 @@ impl<K, V> Default for DefaultCache<K, V> {
impl<K: Eq + Hash, V: Copy + Debug> QueryStorage for DefaultCache<K, V> { impl<K: Eq + Hash, V: Copy + Debug> QueryStorage for DefaultCache<K, V> {
type Value = V; type Value = V;
type Stored = V; type Stored = V;
#[inline]
fn store_nocache(&self, value: Self::Value) -> Self::Stored {
// We have no dedicated storage
value
}
} }
impl<K, V> QueryCache for DefaultCache<K, V> impl<K, V> QueryCache for DefaultCache<K, V>
@ -144,13 +134,6 @@ impl<'tcx, K, V> Default for ArenaCache<'tcx, K, V> {
impl<'tcx, K: Eq + Hash, V: Debug + 'tcx> QueryStorage for ArenaCache<'tcx, K, V> { impl<'tcx, K: Eq + Hash, V: Debug + 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
type Value = V; type Value = V;
type Stored = &'tcx V; type Stored = &'tcx V;
#[inline]
fn store_nocache(&self, value: Self::Value) -> Self::Stored {
let value = self.arena.alloc((value, DepNodeIndex::INVALID));
let value = unsafe { &*(&value.0 as *const _) };
&value
}
} }
impl<'tcx, K, V: 'tcx> QueryCache for ArenaCache<'tcx, K, V> impl<'tcx, K, V: 'tcx> QueryCache for ArenaCache<'tcx, K, V>
@ -231,12 +214,6 @@ impl<K: Idx, V> Default for VecCache<K, V> {
impl<K: Eq + Idx, V: Copy + Debug> QueryStorage for VecCache<K, V> { impl<K: Eq + Idx, V: Copy + Debug> QueryStorage for VecCache<K, V> {
type Value = V; type Value = V;
type Stored = V; type Stored = V;
#[inline]
fn store_nocache(&self, value: Self::Value) -> Self::Stored {
// We have no dedicated storage
value
}
} }
impl<K, V> QueryCache for VecCache<K, V> impl<K, V> QueryCache for VecCache<K, V>
@ -309,13 +286,6 @@ impl<'tcx, K: Idx, V> Default for VecArenaCache<'tcx, K, V> {
impl<'tcx, K: Eq + Idx, V: Debug + 'tcx> QueryStorage for VecArenaCache<'tcx, K, V> { impl<'tcx, K: Eq + Idx, V: Debug + 'tcx> QueryStorage for VecArenaCache<'tcx, K, V> {
type Value = V; type Value = V;
type Stored = &'tcx V; type Stored = &'tcx V;
#[inline]
fn store_nocache(&self, value: Self::Value) -> Self::Stored {
let value = self.arena.alloc((value, DepNodeIndex::INVALID));
let value = unsafe { &*(&value.0 as *const _) };
&value
}
} }
impl<'tcx, K, V: 'tcx> QueryCache for VecArenaCache<'tcx, K, V> impl<'tcx, K, V: 'tcx> QueryCache for VecArenaCache<'tcx, K, V>

View file

@ -121,20 +121,17 @@ where
#[cold] #[cold]
#[inline(never)] #[inline(never)]
fn mk_cycle<Qcx, V, R, D: DepKind>( fn mk_cycle<Qcx, R, D: DepKind>(
qcx: Qcx, qcx: Qcx,
cycle_error: CycleError<D>, cycle_error: CycleError<D>,
handler: HandleCycleError, handler: HandleCycleError,
cache: &dyn crate::query::QueryStorage<Value = V, Stored = R>,
) -> R ) -> R
where where
Qcx: QueryContext + crate::query::HasDepContext<DepKind = D>, Qcx: QueryContext + crate::query::HasDepContext<DepKind = D>,
V: std::fmt::Debug + Value<Qcx::DepContext, Qcx::DepKind>, R: std::fmt::Debug + Value<Qcx::DepContext, Qcx::DepKind>,
R: Copy,
{ {
let error = report_cycle(qcx.dep_context().sess(), &cycle_error); let error = report_cycle(qcx.dep_context().sess(), &cycle_error);
let value = handle_cycle_error(*qcx.dep_context(), &cycle_error, error, handler); handle_cycle_error(*qcx.dep_context(), &cycle_error, error, handler)
cache.store_nocache(value)
} }
fn handle_cycle_error<Tcx, V>( fn handle_cycle_error<Tcx, V>(
@ -397,7 +394,7 @@ where
(result, Some(dep_node_index)) (result, Some(dep_node_index))
} }
TryGetJob::Cycle(error) => { TryGetJob::Cycle(error) => {
let result = mk_cycle(qcx, error, Q::HANDLE_CYCLE_ERROR, cache); let result = mk_cycle(qcx, error, Q::HANDLE_CYCLE_ERROR);
(result, None) (result, None)
} }
#[cfg(parallel_compiler)] #[cfg(parallel_compiler)]