@@ -153,8 +153,14 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
153
153
} ;
154
154
mem:: drop ( lock) ;
155
155
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
+ }
158
164
}
159
165
}
160
166
}
@@ -245,8 +251,10 @@ pub(super) enum TryGetJob<'a, 'tcx: 'a, D: QueryDescription<'tcx> + 'a> {
245
251
}
246
252
247
253
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
254
+ #[ inline( never) ]
255
+ #[ cold]
248
256
pub ( super ) fn report_cycle ( self , CycleError { usage, cycle : stack } : CycleError < ' gcx > )
249
- -> DiagnosticBuilder < ' a >
257
+ -> Box < DiagnosticBuilder < ' a > >
250
258
{
251
259
assert ! ( !stack. is_empty( ) ) ;
252
260
@@ -280,7 +288,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
280
288
& format ! ( "cycle used when {}" , query. describe( self ) ) ) ;
281
289
}
282
290
283
- return err
291
+ return Box :: new ( err)
284
292
} )
285
293
}
286
294
@@ -345,6 +353,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
345
353
}
346
354
}
347
355
356
+ #[ inline( never) ]
348
357
fn try_get_with < Q : QueryDescription < ' gcx > > (
349
358
self ,
350
359
span : Span ,
@@ -409,7 +418,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
409
418
return Ok ( result) ;
410
419
}
411
420
412
- if !dep_node. kind . is_input ( ) {
421
+ if !dep_node. kind . is_input_inlined ( ) {
413
422
if let Some ( dep_node_index) = self . try_mark_green_and_read ( & dep_node) {
414
423
profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
415
424
self . sess . profiler ( |p| p. record_query_hit ( Q :: CATEGORY ) ) ;
@@ -585,7 +594,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
585
594
586
595
// Ensuring an "input" or anonymous query makes no sense
587
596
assert ! ( !dep_node. kind. is_anon( ) ) ;
588
- assert ! ( !dep_node. kind. is_input ( ) ) ;
597
+ assert ! ( !dep_node. kind. is_input_inlined ( ) ) ;
589
598
if self . try_mark_green_and_read ( & dep_node) . is_none ( ) {
590
599
// A None return from `try_mark_green_and_read` means that this is either
591
600
// 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> {
625
634
self ,
626
635
span : Span ,
627
636
key : Q :: Key ,
628
- ) -> Result < Q :: Value , DiagnosticBuilder < ' a > > {
637
+ ) -> Result < Q :: Value , Box < DiagnosticBuilder < ' a > > > {
629
638
match self . try_get_with :: < Q > ( span, key) {
630
639
Ok ( e) => Ok ( e) ,
631
640
Err ( e) => Err ( self . report_cycle ( e) ) ,
@@ -637,11 +646,20 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
637
646
span : Span ,
638
647
key : Q :: Key ,
639
648
) -> 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)
643
651
} )
644
652
}
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
+ }
645
663
}
646
664
647
665
macro_rules! handle_cycle_error {
@@ -861,6 +879,7 @@ macro_rules! define_queries_inner {
861
879
862
880
impl <' a, ' gcx, ' tcx> Deref for TyCtxtAt <' a, ' gcx, ' tcx> {
863
881
type Target = TyCtxt <' a, ' gcx, ' tcx>;
882
+ #[ inline( always) ]
864
883
fn deref( & self ) -> & Self :: Target {
865
884
& self . tcx
866
885
}
@@ -869,6 +888,7 @@ macro_rules! define_queries_inner {
869
888
impl <' a, $tcx, ' lcx> TyCtxt <' a, $tcx, ' lcx> {
870
889
/// Return a transparent wrapper for `TyCtxt` which uses
871
890
/// `span` as the location of queries performed through it.
891
+ #[ inline( always) ]
872
892
pub fn at( self , span: Span ) -> TyCtxtAt <' a, $tcx, ' lcx> {
873
893
TyCtxtAt {
874
894
tcx: self ,
@@ -877,13 +897,15 @@ macro_rules! define_queries_inner {
877
897
}
878
898
879
899
$( $( #[ $attr] ) *
900
+ #[ inline( always) ]
880
901
pub fn $name( self , key: $K) -> $V {
881
902
self . at( DUMMY_SP ) . $name( key)
882
903
} ) *
883
904
}
884
905
885
906
impl <' a, $tcx, ' lcx> TyCtxtAt <' a, $tcx, ' lcx> {
886
907
$( $( #[ $attr] ) *
908
+ #[ inline( always) ]
887
909
pub fn $name( self , key: $K) -> $V {
888
910
self . tcx. get_query:: <queries:: $name<' _>>( self . span, key)
889
911
} ) *
0 commit comments