@@ -153,8 +153,14 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
153153 } ;
154154 mem:: drop ( lock) ;
155155
156- if let Err ( cycle) = job. await ( tcx, span) {
157- return TryGetJob :: JobCompleted ( Err ( cycle) ) ;
156+ #[ cfg( not( parallel_queries) ) ]
157+ return job. await ( tcx, span) ;
158+
159+ #[ cfg( parallel_queries) ]
160+ {
161+ if let Err ( cycle) = job. await ( tcx, span) {
162+ return TryGetJob :: JobCompleted ( Err ( cycle) ) ;
163+ }
158164 }
159165 }
160166 }
@@ -245,8 +251,10 @@ pub(super) enum TryGetJob<'a, 'tcx: 'a, D: QueryDescription<'tcx> + 'a> {
245251}
246252
247253impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
254+ #[ inline( never) ]
255+ #[ cold]
248256 pub ( super ) fn report_cycle ( self , CycleError { usage, cycle : stack } : CycleError < ' gcx > )
249- -> DiagnosticBuilder < ' a >
257+ -> Box < DiagnosticBuilder < ' a > >
250258 {
251259 assert ! ( !stack. is_empty( ) ) ;
252260
@@ -280,7 +288,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
280288 & format ! ( "cycle used when {}" , query. describe( self ) ) ) ;
281289 }
282290
283- return err
291+ return Box :: new ( err)
284292 } )
285293 }
286294
@@ -345,6 +353,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
345353 }
346354 }
347355
356+ #[ inline( never) ]
348357 fn try_get_with < Q : QueryDescription < ' gcx > > (
349358 self ,
350359 span : Span ,
@@ -409,7 +418,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
409418 return Ok ( result) ;
410419 }
411420
412- if !dep_node. kind . is_input ( ) {
421+ if !dep_node. kind . is_input_inlined ( ) {
413422 if let Some ( dep_node_index) = self . try_mark_green_and_read ( & dep_node) {
414423 profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
415424 self . sess . profiler ( |p| p. record_query_hit ( Q :: CATEGORY ) ) ;
@@ -585,7 +594,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
585594
586595 // Ensuring an "input" or anonymous query makes no sense
587596 assert ! ( !dep_node. kind. is_anon( ) ) ;
588- assert ! ( !dep_node. kind. is_input ( ) ) ;
597+ assert ! ( !dep_node. kind. is_input_inlined ( ) ) ;
589598 if self . try_mark_green_and_read ( & dep_node) . is_none ( ) {
590599 // A None return from `try_mark_green_and_read` means that this is either
591600 // a new dep node or that the dep node has already been marked red.
@@ -625,7 +634,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
625634 self ,
626635 span : Span ,
627636 key : Q :: Key ,
628- ) -> Result < Q :: Value , DiagnosticBuilder < ' a > > {
637+ ) -> Result < Q :: Value , Box < DiagnosticBuilder < ' a > > > {
629638 match self . try_get_with :: < Q > ( span, key) {
630639 Ok ( e) => Ok ( e) ,
631640 Err ( e) => Err ( self . report_cycle ( e) ) ,
@@ -637,11 +646,20 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
637646 span : Span ,
638647 key : Q :: Key ,
639648 ) -> Q :: Value {
640- self . try_get_query :: < Q > ( span, key) . unwrap_or_else ( |mut e| {
641- e. emit ( ) ;
642- Q :: handle_cycle_error ( self )
649+ self . try_get_query :: < Q > ( span, key) . unwrap_or_else ( |e| {
650+ self . emit_error :: < Q > ( e)
643651 } )
644652 }
653+
654+ #[ inline( never) ]
655+ #[ cold]
656+ fn emit_error < Q : QueryDescription < ' gcx > > (
657+ self ,
658+ mut e : Box < DiagnosticBuilder < ' a > > ,
659+ ) -> Q :: Value {
660+ e. emit ( ) ;
661+ Q :: handle_cycle_error ( self )
662+ }
645663}
646664
647665macro_rules! handle_cycle_error {
@@ -861,6 +879,7 @@ macro_rules! define_queries_inner {
861879
862880 impl <' a, ' gcx, ' tcx> Deref for TyCtxtAt <' a, ' gcx, ' tcx> {
863881 type Target = TyCtxt <' a, ' gcx, ' tcx>;
882+ #[ inline( always) ]
864883 fn deref( & self ) -> & Self :: Target {
865884 & self . tcx
866885 }
@@ -869,6 +888,7 @@ macro_rules! define_queries_inner {
869888 impl <' a, $tcx, ' lcx> TyCtxt <' a, $tcx, ' lcx> {
870889 /// Return a transparent wrapper for `TyCtxt` which uses
871890 /// `span` as the location of queries performed through it.
891+ #[ inline( always) ]
872892 pub fn at( self , span: Span ) -> TyCtxtAt <' a, $tcx, ' lcx> {
873893 TyCtxtAt {
874894 tcx: self ,
@@ -877,13 +897,15 @@ macro_rules! define_queries_inner {
877897 }
878898
879899 $( $( #[ $attr] ) *
900+ #[ inline( always) ]
880901 pub fn $name( self , key: $K) -> $V {
881902 self . at( DUMMY_SP ) . $name( key)
882903 } ) *
883904 }
884905
885906 impl <' a, $tcx, ' lcx> TyCtxtAt <' a, $tcx, ' lcx> {
886907 $( $( #[ $attr] ) *
908+ #[ inline( always) ]
887909 pub fn $name( self , key: $K) -> $V {
888910 self . tcx. get_query:: <queries:: $name<' _>>( self . span, key)
889911 } ) *
0 commit comments