Skip to content

Commit

Permalink
Do not require QueryCtxt for cache_on_disk.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 23, 2021
1 parent 7c0920f commit 138e96b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_query_impl/src/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*]),
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_query_system/src/query/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 138e96b

Please sign in to comment.