@@ -376,15 +376,13 @@ impl<'tcx> TyCtxt<'tcx> {
376376            return  self . force_query_with_job :: < Q > ( key,  job,  null_dep_node) . 0 ; 
377377        } 
378378
379-         let  dep_node = Q :: to_dep_node ( self ,  & key) ; 
380- 
381-         if  dep_node. kind . is_anon ( )  { 
379+         if  Q :: ANON  { 
382380            profq_msg ! ( self ,  ProfileQueriesMsg :: ProviderBegin ) ; 
383381            self . sess . profiler ( |p| p. start_query ( Q :: NAME ) ) ; 
384382
385383            let  ( ( result,  dep_node_index) ,  diagnostics)  = with_diagnostics ( |diagnostics| { 
386384                self . start_query ( job. job . clone ( ) ,  diagnostics,  |tcx| { 
387-                     tcx. dep_graph . with_anon_task ( dep_node . kind ,  || { 
385+                     tcx. dep_graph . with_anon_task ( Q :: dep_kind ( ) ,  || { 
388386                        Q :: compute ( tcx. global_tcx ( ) ,  key) 
389387                    } ) 
390388                } ) 
@@ -405,7 +403,9 @@ impl<'tcx> TyCtxt<'tcx> {
405403            return  result; 
406404        } 
407405
408-         if  !dep_node. kind . is_eval_always ( )  { 
406+         let  dep_node = Q :: to_dep_node ( self ,  & key) ; 
407+ 
408+         if  !Q :: EVAL_ALWAYS  { 
409409            // The diagnostics for this query will be 
410410            // promoted to the current session during 
411411            // try_mark_green(), so we can ignore them here. 
@@ -546,7 +546,7 @@ impl<'tcx> TyCtxt<'tcx> {
546546
547547        let  ( ( result,  dep_node_index) ,  diagnostics)  = with_diagnostics ( |diagnostics| { 
548548            self . start_query ( job. job . clone ( ) ,  diagnostics,  |tcx| { 
549-                 if  dep_node . kind . is_eval_always ( )  { 
549+                 if  Q :: EVAL_ALWAYS  { 
550550                    tcx. dep_graph . with_eval_always_task ( dep_node, 
551551                                                        tcx, 
552552                                                        key, 
@@ -569,8 +569,8 @@ impl<'tcx> TyCtxt<'tcx> {
569569            self . dep_graph . mark_loaded_from_cache ( dep_node_index,  false ) ; 
570570        } 
571571
572-         if  dep_node . kind  !=  crate :: dep_graph :: DepKind :: Null  { 
573-             if  unlikely ! ( !diagnostics . is_empty ( ) )  { 
572+         if  unlikely ! ( !diagnostics . is_empty ( ) )  { 
573+             if  dep_node . kind  !=  crate :: dep_graph :: DepKind :: Null  { 
574574                self . queries . on_disk_cache 
575575                    . store_diagnostics ( dep_node_index,  diagnostics) ; 
576576            } 
@@ -589,15 +589,16 @@ impl<'tcx> TyCtxt<'tcx> {
589589/// 
590590/// Note: The optimization is only available during incr. comp. 
591591pub ( super )  fn  ensure_query < Q :  QueryDescription < ' tcx > > ( self ,  key :  Q :: Key )  -> ( )  { 
592-         let  dep_node = Q :: to_dep_node ( self ,  & key) ; 
593- 
594-         if  dep_node. kind . is_eval_always ( )  { 
592+         if  Q :: EVAL_ALWAYS  { 
595593            let  _ = self . get_query :: < Q > ( DUMMY_SP ,  key) ; 
596594            return ; 
597595        } 
598596
599597        // Ensuring an anonymous query makes no sense 
600-         assert ! ( !dep_node. kind. is_anon( ) ) ; 
598+         assert ! ( !Q :: ANON ) ; 
599+ 
600+         let  dep_node = Q :: to_dep_node ( self ,  & key) ; 
601+ 
601602        if  self . dep_graph . try_mark_green_and_read ( self ,  & dep_node) . is_none ( )  { 
602603            // A None return from `try_mark_green_and_read` means that this is either 
603604            // a new dep node or that the dep node has already been marked red. 
@@ -653,6 +654,30 @@ macro_rules! handle_cycle_error {
653654    } ; 
654655} 
655656
657+ macro_rules!  is_anon { 
658+     ( [ ] )  => { { 
659+         false 
660+     } } ; 
661+     ( [ anon$( ,  $modifiers: ident) * ] )  => { { 
662+         true 
663+     } } ; 
664+     ( [ $other: ident$( ,  $modifiers: ident) * ] )  => { 
665+         is_anon!( [ $( $modifiers) ,* ] ) 
666+     } ; 
667+ } 
668+ 
669+ macro_rules!  is_eval_always { 
670+     ( [ ] )  => { { 
671+         false 
672+     } } ; 
673+     ( [ eval_always$( ,  $modifiers: ident) * ] )  => { { 
674+         true 
675+     } } ; 
676+     ( [ $other: ident$( ,  $modifiers: ident) * ] )  => { 
677+         is_eval_always!( [ $( $modifiers) ,* ] ) 
678+     } ; 
679+ } 
680+ 
656681macro_rules!  hash_result { 
657682    ( [ ] [ $hcx: expr,  $result: expr] )  => { { 
658683        dep_graph:: hash_result( $hcx,  & $result) 
@@ -933,6 +958,9 @@ macro_rules! define_queries_inner {
933958        } 
934959
935960        impl <$tcx> QueryAccessors <$tcx> for  queries:: $name<$tcx> { 
961+             const  ANON :  bool  = is_anon!( [ $( $modifiers) * ] ) ; 
962+             const  EVAL_ALWAYS :  bool  = is_eval_always!( [ $( $modifiers) * ] ) ; 
963+ 
936964            #[ inline( always) ] 
937965            fn  query( key:  Self :: Key )  -> Query <' tcx> { 
938966                Query :: $name( key) 
@@ -951,6 +979,11 @@ macro_rules! define_queries_inner {
951979                DepNode :: new( tcx,  $node( * key) ) 
952980            } 
953981
982+             #[ inline( always) ] 
983+             fn  dep_kind( )  -> dep_graph:: DepKind  { 
984+                 dep_graph:: DepKind :: $node
985+             } 
986+ 
954987            #[ inline] 
955988            fn  compute( tcx:  TyCtxt <' tcx>,  key:  Self :: Key )  -> Self :: Value  { 
956989                __query_compute:: $name( move || { 
0 commit comments