22//! generate the actual methods on tcx which find and execute the provider,
33//! manage the caches, and so forth.
44
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 } ;
77use crate :: ty:: tls:: { self , ImplicitCtxt } ;
88use crate :: ty:: { self , TyCtxt } ;
99use rustc_query_system:: dep_graph:: HasDepContext ;
@@ -13,7 +13,7 @@ use rustc_query_system::query::{QueryContext, QueryDescription};
1313use rustc_data_structures:: fx:: FxHashMap ;
1414use rustc_data_structures:: sync:: Lock ;
1515use 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 } ;
1717use rustc_serialize:: opaque;
1818use rustc_span:: def_id:: { DefId , LocalDefId } ;
1919use rustc_span:: Span ;
@@ -266,49 +266,6 @@ impl<'tcx> QueryCtxt<'tcx> {
266266 }
267267}
268268
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-
312269/// This struct stores metadata about each Query.
313270///
314271/// Information is retrieved by indexing the `QUERIES` array using the integer value
@@ -689,14 +646,16 @@ macro_rules! define_queries_struct {
689646
690647 Some ( jobs)
691648 }
649+ }
692650
651+ impl QueryEngine <' tcx> for Queries <' tcx> {
693652 #[ 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 ) {
695654 let tcx = QueryCtxt { tcx, queries: self } ;
696655 rustc_query_system:: query:: deadlock( tcx, registry)
697656 }
698657
699- pub ( crate ) fn encode_query_results(
658+ fn encode_query_results(
700659 & ' tcx self ,
701660 tcx: TyCtxt <' tcx>,
702661 encoder: & mut on_disk_cache:: CacheEncoder <' a, ' tcx, opaque:: FileEncoder >,
@@ -711,6 +670,52 @@ macro_rules! define_queries_struct {
711670 tcx. dep_graph. exec_cache_promotions( tcx)
712671 }
713672
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+
714719 $( $( #[ $attr] ) *
715720 #[ inline( always) ]
716721 fn $name(
0 commit comments