@@ -7,7 +7,6 @@ use crate::rustc_middle::ty::TyEncoder;
77use crate :: QueryConfigRestored ;
88use rustc_data_structures:: stable_hasher:: { Hash64 , HashStable , StableHasher } ;
99use rustc_data_structures:: sync:: Lock ;
10- use rustc_errors:: Diagnostic ;
1110
1211use rustc_index:: Idx ;
1312use rustc_middle:: dep_graph:: dep_kinds;
@@ -31,7 +30,6 @@ use rustc_serialize::Encodable;
3130use rustc_session:: Limit ;
3231use rustc_span:: def_id:: LOCAL_CRATE ;
3332use std:: num:: NonZero ;
34- use thin_vec:: ThinVec ;
3533
3634#[ derive( Copy , Clone ) ]
3735pub struct QueryCtxt < ' tcx > {
@@ -125,7 +123,7 @@ impl QueryContext for QueryCtxt<'_> {
125123 self ,
126124 token : QueryJobId ,
127125 depth_limit : bool ,
128- diagnostics : Option < & Lock < ThinVec < Diagnostic > > > ,
126+ side_effects : Option < & Lock < QuerySideEffects > > ,
129127 compute : impl FnOnce ( ) -> R ,
130128 ) -> R {
131129 // The `TyCtxt` stored in TLS has the same global interner lifetime
@@ -140,7 +138,7 @@ impl QueryContext for QueryCtxt<'_> {
140138 let new_icx = ImplicitCtxt {
141139 tcx : self . tcx ,
142140 query : Some ( token) ,
143- diagnostics ,
141+ side_effects ,
144142 query_depth : current_icx. query_depth + depth_limit as usize ,
145143 task_deps : current_icx. task_deps ,
146144 } ;
@@ -172,6 +170,16 @@ impl QueryContext for QueryCtxt<'_> {
172170 crate_name : self . crate_name ( LOCAL_CRATE ) ,
173171 } ) ;
174172 }
173+
174+ #[ tracing:: instrument( level = "trace" , skip( self ) ) ]
175+ fn apply_side_effects ( self , side_effects : QuerySideEffects ) {
176+ let dcx = self . dep_context ( ) . sess ( ) . dcx ( ) ;
177+ let QuerySideEffects { diagnostics } = side_effects;
178+
179+ for diagnostic in diagnostics {
180+ dcx. emit_diagnostic ( diagnostic) ;
181+ }
182+ }
175183}
176184
177185pub ( super ) fn try_mark_green < ' tcx > ( tcx : TyCtxt < ' tcx > , dep_node : & dep_graph:: DepNode ) -> bool {
0 commit comments