@@ -8,10 +8,9 @@ use rustc_query_system::HandleCycleError;
8
8
use rustc_query_system:: dep_graph:: { DepNodeIndex , SerializedDepNodeIndex } ;
9
9
pub ( crate ) use rustc_query_system:: query:: QueryJobId ;
10
10
use rustc_query_system:: query:: * ;
11
- use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span } ;
11
+ use rustc_span:: { ErrorGuaranteed , Span } ;
12
12
pub use sealed:: IntoQueryParam ;
13
13
14
- use super :: erase:: EraseType ;
15
14
use crate :: dep_graph;
16
15
use crate :: dep_graph:: DepKind ;
17
16
use crate :: query:: on_disk_cache:: { CacheEncoder , EncodedDepNodeIndex , OnDiskCache } ;
@@ -167,78 +166,17 @@ impl<'tcx> TyCtxt<'tcx> {
167
166
}
168
167
}
169
168
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 {
234
172
( [ ] $( $args: tt) * ) => {
235
- query_ensure( $( $args) * )
173
+ crate :: query :: inner :: query_ensure( $( $args) * )
236
174
} ;
237
175
( [ ( 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) * )
239
177
} ;
240
178
( [ $other: tt $( $modifiers: tt) * ] $( $args: tt) * ) => {
241
- query_ensure !( [ $( $modifiers) * ] $( $args) * )
179
+ query_ensure_select !( [ $( $modifiers) * ] $( $args) * )
242
180
} ;
243
181
}
244
182
@@ -434,7 +372,7 @@ macro_rules! define_callbacks {
434
372
self ,
435
373
key: query_helper_param_ty!( $( $K) * ) ,
436
374
) -> ensure_ok_result!( [ $( $modifiers) * ] ) {
437
- query_ensure !(
375
+ query_ensure_select !(
438
376
[ $( $modifiers) * ]
439
377
self . tcx,
440
378
self . tcx. query_system. fns. engine. $name,
@@ -449,7 +387,7 @@ macro_rules! define_callbacks {
449
387
$( $( #[ $attr] ) *
450
388
#[ inline( always) ]
451
389
pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) {
452
- query_ensure(
390
+ crate :: query :: inner :: query_ensure(
453
391
self . tcx,
454
392
self . tcx. query_system. fns. engine. $name,
455
393
& self . tcx. query_system. caches. $name,
@@ -474,7 +412,7 @@ macro_rules! define_callbacks {
474
412
#[ inline( always) ]
475
413
pub fn $name( self , key: query_helper_param_ty!( $( $K) * ) ) -> $V
476
414
{
477
- restore:: <$V>( query_get_at(
415
+ restore:: <$V>( crate :: query :: inner :: query_get_at(
478
416
self . tcx,
479
417
self . tcx. query_system. fns. engine. $name,
480
418
& self . tcx. query_system. caches. $name,
0 commit comments