Skip to content

Commit

Permalink
Retire rustc_dep_node_try_load_from_on_disk_cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 22, 2020
1 parent e853cc0 commit 57ba8ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
26 changes: 0 additions & 26 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
let mut query_stream = quote! {};
let mut query_description_stream = quote! {};
let mut dep_node_def_stream = quote! {};
let mut try_load_from_on_disk_cache_stream = quote! {};
let mut cached_queries = quote! {};

for group in groups.0 {
Expand All @@ -439,22 +438,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
cached_queries.extend(quote! {
#name,
});

try_load_from_on_disk_cache_stream.extend(quote! {
::rustc_middle::dep_graph::DepKind::#name => {
if <#arg as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key() {
debug_assert!($tcx.dep_graph
.node_color($dep_node)
.map(|c| c.is_green())
.unwrap_or(false));

let key = <#arg as DepNodeParams<TyCtxt<'_>>>::recover($tcx, $dep_node).unwrap();
if queries::#name::cache_on_disk($tcx, &key, None) {
let _ = $tcx.#name(key);
}
}
}
});
}

let mut attributes = Vec::new();
Expand Down Expand Up @@ -528,14 +511,5 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
}

#query_description_stream

macro_rules! rustc_dep_node_try_load_from_on_disk_cache {
($dep_node:expr, $tcx:expr) => {
match $dep_node.kind {
#try_load_from_on_disk_cache_stream
_ => (),
}
}
}
})
}
24 changes: 23 additions & 1 deletion compiler/rustc_middle/src/ty/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,29 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
}

pub(crate) fn try_load_from_on_disk_cache<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) {
rustc_dep_node_try_load_from_on_disk_cache!(dep_node, tcx)
macro_rules! try_load_from_on_disk_cache {
($($name:ident,)*) => {
match dep_node.kind {
$(DepKind::$name => {
if <query_keys::$name<'tcx> as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key() {
debug_assert!(tcx.dep_graph
.node_color(dep_node)
.map(|c| c.is_green())
.unwrap_or(false));

let key = <query_keys::$name<'tcx> as DepNodeParams<TyCtxt<'_>>>::recover(tcx, dep_node).unwrap();
if queries::$name::cache_on_disk(tcx, &key, None) {
let _ = tcx.$name(key);
}
}
})*

_ => (),
}
}
}

rustc_cached_queries!(try_load_from_on_disk_cache!);
}

mod sealed {
Expand Down

0 comments on commit 57ba8ed

Please sign in to comment.