11use crate :: dep_graph:: DepNodeIndex ;
22use crate :: query:: config:: QueryContext ;
3- use crate :: query:: plumbing:: { QueryLookup , QueryState , QueryStateShard } ;
3+ use crate :: query:: plumbing:: { QueryLookup , QueryState } ;
44
55use rustc_data_structures:: fx:: FxHashMap ;
66use rustc_data_structures:: sharded:: Sharded ;
@@ -21,19 +21,15 @@ pub trait QueryCache<CTX: QueryContext>: Default {
2121 /// It returns the shard index and a lock guard to the shard,
2222 /// which will be used if the query is not in the cache and we need
2323 /// to compute it.
24- fn lookup < R , GetCache , OnHit , OnMiss > (
24+ fn lookup < R , OnHit , OnMiss > (
2525 & self ,
2626 state : & QueryState < CTX , Self > ,
27- get_cache : GetCache ,
2827 key : Self :: Key ,
2928 // `on_hit` can be called while holding a lock to the query state shard.
3029 on_hit : OnHit ,
3130 on_miss : OnMiss ,
3231 ) -> R
3332 where
34- GetCache : for < ' a > Fn (
35- & ' a mut QueryStateShard < CTX , Self :: Key , Self :: Sharded > ,
36- ) -> & ' a mut Self :: Sharded ,
3733 OnHit : FnOnce ( & Self :: Value , DepNodeIndex ) -> R ,
3834 OnMiss : FnOnce ( Self :: Key , QueryLookup < ' _ , CTX , Self :: Key , Self :: Sharded > ) -> R ;
3935
@@ -76,24 +72,21 @@ impl<CTX: QueryContext, K: Eq + Hash, V: Clone> QueryCache<CTX> for DefaultCache
7672 type Sharded = FxHashMap < K , ( V , DepNodeIndex ) > ;
7773
7874 #[ inline( always) ]
79- fn lookup < R , GetCache , OnHit , OnMiss > (
75+ fn lookup < R , OnHit , OnMiss > (
8076 & self ,
8177 state : & QueryState < CTX , Self > ,
82- get_cache : GetCache ,
8378 key : K ,
8479 on_hit : OnHit ,
8580 on_miss : OnMiss ,
8681 ) -> R
8782 where
88- GetCache :
89- for < ' a > Fn ( & ' a mut QueryStateShard < CTX , K , Self :: Sharded > ) -> & ' a mut Self :: Sharded ,
9083 OnHit : FnOnce ( & V , DepNodeIndex ) -> R ,
9184 OnMiss : FnOnce ( K , QueryLookup < ' _ , CTX , K , Self :: Sharded > ) -> R ,
9285 {
9386 let mut lookup = state. get_lookup ( & key) ;
9487 let lock = & mut * lookup. lock ;
9588
96- let result = get_cache ( lock) . raw_entry ( ) . from_key_hashed_nocheck ( lookup. key_hash , & key) ;
89+ let result = lock. cache . raw_entry ( ) . from_key_hashed_nocheck ( lookup. key_hash , & key) ;
9790
9891 if let Some ( ( _, value) ) = result { on_hit ( & value. 0 , value. 1 ) } else { on_miss ( key, lookup) }
9992 }
0 commit comments