@@ -360,33 +360,9 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
360360 [ anon] TraitSelect ,
361361
362362 [ ] CompileCodegenUnit ( Symbol ) ,
363-
364- [ eval_always] Analysis ( CrateNum ) ,
365363] ) ;
366364
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 {
390366 const CAN_RECONSTRUCT_QUERY_KEY : bool ;
391367
392368 /// This method turns the parameters of a DepNodeConstructor into an opaque
@@ -400,6 +376,14 @@ trait DepNodeParams<'tcx>: fmt::Debug {
400376 fn to_debug_str ( & self , _: TyCtxt < ' tcx > ) -> String {
401377 format ! ( "{:?}" , self )
402378 }
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 > ;
403387}
404388
405389impl < ' tcx , T > DepNodeParams < ' tcx > for T
@@ -420,6 +404,10 @@ where
420404 default fn to_debug_str ( & self , _: TyCtxt < ' tcx > ) -> String {
421405 format ! ( "{:?}" , * self )
422406 }
407+
408+ default fn recover ( _: TyCtxt < ' tcx > , _: & DepNode ) -> Option < Self > {
409+ None
410+ }
423411}
424412
425413impl < ' tcx > DepNodeParams < ' tcx > for DefId {
@@ -432,6 +420,10 @@ impl<'tcx> DepNodeParams<'tcx> for DefId {
432420 fn to_debug_str ( & self , tcx : TyCtxt < ' tcx > ) -> String {
433421 tcx. def_path_str ( * self )
434422 }
423+
424+ fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
425+ dep_node. extract_def_id ( tcx)
426+ }
435427}
436428
437429impl < ' tcx > DepNodeParams < ' tcx > for DefIndex {
@@ -444,6 +436,10 @@ impl<'tcx> DepNodeParams<'tcx> for DefIndex {
444436 fn to_debug_str ( & self , tcx : TyCtxt < ' tcx > ) -> String {
445437 tcx. def_path_str ( DefId :: local ( * self ) )
446438 }
439+
440+ fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
441+ dep_node. extract_def_id ( tcx) . map ( |id| id. index )
442+ }
447443}
448444
449445impl < ' tcx > DepNodeParams < ' tcx > for CrateNum {
@@ -457,6 +453,10 @@ impl<'tcx> DepNodeParams<'tcx> for CrateNum {
457453 fn to_debug_str ( & self , tcx : TyCtxt < ' tcx > ) -> String {
458454 tcx. crate_name ( * self ) . to_string ( )
459455 }
456+
457+ fn recover ( tcx : TyCtxt < ' tcx > , dep_node : & DepNode ) -> Option < Self > {
458+ dep_node. extract_def_id ( tcx) . map ( |id| id. krate )
459+ }
460460}
461461
462462impl < ' tcx > DepNodeParams < ' tcx > for ( DefId , DefId ) {
0 commit comments