@@ -8,10 +8,9 @@ use rustc_query_system::HandleCycleError;
88use rustc_query_system:: dep_graph:: { DepNodeIndex , SerializedDepNodeIndex } ;
99pub ( crate ) use rustc_query_system:: query:: QueryJobId ;
1010use rustc_query_system:: query:: * ;
11- use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span } ;
11+ use rustc_span:: { ErrorGuaranteed , Span } ;
1212pub use sealed:: IntoQueryParam ;
1313
14- use super :: erase:: EraseType ;
1514use crate :: dep_graph;
1615use crate :: dep_graph:: DepKind ;
1716use crate :: query:: on_disk_cache:: { CacheEncoder , EncodedDepNodeIndex , OnDiskCache } ;
@@ -167,78 +166,17 @@ impl<'tcx> TyCtxt<'tcx> {
167166 }
168167}
169168
170- #[ inline( always) ]
171- pub fn query_get_at < ' tcx , Cache > (
172- tcx : TyCtxt < ' tcx > ,
173- execute_query : fn ( TyCtxt < ' tcx > , Span , Cache :: Key , QueryMode ) -> Option < Cache :: Value > ,
174- query_cache : & Cache ,
175- span : Span ,
176- key : Cache :: Key ,
177- ) -> Cache :: Value
178- where
179- Cache : QueryCache ,
180- {
181- let key = key. into_query_param ( ) ;
182- match try_get_cached ( tcx, query_cache, & key) {
183- Some ( value) => value,
184- None => execute_query ( tcx, span, key, QueryMode :: Get ) . unwrap ( ) ,
185- }
186- }
187-
188- #[ inline]
189- pub fn query_ensure < ' tcx , Cache > (
190- tcx : TyCtxt < ' tcx > ,
191- execute_query : fn ( TyCtxt < ' tcx > , Span , Cache :: Key , QueryMode ) -> Option < Cache :: Value > ,
192- query_cache : & Cache ,
193- key : Cache :: Key ,
194- check_cache : bool ,
195- ) where
196- Cache : QueryCache ,
197- {
198- let key = key. into_query_param ( ) ;
199- if try_get_cached ( tcx, query_cache, & key) . is_none ( ) {
200- execute_query ( tcx, DUMMY_SP , key, QueryMode :: Ensure { check_cache } ) ;
201- }
202- }
203-
204- #[ inline]
205- pub fn query_ensure_error_guaranteed < ' tcx , Cache , T > (
206- tcx : TyCtxt < ' tcx > ,
207- execute_query : fn ( TyCtxt < ' tcx > , Span , Cache :: Key , QueryMode ) -> Option < Cache :: Value > ,
208- query_cache : & Cache ,
209- key : Cache :: Key ,
210- check_cache : bool ,
211- ) -> Result < ( ) , ErrorGuaranteed >
212- where
213- Cache : QueryCache < Value = super :: erase:: Erase < Result < T , ErrorGuaranteed > > > ,
214- Result < T , ErrorGuaranteed > : EraseType ,
215- {
216- let key = key. into_query_param ( ) ;
217- if let Some ( res) = try_get_cached ( tcx, query_cache, & key) {
218- super :: erase:: restore ( res) . map ( drop)
219- } else {
220- execute_query ( tcx, DUMMY_SP , key, QueryMode :: Ensure { check_cache } )
221- . map ( super :: erase:: restore)
222- . map ( |res| res. map ( drop) )
223- // Either we actually executed the query, which means we got a full `Result`,
224- // or we can just assume the query succeeded, because it was green in the
225- // incremental cache. If it is green, that means that the previous compilation
226- // that wrote to the incremental cache compiles successfully. That is only
227- // possible if the cache entry was `Ok(())`, so we emit that here, without
228- // actually encoding the `Result` in the cache or loading it from there.
229- . unwrap_or ( Ok ( ( ) ) )
230- }
231- }
232-
233- macro_rules! query_ensure {
169+ /// Calls either `query_ensure` or `query_ensure_error_guaranteed`, depending
170+ /// on whether the list of modifiers contains `return_result_from_ensure_ok`.
171+ macro_rules! query_ensure_select {
234172 ( [ ] $( $args: tt) * ) => {
235- query_ensure( $( $args) * )
173+ crate :: query :: inner :: query_ensure( $( $args) * )
236174 } ;
237175 ( [ ( return_result_from_ensure_ok) $( $rest: tt) * ] $( $args: tt) * ) => {
238- query_ensure_error_guaranteed( $( $args) * ) . map ( |_| ( ) )
176+ crate :: query :: inner :: query_ensure_error_guaranteed( $( $args) * )
239177 } ;
240178 ( [ $other: tt $( $modifiers: tt) * ] $( $args: tt) * ) => {
241- query_ensure !( [ $( $modifiers) * ] $( $args) * )
179+ query_ensure_select !( [ $( $modifiers) * ] $( $args) * )
242180 } ;
243181}
244182
@@ -434,7 +372,7 @@ macro_rules! define_callbacks {
434372 self ,
435373 key: query_helper_param_ty!( $( $K) * ) ,
436374 ) -> ensure_ok_result!( [ $( $modifiers) * ] ) {
437- query_ensure !(
375+ query_ensure_select !(
438376 [ $( $modifiers) * ]
439377 self . tcx,
440378 self . tcx. query_system. fns. engine. $name,
@@ -449,7 +387,7 @@ macro_rules! define_callbacks {
449387 $( $( #[ $attr] ) *
450388 #[ inline( always) ]
451389 pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) {
452- query_ensure(
390+ crate :: query :: inner :: query_ensure(
453391 self . tcx,
454392 self . tcx. query_system. fns. engine. $name,
455393 & self . tcx. query_system. caches. $name,
@@ -474,7 +412,7 @@ macro_rules! define_callbacks {
474412 #[ inline( always) ]
475413 pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) -> $V
476414 {
477- restore:: <$V>( query_get_at(
415+ restore:: <$V>( crate :: query :: inner :: query_get_at(
478416 self . tcx,
479417 self . tcx. query_system. fns. engine. $name,
480418 & self . tcx. query_system. caches. $name,
0 commit comments