@@ -46,10 +46,9 @@ impl<C: QueryCache> Default for QueryCacheStore<C> {
46
46
}
47
47
48
48
/// Values used when checking a query cache which can be reused on a cache-miss to execute the query.
49
- pub struct QueryLookup < ' tcx , C > {
49
+ pub struct QueryLookup {
50
50
pub ( super ) key_hash : u64 ,
51
51
shard : usize ,
52
- pub ( super ) lock : LockGuard < ' tcx , C > ,
53
52
}
54
53
55
54
// We compute the key's hash once and then use it for both the
@@ -62,11 +61,14 @@ fn hash_for_shard<K: Hash>(key: &K) -> u64 {
62
61
}
63
62
64
63
impl < C : QueryCache > QueryCacheStore < C > {
65
- pub ( super ) fn get_lookup < ' tcx > ( & ' tcx self , key : & C :: Key ) -> QueryLookup < ' tcx , C :: Sharded > {
64
+ pub ( super ) fn get_lookup < ' tcx > (
65
+ & ' tcx self ,
66
+ key : & C :: Key ,
67
+ ) -> ( QueryLookup , LockGuard < ' tcx , C :: Sharded > ) {
66
68
let key_hash = hash_for_shard ( key) ;
67
69
let shard = get_shard_index_by_hash ( key_hash) ;
68
70
let lock = self . shards . get_shard_by_index ( shard) . lock ( ) ;
69
- QueryLookup { key_hash, shard, lock }
71
+ ( QueryLookup { key_hash, shard } , lock)
70
72
}
71
73
72
74
pub fn iter_results < R > (
@@ -178,19 +180,18 @@ where
178
180
/// This function is inlined because that results in a noticeable speed-up
179
181
/// for some compile-time benchmarks.
180
182
#[ inline( always) ]
181
- fn try_start < ' a , ' b , CTX > (
183
+ fn try_start < ' b , CTX > (
182
184
tcx : CTX ,
183
185
state : & ' b QueryState < CTX :: DepKind , CTX :: Query , C :: Key > ,
184
186
cache : & ' b QueryCacheStore < C > ,
185
187
span : Span ,
186
188
key : & C :: Key ,
187
- lookup : QueryLookup < ' a , C :: Sharded > ,
189
+ lookup : QueryLookup ,
188
190
query : & QueryVtable < CTX , C :: Key , C :: Value > ,
189
191
) -> TryGetJob < ' b , CTX :: DepKind , CTX :: Query , C >
190
192
where
191
193
CTX : QueryContext ,
192
194
{
193
- mem:: drop ( lookup. lock ) ;
194
195
let shard = lookup. shard ;
195
196
let mut state_lock = state. shards . get_shard_by_index ( shard) . lock ( ) ;
196
197
let lock = & mut * state_lock;
@@ -379,7 +380,7 @@ fn try_get_cached<'a, CTX, C, R, OnHit>(
379
380
key : & C :: Key ,
380
381
// `on_hit` can be called while holding a lock to the query cache
381
382
on_hit : OnHit ,
382
- ) -> Result < R , QueryLookup < ' a , C :: Sharded > >
383
+ ) -> Result < R , QueryLookup >
383
384
where
384
385
C : QueryCache ,
385
386
CTX : QueryContext ,
@@ -403,7 +404,7 @@ fn try_execute_query<CTX, C>(
403
404
cache : & QueryCacheStore < C > ,
404
405
span : Span ,
405
406
key : C :: Key ,
406
- lookup : QueryLookup < ' _ , C :: Sharded > ,
407
+ lookup : QueryLookup ,
407
408
query : & QueryVtable < CTX , C :: Key , C :: Value > ,
408
409
) -> C :: Stored
409
410
where
0 commit comments