1
1
use crate :: dep_graph:: DepNodeIndex ;
2
2
use crate :: query:: config:: QueryContext ;
3
- use crate :: query:: plumbing:: { QueryLookup , QueryState , QueryStateShard } ;
3
+ use crate :: query:: plumbing:: { QueryLookup , QueryState } ;
4
4
5
5
use rustc_data_structures:: fx:: FxHashMap ;
6
6
use rustc_data_structures:: sharded:: Sharded ;
@@ -21,19 +21,15 @@ pub trait QueryCache<CTX: QueryContext>: Default {
21
21
/// It returns the shard index and a lock guard to the shard,
22
22
/// which will be used if the query is not in the cache and we need
23
23
/// to compute it.
24
- fn lookup < R , GetCache , OnHit , OnMiss > (
24
+ fn lookup < R , OnHit , OnMiss > (
25
25
& self ,
26
26
state : & QueryState < CTX , Self > ,
27
- get_cache : GetCache ,
28
27
key : Self :: Key ,
29
28
// `on_hit` can be called while holding a lock to the query state shard.
30
29
on_hit : OnHit ,
31
30
on_miss : OnMiss ,
32
31
) -> R
33
32
where
34
- GetCache : for < ' a > Fn (
35
- & ' a mut QueryStateShard < CTX , Self :: Key , Self :: Sharded > ,
36
- ) -> & ' a mut Self :: Sharded ,
37
33
OnHit : FnOnce ( & Self :: Value , DepNodeIndex ) -> R ,
38
34
OnMiss : FnOnce ( Self :: Key , QueryLookup < ' _ , CTX , Self :: Key , Self :: Sharded > ) -> R ;
39
35
@@ -76,24 +72,21 @@ impl<CTX: QueryContext, K: Eq + Hash, V: Clone> QueryCache<CTX> for DefaultCache
76
72
type Sharded = FxHashMap < K , ( V , DepNodeIndex ) > ;
77
73
78
74
#[ inline( always) ]
79
- fn lookup < R , GetCache , OnHit , OnMiss > (
75
+ fn lookup < R , OnHit , OnMiss > (
80
76
& self ,
81
77
state : & QueryState < CTX , Self > ,
82
- get_cache : GetCache ,
83
78
key : K ,
84
79
on_hit : OnHit ,
85
80
on_miss : OnMiss ,
86
81
) -> R
87
82
where
88
- GetCache :
89
- for < ' a > Fn ( & ' a mut QueryStateShard < CTX , K , Self :: Sharded > ) -> & ' a mut Self :: Sharded ,
90
83
OnHit : FnOnce ( & V , DepNodeIndex ) -> R ,
91
84
OnMiss : FnOnce ( K , QueryLookup < ' _ , CTX , K , Self :: Sharded > ) -> R ,
92
85
{
93
86
let mut lookup = state. get_lookup ( & key) ;
94
87
let lock = & mut * lookup. lock ;
95
88
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) ;
97
90
98
91
if let Some ( ( _, value) ) = result { on_hit ( & value. 0 , value. 1 ) } else { on_miss ( key, lookup) }
99
92
}
0 commit comments