@@ -378,24 +378,16 @@ impl<K: DepKind> DepGraph<K> {
378
378
/// Executes something within an "anonymous" task, that is, a task the
379
379
/// `DepNode` of which is determined by the list of inputs it read from.
380
380
#[ inline]
381
- pub fn with_anon_task < Tcx : DepContext < DepKind = K > , OP , R > ( & self ,
381
+ pub fn with_anon_task < Tcx : DepContext < DepKind = K > , OP , R > (
382
+ & self ,
382
383
cx : Tcx ,
383
384
dep_kind : K ,
384
385
op : OP ,
385
386
) -> ( R , DepNodeIndex )
386
387
where
387
388
OP : FnOnce ( ) -> R ,
388
389
{
389
- self . with_hash_task ( cx, dep_kind, op, |task_deps| {
390
- // The dep node indices are hashed here instead of hashing the dep nodes of the
391
- // dependencies. These indices may refer to different nodes per session, but this isn't
392
- // a problem here because we that ensure the final dep node hash is per session only by
393
- // combining it with the per session random number `anon_id_seed`. This hash only need
394
- // to map the dependencies to a single value on a per session basis.
395
- let mut hasher = StableHasher :: new ( ) ;
396
- task_deps. reads . hash ( & mut hasher) ;
397
- hasher. finish ( )
398
- } )
390
+ self . with_hash_task ( cx, dep_kind, op, None :: < ( ) > )
399
391
}
400
392
401
393
/// Executes something within an "anonymous" task. The `hash` is used for
@@ -405,20 +397,21 @@ impl<K: DepKind> DepGraph<K> {
405
397
cx : Ctxt ,
406
398
dep_kind : K ,
407
399
op : OP ,
408
- hash : H ,
400
+ hash : Option < H > ,
409
401
) -> ( R , DepNodeIndex )
410
402
where
411
403
OP : FnOnce ( ) -> R ,
412
- H : FnOnce ( & TaskDeps < K > ) -> Fingerprint ,
404
+ H : Hash ,
413
405
{
414
406
debug_assert ! ( !cx. is_eval_always( dep_kind) ) ;
415
407
416
408
if let Some ( ref data) = self . data {
417
409
let task_deps = Lock :: new ( TaskDeps :: default ( ) ) ;
418
410
let result = K :: with_deps ( TaskDepsRef :: Allow ( & task_deps) , op) ;
419
411
let task_deps = task_deps. into_inner ( ) ;
412
+ let task_deps = task_deps. reads ;
420
413
421
- let dep_node_index = match task_deps. reads . len ( ) {
414
+ let dep_node_index = match task_deps. len ( ) {
422
415
0 => {
423
416
// Because the dep-node id of anon nodes is computed from the sets of its
424
417
// dependencies we already know what the ID of this dependency-less node is
@@ -429,23 +422,33 @@ impl<K: DepKind> DepGraph<K> {
429
422
}
430
423
1 => {
431
424
// When there is only one dependency, don't bother creating a node.
432
- task_deps. reads [ 0 ]
425
+ task_deps[ 0 ]
433
426
}
434
427
_ => {
435
- let hash_result = hash ( & task_deps) ;
428
+ let mut hasher = StableHasher :: new ( ) ;
429
+ if let Some ( hash) = hash {
430
+ hash. hash ( & mut hasher) ;
431
+ } else {
432
+ // The dep node indices are hashed here instead of hashing the dep nodes of the
433
+ // dependencies. These indices may refer to different nodes per session, but this isn't
434
+ // a problem here because we that ensure the final dep node hash is per session only by
435
+ // combining it with the per session random number `anon_id_seed`. This hash only need
436
+ // to map the dependencies to a single value on a per session basis.
437
+ task_deps. hash ( & mut hasher) ;
438
+ }
436
439
437
440
let target_dep_node = DepNode {
438
441
kind : dep_kind,
439
442
// Fingerprint::combine() is faster than sending Fingerprint
440
443
// through the StableHasher (at least as long as StableHasher
441
444
// is so slow).
442
- hash : data. current . anon_id_seed . combine ( hash_result ) . into ( ) ,
445
+ hash : data. current . anon_id_seed . combine ( hasher . finish ( ) ) . into ( ) ,
443
446
} ;
444
447
445
448
data. current . intern_new_node (
446
449
cx. profiler ( ) ,
447
450
target_dep_node,
448
- task_deps. reads ,
451
+ task_deps,
449
452
Fingerprint :: ZERO ,
450
453
)
451
454
}
0 commit comments