@@ -360,33 +360,9 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
360
360
[ anon] TraitSelect ,
361
361
362
362
[ ] CompileCodegenUnit ( Symbol ) ,
363
-
364
- [ eval_always] Analysis ( CrateNum ) ,
365
363
] ) ;
366
364
367
- pub trait RecoverKey < ' tcx > : Sized {
368
- fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > ;
369
- }
370
-
371
- impl RecoverKey < ' tcx > for CrateNum {
372
- fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
373
- dep_node. extract_def_id ( tcx) . map ( |id| id. krate )
374
- }
375
- }
376
-
377
- impl RecoverKey < ' tcx > for DefId {
378
- fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
379
- dep_node. extract_def_id ( tcx)
380
- }
381
- }
382
-
383
- impl RecoverKey < ' tcx > for DefIndex {
384
- fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
385
- dep_node. extract_def_id ( tcx) . map ( |id| id. index )
386
- }
387
- }
388
-
389
- trait DepNodeParams < ' tcx > : fmt:: Debug {
365
+ pub ( crate ) trait DepNodeParams < ' tcx > : fmt:: Debug + Sized {
390
366
const CAN_RECONSTRUCT_QUERY_KEY : bool ;
391
367
392
368
/// This method turns the parameters of a DepNodeConstructor into an opaque
@@ -400,6 +376,14 @@ trait DepNodeParams<'tcx>: fmt::Debug {
400
376
fn to_debug_str ( & self , _: TyCtxt < ' tcx > ) -> String {
401
377
format ! ( "{:?}" , self )
402
378
}
379
+
380
+ /// This method tries to recover the query key from the given `DepNode`,
381
+ /// something which is needed when forcing `DepNode`s during red-green
382
+ /// evaluation. The query system will only call this method if
383
+ /// `CAN_RECONSTRUCT_QUERY_KEY` is `true`.
384
+ /// It is always valid to return `None` here, in which case incremental
385
+ /// compilation will treat the query as having changed instead of forcing it.
386
+ fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > ;
403
387
}
404
388
405
389
impl < ' tcx , T > DepNodeParams < ' tcx > for T
@@ -420,6 +404,10 @@ where
420
404
default fn to_debug_str ( & self , _: TyCtxt < ' tcx > ) -> String {
421
405
format ! ( "{:?}" , * self )
422
406
}
407
+
408
+ default fn recover ( _: TyCtxt < ' tcx > , _: & DepNode ) -> Option < Self > {
409
+ None
410
+ }
423
411
}
424
412
425
413
impl < ' tcx > DepNodeParams < ' tcx > for DefId {
@@ -432,6 +420,10 @@ impl<'tcx> DepNodeParams<'tcx> for DefId {
432
420
fn to_debug_str ( & self , tcx : TyCtxt < ' tcx > ) -> String {
433
421
tcx. def_path_str ( * self )
434
422
}
423
+
424
+ fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
425
+ dep_node. extract_def_id ( tcx)
426
+ }
435
427
}
436
428
437
429
impl < ' tcx > DepNodeParams < ' tcx > for DefIndex {
@@ -444,6 +436,10 @@ impl<'tcx> DepNodeParams<'tcx> for DefIndex {
444
436
fn to_debug_str ( & self , tcx : TyCtxt < ' tcx > ) -> String {
445
437
tcx. def_path_str ( DefId :: local ( * self ) )
446
438
}
439
+
440
+ fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
441
+ dep_node. extract_def_id ( tcx) . map ( |id| id. index )
442
+ }
447
443
}
448
444
449
445
impl < ' tcx > DepNodeParams < ' tcx > for CrateNum {
@@ -457,6 +453,10 @@ impl<'tcx> DepNodeParams<'tcx> for CrateNum {
457
453
fn to_debug_str ( & self , tcx : TyCtxt < ' tcx > ) -> String {
458
454
tcx. crate_name ( * self ) . to_string ( )
459
455
}
456
+
457
+ fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
458
+ dep_node. extract_def_id ( tcx) . map ( |id| id. krate )
459
+ }
460
460
}
461
461
462
462
impl < ' tcx > DepNodeParams < ' tcx > for ( DefId , DefId ) {
0 commit comments