From 138e96b71926a9cb8b70b33d40ab803ab2985d94 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 23 Oct 2021 18:12:43 +0200 Subject: [PATCH] Do not require QueryCtxt for cache_on_disk. --- compiler/rustc_macros/src/query.rs | 4 ++-- compiler/rustc_query_impl/src/on_disk_cache.rs | 2 +- compiler/rustc_query_impl/src/plumbing.rs | 3 +-- compiler/rustc_query_system/src/query/config.rs | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index f5cb36b5ba2..5ff12a17887 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -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 } diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_query_impl/src/on_disk_cache.rs index 90c06c7b231..552906aac31 100644 --- a/compiler/rustc_query_impl/src/on_disk_cache.rs +++ b/compiler/rustc_query_impl/src/on_disk_cache.rs @@ -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. diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 8401104e7c6..6282a9dcd52 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -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); } diff --git a/compiler/rustc_query_system/src/query/config.rs b/compiler/rustc_query_system/src/query/config.rs index 6c4e6196c9d..d2b102b6f89 100644 --- a/compiler/rustc_query_system/src/query/config.rs +++ b/compiler/rustc_query_system/src/query/config.rs @@ -71,5 +71,5 @@ pub trait QueryDescription: 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; - fn cache_on_disk(tcx: CTX, key: &Self::Key) -> bool; + fn cache_on_disk(tcx: CTX::DepContext, key: &Self::Key) -> bool; }