Do not require QueryCtxt for cache_on_disk.

This commit is contained in:
Camille GILLOT 2021-10-23 18:12:43 +02:00
parent 7c0920f5fb
commit 138e96b719
4 changed files with 5 additions and 6 deletions

View File

@ -372,7 +372,7 @@ fn add_query_description_impl(
quote! {
#[allow(unused_variables, unused_braces)]
#[inline]
fn cache_on_disk(#tcx: QueryCtxt<'tcx>, #key: &Self::Key) -> bool {
fn cache_on_disk(#tcx: TyCtxt<'tcx>, #key: &Self::Key) -> bool {
#expr
}
@ -384,7 +384,7 @@ fn add_query_description_impl(
}
quote! {
#[inline]
fn cache_on_disk(_: QueryCtxt<'tcx>, _: &Self::Key) -> bool {
fn cache_on_disk(_: TyCtxt<'tcx>, _: &Self::Key) -> bool {
false
}

View File

@ -1033,7 +1033,7 @@ where
if res.is_err() {
return;
}
if Q::cache_on_disk(tcx, &key) {
if Q::cache_on_disk(*tcx.dep_context(), &key) {
let dep_node = SerializedDepNodeIndex::new(dep_node.index());
// Record position of the cache entry.

View File

@ -315,7 +315,7 @@ macro_rules! define_queries {
} else {
tcx.queries.extern_providers.$name
};
let cache_on_disk = Self::cache_on_disk(tcx, key);
let cache_on_disk = Self::cache_on_disk(tcx.tcx, key);
QueryVtable {
anon: is_anon!([$($modifiers)*]),
eval_always: is_eval_always!([$($modifiers)*]),
@ -415,7 +415,6 @@ macro_rules! define_queries {
debug_assert!(tcx.dep_graph.is_green(&dep_node));
let key = recover(tcx, dep_node).unwrap_or_else(|| panic!("Failed to recover key for {:?} with hash {}", dep_node, dep_node.hash));
let tcx = QueryCtxt::from_tcx(tcx);
if queries::$name::cache_on_disk(tcx, &key) {
let _ = tcx.$name(key);
}

View File

@ -71,5 +71,5 @@ pub trait QueryDescription<CTX: QueryContext>: QueryConfig {
// Don't use this method to compute query results, instead use the methods on TyCtxt
fn make_vtable(tcx: CTX, key: &Self::Key) -> QueryVtable<CTX, Self::Key, Self::Value>;
fn cache_on_disk(tcx: CTX, key: &Self::Key) -> bool;
fn cache_on_disk(tcx: CTX::DepContext, key: &Self::Key) -> bool;
}