@@ -378,24 +378,16 @@ impl<K: DepKind> DepGraph<K> {
378378 /// Executes something within an "anonymous" task, that is, a task the
379379 /// `DepNode` of which is determined by the list of inputs it read from.
380380 #[ 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 ,
382383 cx : Tcx ,
383384 dep_kind : K ,
384385 op : OP ,
385386 ) -> ( R , DepNodeIndex )
386387 where
387388 OP : FnOnce ( ) -> R ,
388389 {
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 :: < ( ) > )
399391 }
400392
401393 /// Executes something within an "anonymous" task. The `hash` is used for
@@ -405,20 +397,21 @@ impl<K: DepKind> DepGraph<K> {
405397 cx : Ctxt ,
406398 dep_kind : K ,
407399 op : OP ,
408- hash : H ,
400+ hash : Option < H > ,
409401 ) -> ( R , DepNodeIndex )
410402 where
411403 OP : FnOnce ( ) -> R ,
412- H : FnOnce ( & TaskDeps < K > ) -> Fingerprint ,
404+ H : Hash ,
413405 {
414406 debug_assert ! ( !cx. is_eval_always( dep_kind) ) ;
415407
416408 if let Some ( ref data) = self . data {
417409 let task_deps = Lock :: new ( TaskDeps :: default ( ) ) ;
418410 let result = K :: with_deps ( TaskDepsRef :: Allow ( & task_deps) , op) ;
419411 let task_deps = task_deps. into_inner ( ) ;
412+ let task_deps = task_deps. reads ;
420413
421- let dep_node_index = match task_deps. reads . len ( ) {
414+ let dep_node_index = match task_deps. len ( ) {
422415 0 => {
423416 // Because the dep-node id of anon nodes is computed from the sets of its
424417 // dependencies we already know what the ID of this dependency-less node is
@@ -429,23 +422,33 @@ impl<K: DepKind> DepGraph<K> {
429422 }
430423 1 => {
431424 // When there is only one dependency, don't bother creating a node.
432- task_deps. reads [ 0 ]
425+ task_deps[ 0 ]
433426 }
434427 _ => {
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+ }
436439
437440 let target_dep_node = DepNode {
438441 kind : dep_kind,
439442 // Fingerprint::combine() is faster than sending Fingerprint
440443 // through the StableHasher (at least as long as StableHasher
441444 // 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 ( ) ,
443446 } ;
444447
445448 data. current . intern_new_node (
446449 cx. profiler ( ) ,
447450 target_dep_node,
448- task_deps. reads ,
451+ task_deps,
449452 Fingerprint :: ZERO ,
450453 )
451454 }
0 commit comments