Skip to content

Commit 503f908

Browse files
committed
XXX: introduce MyKey
1 parent d6218b6 commit 503f908

5 files changed

Lines changed: 12 additions & 10 deletions

File tree

compiler/rustc_query_impl/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use std::marker::ConstParamTy;
1212

13-
use rustc_data_structures::stable_hasher::HashStable;
1413
use rustc_data_structures::sync::AtomicU64;
1514
use rustc_middle::arena::Arena;
1615
use rustc_middle::dep_graph::{self, DepKind, DepKindVTable, DepNodeIndex};
@@ -23,7 +22,6 @@ use rustc_middle::query::plumbing::{QuerySystem, QuerySystemFns, QueryVTable};
2322
use rustc_middle::query::values::Value;
2423
use rustc_middle::ty::TyCtxt;
2524
use rustc_query_system::dep_graph::SerializedDepNodeIndex;
26-
use rustc_query_system::ich::StableHashingContext;
2725
use rustc_query_system::query::{
2826
CycleError, CycleErrorHandling, HashResult, QueryCache, QueryDispatcher, QueryMap, QueryMode,
2927
QueryState,
@@ -79,8 +77,6 @@ impl<'tcx, C: QueryCache, const FLAGS: QueryFlags> Clone
7977
// This is `impl QueryDispatcher for SemiDynamicQueryDispatcher`.
8078
impl<'tcx, C: QueryCache, const FLAGS: QueryFlags> QueryDispatcher<'tcx>
8179
for SemiDynamicQueryDispatcher<'tcx, C, FLAGS>
82-
where
83-
for<'a> C::Key: HashStable<StableHashingContext<'a>>,
8480
{
8581
type Qcx = QueryCtxt<'tcx>;
8682
type Key = C::Key;

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use rustc_middle::ty::print::with_reduced_queries;
3333
use rustc_middle::ty::tls::{self, ImplicitCtxt};
3434
use rustc_middle::ty::{self, TyCtxt};
3535
use rustc_query_system::dep_graph::{DepGraphData, DepNodeKey, FingerprintStyle, HasDepContext};
36-
use rustc_query_system::ich::StableHashingContext;
3736
use rustc_query_system::query::{
3837
ActiveKeyStatus, CycleError, CycleErrorHandling, QueryCache, QueryContext, QueryDispatcher,
3938
QueryJob, QueryJobId, QueryJobInfo, QueryLatch, QueryMap, QueryMode, QuerySideEffect,
@@ -368,7 +367,7 @@ pub(crate) fn create_deferred_query_stack_frame<'tcx, Cache>(
368367
) -> QueryStackFrame<QueryStackDeferred<'tcx>>
369368
where
370369
Cache: QueryCache,
371-
Cache::Key: Key + DynSend + DynSync + for<'a> HashStable<StableHashingContext<'a>> + 'tcx,
370+
Cache::Key: Key + DynSend + DynSync,
372371
{
373372
let kind = vtable.dep_kind;
374373

compiler/rustc_query_system/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(internal_features)]
33
#![feature(assert_matches)]
44
#![feature(min_specialization)]
5+
#![feature(trait_alias)]
56
// tidy-alphabetical-end
67

78
pub mod cache;

compiler/rustc_query_system/src/query/caches.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ use std::hash::Hash;
33
use std::sync::OnceLock;
44

55
use rustc_data_structures::sharded::ShardedHashMap;
6+
use rustc_data_structures::stable_hasher::HashStable;
67
pub use rustc_data_structures::vec_cache::VecCache;
78
use rustc_hir::def_id::LOCAL_CRATE;
89
use rustc_index::Idx;
910
use rustc_span::def_id::{DefId, DefIndex};
1011

1112
use crate::dep_graph::DepNodeIndex;
13+
use crate::ich::StableHashingContext;
14+
15+
// njn: explain
16+
// njn: rename
17+
pub trait MyKey = Hash + Eq + Copy + Debug + for<'a> HashStable<StableHashingContext<'a>>;
1218

1319
/// Trait for types that serve as an in-memory cache for query results,
1420
/// for a given key (argument) type and value (return) type.
1521
///
1622
/// Types implementing this trait are associated with actual key/value types
1723
/// by the `Cache` associated type of the `rustc_middle::query::Key` trait.
1824
pub trait QueryCache: Sized {
19-
type Key: Hash + Eq + Copy + Debug;
25+
type Key: MyKey;
2026
type Value: Copy;
2127

2228
/// Returns the cached value (and other information) associated with the
@@ -48,7 +54,7 @@ impl<K, V> Default for DefaultCache<K, V> {
4854

4955
impl<K, V> QueryCache for DefaultCache<K, V>
5056
where
51-
K: Eq + Hash + Copy + Debug,
57+
K: MyKey,
5258
V: Copy,
5359
{
5460
type Key = K;
@@ -175,7 +181,7 @@ where
175181

176182
impl<K, V> QueryCache for VecCache<K, V, DepNodeIndex>
177183
where
178-
K: Idx + Eq + Hash + Copy + Debug,
184+
K: Idx + MyKey,
179185
V: Copy,
180186
{
181187
type Key = K;

compiler/rustc_query_system/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_macros::{Decodable, Encodable};
1212
use rustc_span::Span;
1313
use rustc_span::def_id::DefId;
1414

15-
pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache};
15+
pub use self::caches::{DefIdCache, DefaultCache, MyKey, QueryCache, SingleCache, VecCache};
1616
pub use self::dispatcher::{HashResult, QueryDispatcher};
1717
pub use self::job::{
1818
QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryLatch, QueryMap, break_query_cycles,

0 commit comments

Comments
 (0)