@@ -46,10 +46,9 @@ impl<C: QueryCache> Default for QueryCacheStore<C> {
4646}
4747
4848/// 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 {
5050 pub ( super ) key_hash : u64 ,
5151 shard : usize ,
52- pub ( super ) lock : LockGuard < ' tcx , C > ,
5352}
5453
5554// 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 {
6261}
6362
6463impl < 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 > ) {
6668 let key_hash = hash_for_shard ( key) ;
6769 let shard = get_shard_index_by_hash ( key_hash) ;
6870 let lock = self . shards . get_shard_by_index ( shard) . lock ( ) ;
69- QueryLookup { key_hash, shard, lock }
71+ ( QueryLookup { key_hash, shard } , lock)
7072 }
7173
7274 pub fn iter_results < R > (
@@ -178,19 +180,18 @@ where
178180 /// This function is inlined because that results in a noticeable speed-up
179181 /// for some compile-time benchmarks.
180182 #[ inline( always) ]
181- fn try_start < ' a , ' b , CTX > (
183+ fn try_start < ' b , CTX > (
182184 tcx : CTX ,
183185 state : & ' b QueryState < CTX :: DepKind , CTX :: Query , C :: Key > ,
184186 cache : & ' b QueryCacheStore < C > ,
185187 span : Span ,
186188 key : & C :: Key ,
187- lookup : QueryLookup < ' a , C :: Sharded > ,
189+ lookup : QueryLookup ,
188190 query : & QueryVtable < CTX , C :: Key , C :: Value > ,
189191 ) -> TryGetJob < ' b , CTX :: DepKind , CTX :: Query , C >
190192 where
191193 CTX : QueryContext ,
192194 {
193- mem:: drop ( lookup. lock ) ;
194195 let shard = lookup. shard ;
195196 let mut state_lock = state. shards . get_shard_by_index ( shard) . lock ( ) ;
196197 let lock = & mut * state_lock;
@@ -379,7 +380,7 @@ fn try_get_cached<'a, CTX, C, R, OnHit>(
379380 key : & C :: Key ,
380381 // `on_hit` can be called while holding a lock to the query cache
381382 on_hit : OnHit ,
382- ) -> Result < R , QueryLookup < ' a , C :: Sharded > >
383+ ) -> Result < R , QueryLookup >
383384where
384385 C : QueryCache ,
385386 CTX : QueryContext ,
@@ -403,7 +404,7 @@ fn try_execute_query<CTX, C>(
403404 cache : & QueryCacheStore < C > ,
404405 span : Span ,
405406 key : C :: Key ,
406- lookup : QueryLookup < ' _ , C :: Sharded > ,
407+ lookup : QueryLookup ,
407408 query : & QueryVtable < CTX , C :: Key , C :: Value > ,
408409) -> C :: Stored
409410where
0 commit comments