@@ -79,14 +79,14 @@ struct DepGraphData {
79
79
loaded_from_cache : Lock < FxHashMap < DepNodeIndex , bool > > ,
80
80
}
81
81
82
- pub fn hash_result < R > ( hcx : & mut StableHashingContext < ' _ > , result : & R ) -> Option < Fingerprint >
82
+ pub fn hash_result < R > ( hcx : & mut StableHashingContext < ' _ > , result : & R ) -> Fingerprint
83
83
where
84
84
R : for < ' a > HashStable < StableHashingContext < ' a > > ,
85
85
{
86
86
let mut stable_hasher = StableHasher :: new ( ) ;
87
87
result. hash_stable ( hcx, & mut stable_hasher) ;
88
88
89
- Some ( stable_hasher. finish ( ) )
89
+ stable_hasher. finish ( )
90
90
}
91
91
92
92
impl DepGraph {
@@ -193,7 +193,7 @@ impl DepGraph {
193
193
cx : C ,
194
194
arg : A ,
195
195
task : fn ( C , A ) -> R ,
196
- hash_result : impl FnOnce ( & mut StableHashingContext < ' _ > , & R ) -> Option < Fingerprint > ,
196
+ hash_result : Option < impl FnOnce ( & mut StableHashingContext < ' _ > , & R ) -> Fingerprint > ,
197
197
) -> ( R , DepNodeIndex )
198
198
where
199
199
C : DepGraphSafe + StableHashingContextProvider < ' a > ,
@@ -229,7 +229,8 @@ impl DepGraph {
229
229
|data, key, fingerprint, _| {
230
230
data. borrow_mut ( ) . alloc_node ( key, SmallVec :: new ( ) , fingerprint)
231
231
} ,
232
- hash_result :: < R > )
232
+ Some ( hash_result :: < R > )
233
+ )
233
234
}
234
235
235
236
fn with_task_impl < ' a , C , A , R > (
@@ -244,24 +245,21 @@ impl DepGraph {
244
245
DepNode ,
245
246
Fingerprint ,
246
247
Option < TaskDeps > ) -> DepNodeIndex ,
247
- hash_result : impl FnOnce ( & mut StableHashingContext < ' _ > , & R ) -> Option < Fingerprint > ,
248
+ hash_result : Option < impl FnOnce ( & mut StableHashingContext < ' _ > , & R ) -> Fingerprint > ,
248
249
) -> ( R , DepNodeIndex )
249
250
where
250
251
C : DepGraphSafe + StableHashingContextProvider < ' a > ,
251
252
{
252
253
if let Some ( ref data) = self . data {
253
254
let task_deps = create_task ( key) . map ( |deps| Lock :: new ( deps) ) ;
254
255
255
- // In incremental mode, hash the result of the task. We don't
256
- // do anything with the hash yet, but we are computing it
257
- // anyway so that
258
- // - we make sure that the infrastructure works and
259
- // - we can get an idea of the runtime cost.
260
- let mut hcx = cx. get_stable_hashing_context ( ) ;
261
-
262
- if cfg ! ( debug_assertions) {
263
- profq_msg ( hcx. sess ( ) , ProfileQueriesMsg :: TaskBegin ( key. clone ( ) ) )
264
- } ;
256
+ let hcx = hash_result. as_ref ( ) . map ( |_| {
257
+ let hcx = cx. get_stable_hashing_context ( ) ;
258
+ if cfg ! ( debug_assertions) {
259
+ profq_msg ( hcx. sess ( ) , ProfileQueriesMsg :: TaskBegin ( key. clone ( ) ) )
260
+ } ;
261
+ hcx
262
+ } ) ;
265
263
266
264
let result = if no_tcx {
267
265
task ( cx, arg)
@@ -279,10 +277,12 @@ impl DepGraph {
279
277
} ;
280
278
281
279
if cfg ! ( debug_assertions) {
282
- profq_msg ( hcx. sess ( ) , ProfileQueriesMsg :: TaskEnd )
280
+ hcx . as_ref ( ) . map ( |hcx| profq_msg ( hcx. sess ( ) , ProfileQueriesMsg :: TaskEnd ) ) ;
283
281
} ;
284
282
285
- let current_fingerprint = hash_result ( & mut hcx, & result) ;
283
+ let current_fingerprint = hash_result. map ( |hash_result| {
284
+ hash_result ( & mut hcx. unwrap ( ) , & result)
285
+ } ) ;
286
286
287
287
let dep_node_index = finish_task_and_alloc_depnode (
288
288
& data. current ,
@@ -291,7 +291,9 @@ impl DepGraph {
291
291
task_deps. map ( |lock| lock. into_inner ( ) ) ,
292
292
) ;
293
293
294
- let print_status = cfg ! ( debug_assertions) && hcx. sess ( ) . opts . debugging_opts . dep_tasks ;
294
+ let print_status = cfg ! ( debug_assertions) && ty:: tls:: with_opt ( |tcx| {
295
+ tcx. map ( |tcx| tcx. sess . opts . debugging_opts . dep_tasks ) . unwrap_or ( false )
296
+ } ) ;
295
297
296
298
// Determine the color of the new DepNode.
297
299
if let Some ( prev_index) = data. previous . node_to_index_opt ( & key) {
@@ -378,7 +380,7 @@ impl DepGraph {
378
380
cx : C ,
379
381
arg : A ,
380
382
task : fn ( C , A ) -> R ,
381
- hash_result : impl FnOnce ( & mut StableHashingContext < ' _ > , & R ) -> Option < Fingerprint > ,
383
+ hash_result : Option < impl FnOnce ( & mut StableHashingContext < ' _ > , & R ) -> Fingerprint > ,
382
384
) -> ( R , DepNodeIndex )
383
385
where
384
386
C : DepGraphSafe + StableHashingContextProvider < ' a > ,
0 commit comments