2
2
//! generate the actual methods on tcx which find and execute the provider,
3
3
//! manage the caches, and so forth.
4
4
5
- use crate :: dep_graph:: { self , DepKind , DepNode , DepNodeExt , DepNodeIndex , SerializedDepNodeIndex } ;
6
- use crate :: ty:: query:: { on_disk_cache, queries, Queries , Query } ;
5
+ use crate :: dep_graph:: { DepKind , DepNode , DepNodeExt , DepNodeIndex , SerializedDepNodeIndex } ;
6
+ use crate :: ty:: query:: { on_disk_cache, queries, Query } ;
7
7
use crate :: ty:: tls:: { self , ImplicitCtxt } ;
8
8
use crate :: ty:: { self , TyCtxt } ;
9
9
use rustc_query_system:: dep_graph:: HasDepContext ;
@@ -13,7 +13,7 @@ use rustc_query_system::query::{QueryContext, QueryDescription};
13
13
use rustc_data_structures:: fx:: FxHashMap ;
14
14
use rustc_data_structures:: sync:: Lock ;
15
15
use rustc_data_structures:: thin_vec:: ThinVec ;
16
- use rustc_errors:: { struct_span_err, Diagnostic , DiagnosticBuilder , Handler , Level } ;
16
+ use rustc_errors:: { struct_span_err, Diagnostic , DiagnosticBuilder } ;
17
17
use rustc_serialize:: opaque;
18
18
use rustc_span:: def_id:: { DefId , LocalDefId } ;
19
19
use rustc_span:: Span ;
@@ -266,49 +266,6 @@ impl<'tcx> QueryCtxt<'tcx> {
266
266
}
267
267
}
268
268
269
- impl < ' tcx > Queries < ' tcx > {
270
- pub fn try_print_query_stack (
271
- & ' tcx self ,
272
- tcx : TyCtxt < ' tcx > ,
273
- query : Option < QueryJobId < dep_graph:: DepKind > > ,
274
- handler : & Handler ,
275
- num_frames : Option < usize > ,
276
- ) -> usize {
277
- let query_map = self . try_collect_active_jobs ( ) ;
278
-
279
- let mut current_query = query;
280
- let mut i = 0 ;
281
-
282
- while let Some ( query) = current_query {
283
- if Some ( i) == num_frames {
284
- break ;
285
- }
286
- let query_info = if let Some ( info) = query_map. as_ref ( ) . and_then ( |map| map. get ( & query) )
287
- {
288
- info
289
- } else {
290
- break ;
291
- } ;
292
- let mut diag = Diagnostic :: new (
293
- Level :: FailureNote ,
294
- & format ! (
295
- "#{} [{}] {}" ,
296
- i,
297
- query_info. info. query. name( ) ,
298
- query_info. info. query. describe( QueryCtxt { tcx, queries: self } )
299
- ) ,
300
- ) ;
301
- diag. span = tcx. sess . source_map ( ) . guess_head_span ( query_info. info . span ) . into ( ) ;
302
- handler. force_print_diagnostic ( diag) ;
303
-
304
- current_query = query_info. job . parent ;
305
- i += 1 ;
306
- }
307
-
308
- i
309
- }
310
- }
311
-
312
269
/// This struct stores metadata about each Query.
313
270
///
314
271
/// Information is retrieved by indexing the `QUERIES` array using the integer value
@@ -689,14 +646,16 @@ macro_rules! define_queries_struct {
689
646
690
647
Some ( jobs)
691
648
}
649
+ }
692
650
651
+ impl QueryEngine <' tcx> for Queries <' tcx> {
693
652
#[ cfg( parallel_compiler) ]
694
- pub unsafe fn deadlock( & ' tcx self , tcx: TyCtxt <' tcx>, registry: & rustc_rayon_core:: Registry ) {
653
+ unsafe fn deadlock( & ' tcx self , tcx: TyCtxt <' tcx>, registry: & rustc_rayon_core:: Registry ) {
695
654
let tcx = QueryCtxt { tcx, queries: self } ;
696
655
rustc_query_system:: query:: deadlock( tcx, registry)
697
656
}
698
657
699
- pub ( crate ) fn encode_query_results(
658
+ fn encode_query_results(
700
659
& ' tcx self ,
701
660
tcx: TyCtxt <' tcx>,
702
661
encoder: & mut on_disk_cache:: CacheEncoder <' a, ' tcx, opaque:: FileEncoder >,
@@ -711,6 +670,52 @@ macro_rules! define_queries_struct {
711
670
tcx. dep_graph. exec_cache_promotions( tcx)
712
671
}
713
672
673
+ fn try_mark_green( & ' tcx self , tcx: TyCtxt <' tcx>, dep_node: & dep_graph:: DepNode ) -> bool {
674
+ let qcx = QueryCtxt { tcx, queries: self } ;
675
+ tcx. dep_graph. try_mark_green( qcx, dep_node) . is_some( )
676
+ }
677
+
678
+ fn try_print_query_stack(
679
+ & ' tcx self ,
680
+ tcx: TyCtxt <' tcx>,
681
+ query: Option <QueryJobId <dep_graph:: DepKind >>,
682
+ handler: & Handler ,
683
+ num_frames: Option <usize >,
684
+ ) -> usize {
685
+ let query_map = self . try_collect_active_jobs( ) ;
686
+
687
+ let mut current_query = query;
688
+ let mut i = 0 ;
689
+
690
+ while let Some ( query) = current_query {
691
+ if Some ( i) == num_frames {
692
+ break ;
693
+ }
694
+ let query_info = if let Some ( info) = query_map. as_ref( ) . and_then( |map| map. get( & query) )
695
+ {
696
+ info
697
+ } else {
698
+ break ;
699
+ } ;
700
+ let mut diag = Diagnostic :: new(
701
+ Level :: FailureNote ,
702
+ & format!(
703
+ "#{} [{}] {}" ,
704
+ i,
705
+ query_info. info. query. name( ) ,
706
+ query_info. info. query. describe( QueryCtxt { tcx, queries: self } )
707
+ ) ,
708
+ ) ;
709
+ diag. span = tcx. sess. source_map( ) . guess_head_span( query_info. info. span) . into( ) ;
710
+ handler. force_print_diagnostic( diag) ;
711
+
712
+ current_query = query_info. job. parent;
713
+ i += 1 ;
714
+ }
715
+
716
+ i
717
+ }
718
+
714
719
$( $( #[ $attr] ) *
715
720
#[ inline( always) ]
716
721
fn $name(
0 commit comments