@@ -6,7 +6,6 @@ use std::num::NonZero;
66
77use rustc_data_structures:: jobserver:: Proxy ;
88use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
9- use rustc_data_structures:: sync:: { DynSend , DynSync } ;
109use rustc_data_structures:: unord:: UnordMap ;
1110use rustc_hashes:: Hash64 ;
1211use rustc_hir:: limit:: Limit ;
@@ -27,8 +26,8 @@ use rustc_middle::ty::{self, TyCtxt};
2726use rustc_query_system:: dep_graph:: { DepNodeParams , HasDepContext } ;
2827use rustc_query_system:: ich:: StableHashingContext ;
2928use rustc_query_system:: query:: {
30- QueryCache , QueryConfig , QueryContext , QueryJobId , QueryMap , QuerySideEffect ,
31- QueryStackDeferred , QueryStackFrame , QueryStackFrameExtra , force_query,
29+ QueryCache , QueryConfig , QueryContext , QueryJobId , QueryMap , QuerySideEffect , QueryStackFrame ,
30+ force_query,
3231} ;
3332use rustc_query_system:: { QueryOverflow , QueryOverflowNote } ;
3433use rustc_serialize:: { Decodable , Encodable } ;
@@ -67,9 +66,7 @@ impl<'tcx> HasDepContext for QueryCtxt<'tcx> {
6766 }
6867}
6968
70- impl < ' tcx > QueryContext for QueryCtxt < ' tcx > {
71- type QueryInfo = QueryStackDeferred < ' tcx > ;
72-
69+ impl QueryContext for QueryCtxt < ' _ > {
7370 #[ inline]
7471 fn jobserver_proxy ( & self ) -> & Proxy {
7572 & * self . jobserver_proxy
@@ -98,10 +95,7 @@ impl<'tcx> QueryContext for QueryCtxt<'tcx> {
9895 /// Prefer passing `false` to `require_complete` to avoid potential deadlocks,
9996 /// especially when called from within a deadlock handler, unless a
10097 /// complete map is needed and no deadlock is possible at this call site.
101- fn collect_active_jobs (
102- self ,
103- require_complete : bool ,
104- ) -> Result < QueryMap < QueryStackDeferred < ' tcx > > , QueryMap < QueryStackDeferred < ' tcx > > > {
98+ fn collect_active_jobs ( self , require_complete : bool ) -> Result < QueryMap , QueryMap > {
10599 let mut jobs = QueryMap :: default ( ) ;
106100 let mut complete = true ;
107101
@@ -114,13 +108,6 @@ impl<'tcx> QueryContext for QueryCtxt<'tcx> {
114108 if complete { Ok ( jobs) } else { Err ( jobs) }
115109 }
116110
117- fn lift_query_info (
118- self ,
119- info : & QueryStackDeferred < ' tcx > ,
120- ) -> rustc_query_system:: query:: QueryStackFrameExtra {
121- info. extract ( )
122- }
123-
124111 // Interactions with on_disk_cache
125112 fn load_side_effect (
126113 self ,
@@ -181,10 +168,7 @@ impl<'tcx> QueryContext for QueryCtxt<'tcx> {
181168
182169 self . sess . dcx ( ) . emit_fatal ( QueryOverflow {
183170 span : info. job . span ,
184- note : QueryOverflowNote {
185- desc : self . lift_query_info ( & info. query . info ) . description ,
186- depth,
187- } ,
171+ note : QueryOverflowNote { desc : info. query . description , depth } ,
188172 suggested_limit,
189173 crate_name : self . crate_name ( LOCAL_CRATE ) ,
190174 } ) ;
@@ -321,17 +305,16 @@ macro_rules! should_ever_cache_on_disk {
321305 } ;
322306}
323307
324- fn create_query_frame_extra < ' tcx , K : Key + Copy + ' tcx > (
325- ( tcx, key, kind, name, do_describe) : (
326- TyCtxt < ' tcx > ,
327- K ,
328- DepKind ,
329- & ' static str ,
330- fn ( TyCtxt < ' tcx > , K ) -> String ,
331- ) ,
332- ) -> QueryStackFrameExtra {
333- let def_id = key. key_as_def_id ( ) ;
334-
308+ pub ( crate ) fn create_query_frame <
309+ ' tcx ,
310+ K : Copy + Key + for < ' a > HashStable < StableHashingContext < ' a > > ,
311+ > (
312+ tcx : TyCtxt < ' tcx > ,
313+ do_describe : fn ( TyCtxt < ' tcx > , K ) -> String ,
314+ key : K ,
315+ kind : DepKind ,
316+ name : & ' static str ,
317+ ) -> QueryStackFrame {
335318 // If reduced queries are requested, we may be printing a query stack due
336319 // to a panic. Avoid using `default_span` and `def_kind` in that case.
337320 let reduce_queries = with_reduced_queries ( ) ;
@@ -343,6 +326,7 @@ fn create_query_frame_extra<'tcx, K: Key + Copy + 'tcx>(
343326 } else {
344327 description
345328 } ;
329+
346330 let span = if kind == dep_graph:: dep_kinds:: def_span || reduce_queries {
347331 // The `def_span` query is used to calculate `default_span`,
348332 // so exit to avoid infinite recursion.
@@ -351,41 +335,25 @@ fn create_query_frame_extra<'tcx, K: Key + Copy + 'tcx>(
351335 Some ( key. default_span ( tcx) )
352336 } ;
353337
338+ let def_id = key. key_as_def_id ( ) ;
339+
354340 let def_kind = if kind == dep_graph:: dep_kinds:: def_kind || reduce_queries {
355341 // Try to avoid infinite recursion.
356342 None
357343 } else {
358344 def_id. and_then ( |def_id| def_id. as_local ( ) ) . map ( |def_id| tcx. def_kind ( def_id) )
359345 } ;
360- QueryStackFrameExtra :: new ( description, span, def_kind)
361- }
362-
363- pub ( crate ) fn create_query_frame <
364- ' tcx ,
365- K : Copy + DynSend + DynSync + Key + for < ' a > HashStable < StableHashingContext < ' a > > + ' tcx ,
366- > (
367- tcx : TyCtxt < ' tcx > ,
368- do_describe : fn ( TyCtxt < ' tcx > , K ) -> String ,
369- key : K ,
370- kind : DepKind ,
371- name : & ' static str ,
372- ) -> QueryStackFrame < QueryStackDeferred < ' tcx > > {
373- let def_id = key. key_as_def_id ( ) ;
374346
375- let hash = || {
376- tcx. with_stable_hashing_context ( |mut hcx| {
377- let mut hasher = StableHasher :: new ( ) ;
378- kind. as_usize ( ) . hash_stable ( & mut hcx, & mut hasher) ;
379- key. hash_stable ( & mut hcx, & mut hasher) ;
380- hasher. finish :: < Hash64 > ( )
381- } )
382- } ;
383347 let def_id_for_ty_in_cycle = key. def_id_for_ty_in_cycle ( ) ;
384348
385- let info =
386- QueryStackDeferred :: new ( ( tcx, key, kind, name, do_describe) , create_query_frame_extra) ;
349+ let hash = tcx. with_stable_hashing_context ( |mut hcx| {
350+ let mut hasher = StableHasher :: new ( ) ;
351+ kind. as_usize ( ) . hash_stable ( & mut hcx, & mut hasher) ;
352+ key. hash_stable ( & mut hcx, & mut hasher) ;
353+ hasher. finish :: < Hash64 > ( )
354+ } ) ;
387355
388- QueryStackFrame :: new ( info , kind , hash , def_id , def_id_for_ty_in_cycle)
356+ QueryStackFrame :: new ( description , span , def_id , def_kind , kind , def_id_for_ty_in_cycle, hash )
389357}
390358
391359pub ( crate ) fn encode_query_results < ' a , ' tcx , Q > (
@@ -737,7 +705,7 @@ macro_rules! define_queries {
737705
738706 pub ( crate ) fn collect_active_jobs<' tcx>(
739707 tcx: TyCtxt <' tcx>,
740- qmap: & mut QueryMap < QueryStackDeferred < ' tcx>> ,
708+ qmap: & mut QueryMap ,
741709 require_complete: bool ,
742710 ) -> Option <( ) > {
743711 let make_query = |tcx, key| {
@@ -821,7 +789,7 @@ macro_rules! define_queries {
821789 // These arrays are used for iteration and can't be indexed by `DepKind`.
822790
823791 const COLLECT_ACTIVE_JOBS : & [
824- for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryMap < QueryStackDeferred < ' tcx>> , bool ) -> Option <( ) >
792+ for <' tcx> fn ( TyCtxt <' tcx>, & mut QueryMap , bool ) -> Option <( ) >
825793 ] =
826794 & [ $( query_impl:: $name:: collect_active_jobs) ,* ] ;
827795
0 commit comments