@@ -11,6 +11,7 @@ use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
11
11
use parking_lot:: Mutex ;
12
12
use smallvec:: { smallvec, SmallVec } ;
13
13
use std:: collections:: hash_map:: Entry ;
14
+ use std:: fmt:: Debug ;
14
15
use std:: hash:: Hash ;
15
16
use std:: marker:: PhantomData ;
16
17
use std:: sync:: atomic:: Ordering :: Relaxed ;
@@ -208,7 +209,7 @@ impl<K: DepKind> DepGraph<K> {
208
209
/// `arg` parameter.
209
210
///
210
211
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/incremental-compilation.html
211
- pub fn with_task < Ctxt : HasDepContext < DepKind = K > , A , R > (
212
+ pub fn with_task < Ctxt : HasDepContext < DepKind = K > , A : Debug , R > (
212
213
& self ,
213
214
key : DepNode < K > ,
214
215
cx : Ctxt ,
@@ -234,7 +235,7 @@ impl<K: DepKind> DepGraph<K> {
234
235
)
235
236
}
236
237
237
- fn with_task_impl < Ctxt : HasDepContext < DepKind = K > , A , R > (
238
+ fn with_task_impl < Ctxt : HasDepContext < DepKind = K > , A : Debug , R > (
238
239
& self ,
239
240
key : DepNode < K > ,
240
241
cx : Ctxt ,
@@ -244,6 +245,20 @@ impl<K: DepKind> DepGraph<K> {
244
245
hash_result : impl FnOnce ( & mut Ctxt :: StableHashingContext , & R ) -> Option < Fingerprint > ,
245
246
) -> ( R , DepNodeIndex ) {
246
247
if let Some ( ref data) = self . data {
248
+ // If the following assertion triggers, it can have two reasons:
249
+ // 1. Something is wrong with DepNode creation, either here or
250
+ // in `DepGraph::try_mark_green()`.
251
+ // 2. Two distinct query keys get mapped to the same `DepNode`
252
+ // (see for example #48923).
253
+ assert ! (
254
+ !self . dep_node_exists( & key) ,
255
+ "forcing query with already existing `DepNode`\n \
256
+ - query-key: {:?}\n \
257
+ - dep-node: {:?}",
258
+ arg,
259
+ key
260
+ ) ;
261
+
247
262
let dcx = cx. dep_context ( ) ;
248
263
let task_deps = create_task ( key) . map ( Lock :: new) ;
249
264
let result = K :: with_deps ( task_deps. as_ref ( ) , || task ( cx, arg) ) ;
@@ -359,7 +374,7 @@ impl<K: DepKind> DepGraph<K> {
359
374
360
375
/// Executes something within an "eval-always" task which is a task
361
376
/// that runs whenever anything changes.
362
- pub fn with_eval_always_task < Ctxt : HasDepContext < DepKind = K > , A , R > (
377
+ pub fn with_eval_always_task < Ctxt : HasDepContext < DepKind = K > , A : Debug , R > (
363
378
& self ,
364
379
key : DepNode < K > ,
365
380
cx : Ctxt ,
0 commit comments