@@ -7,6 +7,8 @@ use crate::query::caches::QueryCache;
7
7
use crate :: query:: config:: { QueryDescription , QueryVTable } ;
8
8
use crate :: query:: job:: { report_cycle, QueryInfo , QueryJob , QueryJobId , QueryJobInfo } ;
9
9
use crate :: query:: { QueryContext , QueryMap , QuerySideEffects , QueryStackFrame } ;
10
+ use crate :: values:: Value ;
11
+ use crate :: HandleCycleError ;
10
12
use rustc_data_structures:: fingerprint:: Fingerprint ;
11
13
use rustc_data_structures:: fx:: FxHashMap ;
12
14
#[ cfg( parallel_compiler) ]
@@ -118,19 +120,46 @@ where
118
120
fn mk_cycle < CTX , V , R > (
119
121
tcx : CTX ,
120
122
error : CycleError ,
121
- handle_cycle_error : fn ( CTX , DiagnosticBuilder < ' _ , ErrorGuaranteed > ) -> V ,
123
+ handler : HandleCycleError ,
122
124
cache : & dyn crate :: query:: QueryStorage < Value = V , Stored = R > ,
123
125
) -> R
124
126
where
125
127
CTX : QueryContext ,
126
- V : std:: fmt:: Debug ,
128
+ V : std:: fmt:: Debug + Value < CTX :: DepContext > ,
127
129
R : Clone ,
128
130
{
129
131
let error = report_cycle ( tcx. dep_context ( ) . sess ( ) , error) ;
130
- let value = handle_cycle_error ( tcx, error) ;
132
+ let value = handle_cycle_error ( * tcx. dep_context ( ) , error, handler ) ;
131
133
cache. store_nocache ( value)
132
134
}
133
135
136
+ fn handle_cycle_error < CTX , V > (
137
+ tcx : CTX ,
138
+ mut error : DiagnosticBuilder < ' _ , ErrorGuaranteed > ,
139
+ handler : HandleCycleError ,
140
+ ) -> V
141
+ where
142
+ CTX : DepContext ,
143
+ V : Value < CTX > ,
144
+ {
145
+ use HandleCycleError :: * ;
146
+ match handler {
147
+ Error => {
148
+ error. emit ( ) ;
149
+ Value :: from_cycle_error ( tcx)
150
+ }
151
+ Fatal => {
152
+ error. emit ( ) ;
153
+ tcx. sess ( ) . abort_if_errors ( ) ;
154
+ unreachable ! ( )
155
+ }
156
+ DelayBug => {
157
+ error. delay_as_bug ( ) ;
158
+ Value :: from_cycle_error ( tcx)
159
+ }
160
+ }
161
+ }
162
+
134
163
impl < ' tcx , K > JobOwner < ' tcx , K >
135
164
where
136
165
K : Eq + Hash + Clone ,
@@ -336,6 +365,7 @@ fn try_execute_query<CTX, C>(
336
365
where
337
366
C : QueryCache ,
338
367
C :: Key : Clone + DepNodeParams < CTX :: DepContext > ,
368
+ C :: Value : Value < CTX :: DepContext > ,
339
369
CTX : QueryContext ,
340
370
{
341
371
match JobOwner :: < ' _ , C :: Key > :: try_start ( & tcx, state, span, key. clone ( ) ) {
@@ -686,6 +716,7 @@ pub fn get_query<Q, CTX>(tcx: CTX, span: Span, key: Q::Key, mode: QueryMode) ->
686
716
where
687
717
Q : QueryDescription < CTX > ,
688
718
Q :: Key : DepNodeParams < CTX :: DepContext > ,
719
+ Q :: Value : Value < CTX :: DepContext > ,
689
720
CTX : QueryContext ,
690
721
{
691
722
let query = Q :: make_vtable ( tcx, & key) ;
@@ -718,6 +749,7 @@ pub fn force_query<Q, CTX>(tcx: CTX, key: Q::Key, dep_node: DepNode<CTX::DepKind
718
749
where
719
750
Q : QueryDescription < CTX > ,
720
751
Q :: Key : DepNodeParams < CTX :: DepContext > ,
752
+ Q :: Value : Value < CTX :: DepContext > ,
721
753
CTX : QueryContext ,
722
754
{
723
755
// We may be concurrently trying both execute and force a query.
0 commit comments