@@ -79,9 +79,14 @@ macro_rules! erase {
7979 ( $x: tt) => ( { } )
8080}
8181
82+ macro_rules! anon_attr_to_bool {
83+ ( anon) => ( true )
84+ }
85+
8286macro_rules! define_dep_nodes {
8387 ( <$tcx: tt>
8488 $(
89+ [ $( $anon: ident) * ]
8590 $variant: ident $( ( $( $tuple_arg: tt) ,* ) ) *
8691 $( { $( $struct_arg_name: ident : $struct_arg_ty: ty) ,* } ) *
8792 , ) *
@@ -117,6 +122,19 @@ macro_rules! define_dep_nodes {
117122 }
118123 }
119124
125+ #[ allow( unreachable_code) ]
126+ #[ inline]
127+ pub fn is_anon<$tcx>( & self ) -> bool {
128+ match * self {
129+ $(
130+ DepKind :: $variant => {
131+ $( return anon_attr_to_bool!( $anon) ; ) *
132+ false
133+ }
134+ ) *
135+ }
136+ }
137+
120138 #[ allow( unreachable_code) ]
121139 #[ inline]
122140 pub fn has_params( & self ) -> bool {
@@ -356,100 +374,101 @@ define_dep_nodes!( <'tcx>
356374 // suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
357375 // access to the krate, but you must remember to add suitable
358376 // edges yourself for the individual items that you read.
359- Krate ,
377+ [ ] Krate ,
360378
361379 // Represents the HIR node with the given node-id
362- Hir ( DefId ) ,
380+ [ ] Hir ( DefId ) ,
363381
364382 // Represents the body of a function or method. The def-id is that of the
365383 // function/method.
366- HirBody ( DefId ) ,
384+ [ ] HirBody ( DefId ) ,
367385
368386 // Represents the metadata for a given HIR node, typically found
369387 // in an extern crate.
370- MetaData ( DefId ) ,
388+ [ ] MetaData ( DefId ) ,
371389
372390 // Represents some artifact that we save to disk. Note that these
373391 // do not have a def-id as part of their identifier.
374- WorkProduct ( WorkProductId ) ,
392+ [ ] WorkProduct ( WorkProductId ) ,
375393
376394 // Represents different phases in the compiler.
377- RegionMaps ( DefId ) ,
378- Coherence ,
379- Resolve ,
380- CoherenceCheckTrait ( DefId ) ,
381- PrivacyAccessLevels ( CrateNum ) ,
395+ [ ] RegionMaps ( DefId ) ,
396+ [ ] Coherence ,
397+ [ ] Resolve ,
398+ [ ] CoherenceCheckTrait ( DefId ) ,
399+ [ ] PrivacyAccessLevels ( CrateNum ) ,
382400
383401 // Represents the MIR for a fn; also used as the task node for
384402 // things read/modify that MIR.
385- MirConstQualif ( DefId ) ,
386- MirConst ( DefId ) ,
387- MirValidated ( DefId ) ,
388- MirOptimized ( DefId ) ,
389- MirShim { instance_def: InstanceDef <' tcx> } ,
390-
391- BorrowCheckKrate ,
392- BorrowCheck ( DefId ) ,
393- RvalueCheck ( DefId ) ,
394- Reachability ,
395- MirKeys ,
396- TransWriteMetadata ,
397- CrateVariances ,
403+ [ ] MirConstQualif ( DefId ) ,
404+ [ ] MirConst ( DefId ) ,
405+ [ ] MirValidated ( DefId ) ,
406+ [ ] MirOptimized ( DefId ) ,
407+ [ ] MirShim { instance_def: InstanceDef <' tcx> } ,
408+
409+ [ ] BorrowCheckKrate ,
410+ [ ] BorrowCheck ( DefId ) ,
411+ [ ] RvalueCheck ( DefId ) ,
412+ [ ] Reachability ,
413+ [ ] MirKeys ,
414+ [ ] TransWriteMetadata ,
415+ [ ] CrateVariances ,
398416
399417 // Nodes representing bits of computed IR in the tcx. Each shared
400418 // table in the tcx (or elsewhere) maps to one of these
401419 // nodes.
402- AssociatedItems ( DefId ) ,
403- TypeOfItem ( DefId ) ,
404- GenericsOfItem ( DefId ) ,
405- PredicatesOfItem ( DefId ) ,
406- SuperPredicatesOfItem ( DefId ) ,
407- TraitDefOfItem ( DefId ) ,
408- AdtDefOfItem ( DefId ) ,
409- IsDefaultImpl ( DefId ) ,
410- ImplTraitRef ( DefId ) ,
411- ImplPolarity ( DefId ) ,
412- ClosureKind ( DefId ) ,
413- FnSignature ( DefId ) ,
414- CoerceUnsizedInfo ( DefId ) ,
415-
416- ItemVarianceConstraints ( DefId ) ,
417- ItemVariances ( DefId ) ,
418- IsConstFn ( DefId ) ,
419- IsForeignItem ( DefId ) ,
420- TypeParamPredicates { item_id: DefId , param_id: DefId } ,
421- SizedConstraint ( DefId ) ,
422- DtorckConstraint ( DefId ) ,
423- AdtDestructor ( DefId ) ,
424- AssociatedItemDefIds ( DefId ) ,
425- InherentImpls ( DefId ) ,
426- TypeckBodiesKrate ,
427- TypeckTables ( DefId ) ,
428- HasTypeckTables ( DefId ) ,
429- ConstEval { def_id: DefId , substs: & ' tcx Substs <' tcx> } ,
430- SymbolName ( DefId ) ,
431- InstanceSymbolName { instance: Instance <' tcx> } ,
432- SpecializationGraph ( DefId ) ,
433- ObjectSafety ( DefId ) ,
434- IsCopy ( DefId ) ,
435- IsSized ( DefId ) ,
436- IsFreeze ( DefId ) ,
437- NeedsDrop ( DefId ) ,
438- Layout ( DefId ) ,
420+ [ ] AssociatedItems ( DefId ) ,
421+ [ ] TypeOfItem ( DefId ) ,
422+ [ ] GenericsOfItem ( DefId ) ,
423+ [ ] PredicatesOfItem ( DefId ) ,
424+ [ ] SuperPredicatesOfItem ( DefId ) ,
425+ [ ] TraitDefOfItem ( DefId ) ,
426+ [ ] AdtDefOfItem ( DefId ) ,
427+ [ ] IsDefaultImpl ( DefId ) ,
428+ [ ] ImplTraitRef ( DefId ) ,
429+ [ ] ImplPolarity ( DefId ) ,
430+ [ ] ClosureKind ( DefId ) ,
431+ [ ] FnSignature ( DefId ) ,
432+ [ ] CoerceUnsizedInfo ( DefId ) ,
433+
434+ [ ] ItemVarianceConstraints ( DefId ) ,
435+ [ ] ItemVariances ( DefId ) ,
436+ [ ] IsConstFn ( DefId ) ,
437+ [ ] IsForeignItem ( DefId ) ,
438+ [ ] TypeParamPredicates { item_id: DefId , param_id: DefId } ,
439+ [ ] SizedConstraint ( DefId ) ,
440+ [ ] DtorckConstraint ( DefId ) ,
441+ [ ] AdtDestructor ( DefId ) ,
442+ [ ] AssociatedItemDefIds ( DefId ) ,
443+ [ ] InherentImpls ( DefId ) ,
444+ [ ] TypeckBodiesKrate ,
445+ [ ] TypeckTables ( DefId ) ,
446+ [ ] HasTypeckTables ( DefId ) ,
447+ [ ] ConstEval { def_id: DefId , substs: & ' tcx Substs <' tcx> } ,
448+ [ ] SymbolName ( DefId ) ,
449+ [ ] InstanceSymbolName { instance: Instance <' tcx> } ,
450+ [ ] SpecializationGraph ( DefId ) ,
451+ [ ] ObjectSafety ( DefId ) ,
452+
453+ [ anon] IsCopy ( DefId ) ,
454+ [ anon] IsSized ( DefId ) ,
455+ [ anon] IsFreeze ( DefId ) ,
456+ [ anon] NeedsDrop ( DefId ) ,
457+ [ anon] Layout ( DefId ) ,
439458
440459 // The set of impls for a given trait.
441- TraitImpls ( DefId ) ,
442- RelevantTraitImpls ( DefId , SimplifiedType ) ,
460+ [ ] TraitImpls ( DefId ) ,
461+ [ ] RelevantTraitImpls ( DefId , SimplifiedType ) ,
443462
444- AllLocalTraitImpls ,
463+ [ ] AllLocalTraitImpls ,
445464
446465 // Nodes representing caches. To properly handle a true cache, we
447466 // don't use a DepTrackingMap, but rather we push a task node.
448467 // Otherwise the write into the map would be incorrectly
449468 // attributed to the first task that happened to fill the cache,
450469 // which would yield an overly conservative dep-graph.
451- TraitItems ( DefId ) ,
452- ReprHints ( DefId ) ,
470+ [ ] TraitItems ( DefId ) ,
471+ [ ] ReprHints ( DefId ) ,
453472
454473 // Trait selection cache is a little funny. Given a trait
455474 // reference like `Foo: SomeTrait<Bar>`, there could be
@@ -476,35 +495,45 @@ define_dep_nodes!( <'tcx>
476495 // imprecision in our dep-graph tracking. The important thing is
477496 // that for any given trait-ref, we always map to the **same**
478497 // trait-select node.
479- TraitSelect { trait_def_id: DefId , input_def_id: DefId } ,
498+ [ ] TraitSelect { trait_def_id: DefId , input_def_id: DefId } ,
480499
481500 // For proj. cache, we just keep a list of all def-ids, since it is
482501 // not a hotspot.
483- ProjectionCache { def_ids: DefIdList } ,
484-
485- ParamEnv ( DefId ) ,
486- DescribeDef ( DefId ) ,
487- DefSpan ( DefId ) ,
488- Stability ( DefId ) ,
489- Deprecation ( DefId ) ,
490- ItemBodyNestedBodies ( DefId ) ,
491- ConstIsRvaluePromotableToStatic ( DefId ) ,
492- ImplParent ( DefId ) ,
493- TraitOfItem ( DefId ) ,
494- IsExportedSymbol ( DefId ) ,
495- IsMirAvailable ( DefId ) ,
496- ItemAttrs ( DefId ) ,
497- FnArgNames ( DefId ) ,
498- DylibDepFormats ( DefId ) ,
499- IsAllocator ( DefId ) ,
500- IsPanicRuntime ( DefId ) ,
501- ExternCrate ( DefId ) ,
502+ [ ] ProjectionCache { def_ids: DefIdList } ,
503+
504+ [ ] ParamEnv ( DefId ) ,
505+ [ ] DescribeDef ( DefId ) ,
506+ [ ] DefSpan ( DefId ) ,
507+ [ ] Stability ( DefId ) ,
508+ [ ] Deprecation ( DefId ) ,
509+ [ ] ItemBodyNestedBodies ( DefId ) ,
510+ [ ] ConstIsRvaluePromotableToStatic ( DefId ) ,
511+ [ ] ImplParent ( DefId ) ,
512+ [ ] TraitOfItem ( DefId ) ,
513+ [ ] IsExportedSymbol ( DefId ) ,
514+ [ ] IsMirAvailable ( DefId ) ,
515+ [ ] ItemAttrs ( DefId ) ,
516+ [ ] FnArgNames ( DefId ) ,
517+ [ ] DylibDepFormats ( DefId ) ,
518+ [ ] IsAllocator ( DefId ) ,
519+ [ ] IsPanicRuntime ( DefId ) ,
520+ [ ] ExternCrate ( DefId ) ,
502521) ;
503522
504- trait DepNodeParams < ' a , ' gcx : ' tcx + ' a , ' tcx : ' a > {
523+ trait DepNodeParams < ' a , ' gcx : ' tcx + ' a , ' tcx : ' a > : fmt :: Debug {
505524 const CAN_RECONSTRUCT_QUERY_KEY : bool ;
506- fn to_fingerprint ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Fingerprint ;
507- fn to_debug_str ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> String ;
525+
526+ /// This method turns the parameters of a DepNodeConstructor into an opaque
527+ /// Fingerprint to be used in DepNode.
528+ /// Not all DepNodeParams support being turned into a Fingerprint (they
529+ /// don't need to if the corresponding DepNode is anonymous).
530+ fn to_fingerprint ( & self , _: TyCtxt < ' a , ' gcx , ' tcx > ) -> Fingerprint {
531+ panic ! ( "Not implemented. Accidentally called on anonymous node?" )
532+ }
533+
534+ fn to_debug_str ( & self , _: TyCtxt < ' a , ' gcx , ' tcx > ) -> String {
535+ format ! ( "{:?}" , self )
536+ }
508537}
509538
510539impl < ' a , ' gcx : ' tcx + ' a , ' tcx : ' a , T > DepNodeParams < ' a , ' gcx , ' tcx > for T
0 commit comments