2
2
//! generate the actual methods on tcx which find and execute the provider,
3
3
//! manage the caches, and so forth.
4
4
5
- use crate :: dep_graph:: { DepContext , DepKind , DepNode , DepNodeParams } ;
6
- use crate :: dep_graph:: { DepNodeIndex , SerializedDepNodeIndex } ;
5
+ use crate :: dep_graph:: { DepContext , DepKind , DepNode , DepNodeIndex , DepNodeParams } ;
7
6
use crate :: query:: caches:: QueryCache ;
8
7
use crate :: query:: config:: { QueryDescription , QueryVtable , QueryVtableExt } ;
9
8
use crate :: query:: job:: {
@@ -496,21 +495,7 @@ where
496
495
// promoted to the current session during
497
496
// `try_mark_green()`, so we can ignore them here.
498
497
let loaded = tcx. start_query ( job. id , None , || {
499
- let marked = dep_graph. try_mark_green_and_read ( tcx, & dep_node) ;
500
- marked. map ( |( prev_dep_node_index, dep_node_index) | {
501
- (
502
- load_from_disk_and_cache_in_memory (
503
- tcx,
504
- key. clone ( ) ,
505
- prev_dep_node_index,
506
- dep_node_index,
507
- & dep_node,
508
- query,
509
- compute,
510
- ) ,
511
- dep_node_index,
512
- )
513
- } )
498
+ try_load_from_disk_and_cache_in_memory ( tcx, key. clone ( ) , & dep_node, query, compute)
514
499
} ) ;
515
500
if let Some ( ( result, dep_node_index) ) = loaded {
516
501
return job. complete ( result, dep_node_index) ;
@@ -522,21 +507,23 @@ where
522
507
result
523
508
}
524
509
525
- fn load_from_disk_and_cache_in_memory < CTX , K , V : Debug > (
510
+ fn try_load_from_disk_and_cache_in_memory < CTX , K , V > (
526
511
tcx : CTX ,
527
512
key : K ,
528
- prev_dep_node_index : SerializedDepNodeIndex ,
529
- dep_node_index : DepNodeIndex ,
530
513
dep_node : & DepNode < CTX :: DepKind > ,
531
514
query : & QueryVtable < CTX , K , V > ,
532
515
compute : fn ( CTX :: DepContext , K ) -> V ,
533
- ) -> V
516
+ ) -> Option < ( V , DepNodeIndex ) >
534
517
where
535
518
CTX : QueryContext ,
519
+ V : Debug ,
536
520
{
537
521
// Note this function can be called concurrently from the same query
538
522
// We must ensure that this is handled correctly.
539
523
524
+ let ( prev_dep_node_index, dep_node_index) =
525
+ tcx. dep_context ( ) . dep_graph ( ) . try_mark_green_and_read ( tcx, & dep_node) ?;
526
+
540
527
debug_assert ! ( tcx. dep_context( ) . dep_graph( ) . is_green( dep_node) ) ;
541
528
542
529
// First we try to load the result from the on-disk cache.
@@ -558,7 +545,7 @@ where
558
545
None
559
546
} ;
560
547
561
- if let Some ( result) = result {
548
+ let result = if let Some ( result) = result {
562
549
// If `-Zincremental-verify-ich` is specified, re-hash results from
563
550
// the cache and make sure that they have the expected fingerprint.
564
551
if unlikely ! ( tcx. dep_context( ) . sess( ) . opts. debugging_opts. incremental_verify_ich) {
@@ -588,7 +575,9 @@ where
588
575
incremental_verify_ich ( * tcx. dep_context ( ) , & result, dep_node, query) ;
589
576
590
577
result
591
- }
578
+ } ;
579
+
580
+ Some ( ( result, dep_node_index) )
592
581
}
593
582
594
583
fn incremental_verify_ich < CTX , K , V : Debug > (
0 commit comments