Skip to content

Commit d459840

Browse files
committed
Remove QueryStorage::store_nocache
1 parent e4dd9ed commit d459840

File tree

2 files changed

+4
-37
lines changed

2 files changed

+4
-37
lines changed

compiler/rustc_query_system/src/query/caches.rs

-30
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ pub trait CacheSelector<'tcx, V> {
2323
pub trait QueryStorage {
2424
type Value: Debug;
2525
type Stored: Copy;
26-
27-
/// Store a value without putting it in the cache.
28-
/// This is meant to be used with cycle errors.
29-
fn store_nocache(&self, value: Self::Value) -> Self::Stored;
3026
}
3127

3228
pub trait QueryCache: QueryStorage + Sized {
@@ -68,12 +64,6 @@ impl<K, V> Default for DefaultCache<K, V> {
6864
impl<K: Eq + Hash, V: Copy + Debug> QueryStorage for DefaultCache<K, V> {
6965
type Value = V;
7066
type Stored = V;
71-
72-
#[inline]
73-
fn store_nocache(&self, value: Self::Value) -> Self::Stored {
74-
// We have no dedicated storage
75-
value
76-
}
7767
}
7868

7969
impl<K, V> QueryCache for DefaultCache<K, V>
@@ -144,13 +134,6 @@ impl<'tcx, K, V> Default for ArenaCache<'tcx, K, V> {
144134
impl<'tcx, K: Eq + Hash, V: Debug + 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
145135
type Value = V;
146136
type Stored = &'tcx V;
147-
148-
#[inline]
149-
fn store_nocache(&self, value: Self::Value) -> Self::Stored {
150-
let value = self.arena.alloc((value, DepNodeIndex::INVALID));
151-
let value = unsafe { &*(&value.0 as *const _) };
152-
&value
153-
}
154137
}
155138

156139
impl<'tcx, K, V: 'tcx> QueryCache for ArenaCache<'tcx, K, V>
@@ -231,12 +214,6 @@ impl<K: Idx, V> Default for VecCache<K, V> {
231214
impl<K: Eq + Idx, V: Copy + Debug> QueryStorage for VecCache<K, V> {
232215
type Value = V;
233216
type Stored = V;
234-
235-
#[inline]
236-
fn store_nocache(&self, value: Self::Value) -> Self::Stored {
237-
// We have no dedicated storage
238-
value
239-
}
240217
}
241218

242219
impl<K, V> QueryCache for VecCache<K, V>
@@ -309,13 +286,6 @@ impl<'tcx, K: Idx, V> Default for VecArenaCache<'tcx, K, V> {
309286
impl<'tcx, K: Eq + Idx, V: Debug + 'tcx> QueryStorage for VecArenaCache<'tcx, K, V> {
310287
type Value = V;
311288
type Stored = &'tcx V;
312-
313-
#[inline]
314-
fn store_nocache(&self, value: Self::Value) -> Self::Stored {
315-
let value = self.arena.alloc((value, DepNodeIndex::INVALID));
316-
let value = unsafe { &*(&value.0 as *const _) };
317-
&value
318-
}
319289
}
320290

321291
impl<'tcx, K, V: 'tcx> QueryCache for VecArenaCache<'tcx, K, V>

compiler/rustc_query_system/src/query/plumbing.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,17 @@ where
121121

122122
#[cold]
123123
#[inline(never)]
124-
fn mk_cycle<Qcx, V, R, D: DepKind>(
124+
fn mk_cycle<Qcx, R, D: DepKind>(
125125
qcx: Qcx,
126126
cycle_error: CycleError<D>,
127127
handler: HandleCycleError,
128-
cache: &dyn crate::query::QueryStorage<Value = V, Stored = R>,
129128
) -> R
130129
where
131130
Qcx: QueryContext + crate::query::HasDepContext<DepKind = D>,
132-
V: std::fmt::Debug + Value<Qcx::DepContext, Qcx::DepKind>,
133-
R: Copy,
131+
R: std::fmt::Debug + Value<Qcx::DepContext, Qcx::DepKind>,
134132
{
135133
let error = report_cycle(qcx.dep_context().sess(), &cycle_error);
136-
let value = handle_cycle_error(*qcx.dep_context(), &cycle_error, error, handler);
137-
cache.store_nocache(value)
134+
handle_cycle_error(*qcx.dep_context(), &cycle_error, error, handler)
138135
}
139136

140137
fn handle_cycle_error<Tcx, V>(
@@ -399,7 +396,7 @@ where
399396
(result, Some(dep_node_index))
400397
}
401398
TryGetJob::Cycle(error) => {
402-
let result = mk_cycle(qcx, error, Q::HANDLE_CYCLE_ERROR, cache);
399+
let result = mk_cycle(qcx, error, Q::HANDLE_CYCLE_ERROR);
403400
(result, None)
404401
}
405402
#[cfg(parallel_compiler)]

0 commit comments

Comments
 (0)