@@ -301,11 +301,8 @@ pub(crate) fn create_query_frame<
301
301
QueryStackFrame::new(name, description, span, def_kind, hash)
302
302
}
303
303
304
- pub(crate) fn try_load_from_on_disk_cache<'tcx, Q, V>(
305
- tcx: TyCtxt<'tcx>,
306
- dep_node: DepNode,
307
- cache_query_deps: fn(TyCtxt<'tcx>, Q::Key) -> V,
308
- ) where
304
+ fn try_load_from_on_disk_cache<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode)
305
+ where
309
306
Q: QueryDescription<QueryCtxt<'tcx>>,
310
307
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
311
308
{
@@ -315,11 +312,11 @@ pub(crate) fn try_load_from_on_disk_cache<'tcx, Q, V>(
315
312
panic!("Failed to recover key for {:?} with hash {}", dep_node, dep_node.hash)
316
313
});
317
314
if Q::cache_on_disk(tcx, &key) {
318
- let _ = cache_query_deps (tcx, key);
315
+ let _ = Q::execute_query (tcx, key);
319
316
}
320
317
}
321
318
322
- pub(crate) fn force_from_dep_node<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode) -> bool
319
+ fn force_from_dep_node<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode) -> bool
323
320
where
324
321
Q: QueryDescription<QueryCtxt<'tcx>>,
325
322
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
@@ -336,13 +333,9 @@ where
336
333
}
337
334
338
335
pub(crate) fn query_callback<'tcx, Q: QueryConfig>(
339
- // NOTE: we can't remove these function pointers, because `recover` is invariant -> `try_load_from_on_disk_cache` takes a concrete lifetime, not a universal lifetime.
340
- // Instead, we infer the correct lifetime at the callsite, so we can pass in a HRTB function pointer to the DepKindStruct.
341
- try_load_from_on_disk_cache: fn(TyCtxt<'_>, DepNode),
342
- force_from_dep_node: fn(TyCtxt<'_>, DepNode) -> bool,
343
336
is_anon: bool,
344
337
is_eval_always: bool,
345
- ) -> DepKindStruct
338
+ ) -> DepKindStruct<'tcx>
346
339
where
347
340
Q: QueryDescription<QueryCtxt<'tcx>>,
348
341
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
@@ -363,8 +356,8 @@ where
363
356
is_anon,
364
357
is_eval_always,
365
358
fingerprint_style,
366
- force_from_dep_node: Some(force_from_dep_node),
367
- try_load_from_on_disk_cache: Some(try_load_from_on_disk_cache),
359
+ force_from_dep_node: Some(force_from_dep_node::<Q> ),
360
+ try_load_from_on_disk_cache: Some(try_load_from_on_disk_cache::<Q> ),
368
361
}
369
362
}
370
363
@@ -431,6 +424,10 @@ macro_rules! define_queries {
431
424
try_load_from_disk: Self::TRY_LOAD_FROM_DISK,
432
425
}
433
426
}
427
+
428
+ fn execute_query(tcx: TyCtxt<'tcx>, k: Self::Key) -> Self::Stored {
429
+ tcx.$name(k)
430
+ }
434
431
})*
435
432
436
433
#[allow(nonstandard_style)]
@@ -439,7 +436,7 @@ macro_rules! define_queries {
439
436
use rustc_query_system::dep_graph::FingerprintStyle;
440
437
441
438
// We use this for most things when incr. comp. is turned off.
442
- pub fn Null() -> DepKindStruct {
439
+ pub fn Null<'tcx> () -> DepKindStruct<'tcx> {
443
440
DepKindStruct {
444
441
is_anon: false,
445
442
is_eval_always: false,
@@ -450,7 +447,7 @@ macro_rules! define_queries {
450
447
}
451
448
452
449
// We use this for the forever-red node.
453
- pub fn Red() -> DepKindStruct {
450
+ pub fn Red<'tcx> () -> DepKindStruct<'tcx> {
454
451
DepKindStruct {
455
452
is_anon: false,
456
453
is_eval_always: false,
@@ -460,7 +457,7 @@ macro_rules! define_queries {
460
457
}
461
458
}
462
459
463
- pub fn TraitSelect() -> DepKindStruct {
460
+ pub fn TraitSelect<'tcx> () -> DepKindStruct<'tcx> {
464
461
DepKindStruct {
465
462
is_anon: true,
466
463
is_eval_always: false,
@@ -470,7 +467,7 @@ macro_rules! define_queries {
470
467
}
471
468
}
472
469
473
- pub fn CompileCodegenUnit() -> DepKindStruct {
470
+ pub fn CompileCodegenUnit<'tcx> () -> DepKindStruct<'tcx> {
474
471
DepKindStruct {
475
472
is_anon: false,
476
473
is_eval_always: false,
@@ -480,7 +477,7 @@ macro_rules! define_queries {
480
477
}
481
478
}
482
479
483
- pub fn CompileMonoItem() -> DepKindStruct {
480
+ pub fn CompileMonoItem<'tcx> () -> DepKindStruct<'tcx> {
484
481
DepKindStruct {
485
482
is_anon: false,
486
483
is_eval_always: false,
@@ -490,21 +487,15 @@ macro_rules! define_queries {
490
487
}
491
488
}
492
489
493
- $(pub(crate) fn $name()-> DepKindStruct {
494
- let is_anon = is_anon!([$($modifiers)*]);
495
- let is_eval_always = is_eval_always!([$($modifiers)*]);
496
- type Q<'tcx> = queries::$name<'tcx>;
497
-
498
- $crate::plumbing::query_callback::<Q<'_>>(
499
- |tcx, key| $crate::plumbing::try_load_from_on_disk_cache::<Q<'_>, _>(tcx, key, TyCtxt::$name),
500
- |tcx, key| $crate::plumbing::force_from_dep_node::<Q<'_>>(tcx, key),
501
- is_anon,
502
- is_eval_always
490
+ $(pub(crate) fn $name<'tcx>()-> DepKindStruct<'tcx> {
491
+ $crate::plumbing::query_callback::<queries::$name<'tcx>>(
492
+ is_anon!([$($modifiers)*]),
493
+ is_eval_always!([$($modifiers)*]),
503
494
)
504
495
})*
505
496
}
506
497
507
- pub fn query_callbacks<'tcx>(arena: &'tcx Arena<'tcx>) -> &'tcx [DepKindStruct] {
498
+ pub fn query_callbacks<'tcx>(arena: &'tcx Arena<'tcx>) -> &'tcx [DepKindStruct<'tcx> ] {
508
499
arena.alloc_from_iter(make_dep_kind_array!(query_callbacks))
509
500
}
510
501
}
0 commit comments