@@ -3,20 +3,26 @@ use std::hash::Hash;
33use std:: sync:: OnceLock ;
44
55use rustc_data_structures:: sharded:: ShardedHashMap ;
6+ use rustc_data_structures:: stable_hasher:: HashStable ;
67pub use rustc_data_structures:: vec_cache:: VecCache ;
78use rustc_hir:: def_id:: LOCAL_CRATE ;
89use rustc_index:: Idx ;
910use rustc_span:: def_id:: { DefId , DefIndex } ;
1011
1112use 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.
1824pub 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
4955impl < K , V > QueryCache for DefaultCache < K , V >
5056where
51- K : Eq + Hash + Copy + Debug ,
57+ K : MyKey ,
5258 V : Copy ,
5359{
5460 type Key = K ;
@@ -175,7 +181,7 @@ where
175181
176182impl < K , V > QueryCache for VecCache < K , V , DepNodeIndex >
177183where
178- K : Idx + Eq + Hash + Copy + Debug ,
184+ K : Idx + MyKey ,
179185 V : Copy ,
180186{
181187 type Key = K ;
0 commit comments