@@ -19,7 +19,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
19
19
use rustc_data_structures:: sync:: Lock ;
20
20
#[ cfg( parallel_compiler) ]
21
21
use rustc_data_structures:: { outline, sync} ;
22
- use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError , StashKey } ;
22
+ use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , StashKey } ;
23
23
use rustc_span:: { Span , DUMMY_SP } ;
24
24
use std:: cell:: Cell ;
25
25
use std:: collections:: hash_map:: Entry ;
@@ -45,11 +45,13 @@ enum QueryResult {
45
45
}
46
46
47
47
impl QueryResult {
48
- /// Unwraps the query job and if poisoned will raise a [`FatalError`]
49
- fn unwrap ( self ) -> QueryJob {
48
+ /// Unwraps the query job expecting that it has started.
49
+ fn expect_job ( self , query_name : & ' static str ) -> QueryJob {
50
50
match self {
51
51
Self :: Started ( job) => job,
52
- Self :: Poisoned => FatalError . raise ( ) ,
52
+ Self :: Poisoned => {
53
+ panic ! ( "job for query {} failed to start and was poisoned" , query_name)
54
+ }
53
55
}
54
56
}
55
57
}
@@ -105,6 +107,7 @@ where
105
107
{
106
108
state : & ' tcx QueryState < K > ,
107
109
key : K ,
110
+ query_name : & ' static str ,
108
111
}
109
112
110
113
#[ cold]
@@ -163,9 +166,10 @@ where
163
166
{
164
167
/// Completes the query by updating the query cache with the `result`,
165
168
/// signals the waiter and forgets the JobOwner, so it won't poison the query
166
- fn complete < C > ( self , cache : & C , result : C :: Value , dep_node_index : DepNodeIndex )
169
+ fn complete < C , Q > ( self , q : Q , cache : & C , result : C :: Value , dep_node_index : DepNodeIndex )
167
170
where
168
171
C : QueryCache < Key = K > ,
172
+ Q : QueryConfig < Qcx > ,
169
173
{
170
174
let key = self . key ;
171
175
let state = self . state ;
@@ -179,7 +183,7 @@ where
179
183
180
184
let job = {
181
185
let mut lock = state. active . lock_shard_by_value ( & key) ;
182
- lock. remove ( & key) . unwrap ( ) . unwrap ( )
186
+ lock. remove ( & key) . unwrap ( ) . expect_job ( q . name ( ) )
183
187
} ;
184
188
185
189
job. signal_complete ( ) ;
@@ -197,7 +201,7 @@ where
197
201
let state = self . state ;
198
202
let job = {
199
203
let mut shard = state. active . lock_shard_by_value ( & self . key ) ;
200
- let job = shard. remove ( & self . key ) . unwrap ( ) . unwrap ( ) ;
204
+ let job = shard. remove ( & self . key ) . unwrap ( ) . expect_job ( self . query_name ) ;
201
205
202
206
shard. insert ( self . key , QueryResult :: Poisoned ) ;
203
207
job
@@ -282,7 +286,7 @@ where
282
286
// We didn't find the query result in the query cache. Check if it was
283
287
// poisoned due to a panic instead.
284
288
let lock = query. query_state ( qcx) . active . get_shard_by_value ( & key) . lock ( ) ;
285
- lock. get ( & key) . unwrap ( ) ;
289
+ lock. get ( & key) . expect_job ( query . name ( ) ) ;
286
290
panic ! (
287
291
"query result must in the cache or the query must be poisoned after a wait"
288
292
) ;
@@ -362,7 +366,9 @@ where
362
366
// so we just return the error.
363
367
cycle_error ( query, qcx, id, span)
364
368
}
365
- QueryResult :: Poisoned => FatalError . raise ( ) ,
369
+ QueryResult :: Poisoned => {
370
+ panic ! ( "job for query {} failed to start and was poisoned" , query. name( ) )
371
+ }
366
372
}
367
373
}
368
374
}
@@ -382,7 +388,7 @@ where
382
388
Qcx : QueryContext ,
383
389
{
384
390
// Use `JobOwner` so the query will be poisoned if executing it panics.
385
- let job_owner = JobOwner { state, key } ;
391
+ let job_owner = JobOwner { state, key, query_name : query . name ( ) } ;
386
392
387
393
debug_assert_eq ! ( qcx. dep_context( ) . dep_graph( ) . is_fully_enabled( ) , INCR ) ;
388
394
@@ -437,7 +443,7 @@ where
437
443
}
438
444
}
439
445
}
440
- job_owner. complete ( cache, result, dep_node_index) ;
446
+ job_owner. complete ( cache, q , result, dep_node_index) ;
441
447
442
448
( result, Some ( dep_node_index) )
443
449
}
0 commit comments