Derive which queries to save using the proc macro

This commit is contained in:
John Kåre Alsaker 2019-06-27 06:41:06 +02:00
parent ef064d2f66
commit b9344e31f5
3 changed files with 26 additions and 24 deletions

View File

@ -422,11 +422,6 @@
"const-evaluating `{}`",
tcx.def_path_str(key.value.instance.def.def_id())
}
cache_on_disk_if(_, opt_result) {
// Only store results without errors
// FIXME: We never store these
opt_result.map_or(true, |r| r.is_ok())
}
}
/// Results of evaluating const items or constants embedded in

View File

@ -201,28 +201,22 @@ pub fn serialize<'tcx, E>(&self, tcx: TyCtxt<'tcx>, encoder: &mut E) -> Result<(
let mut query_result_index = EncodedQueryResultIndex::new();
time(tcx.sess, "encode query results", || {
use crate::ty::query::queries::*;
let enc = &mut encoder;
let qri = &mut query_result_index;
encode_query_results::<type_of<'_>, _>(tcx, enc, qri)?;
encode_query_results::<generics_of<'_>, _>(tcx, enc, qri)?;
encode_query_results::<predicates_of<'_>, _>(tcx, enc, qri)?;
encode_query_results::<used_trait_imports<'_>, _>(tcx, enc, qri)?;
encode_query_results::<typeck_tables_of<'_>, _>(tcx, enc, qri)?;
encode_query_results::<codegen_fulfill_obligation<'_>, _>(tcx, enc, qri)?;
encode_query_results::<optimized_mir<'_>, _>(tcx, enc, qri)?;
encode_query_results::<unsafety_check_result<'_>, _>(tcx, enc, qri)?;
encode_query_results::<borrowck<'_>, _>(tcx, enc, qri)?;
encode_query_results::<mir_borrowck<'_>, _>(tcx, enc, qri)?;
encode_query_results::<mir_const_qualif<'_>, _>(tcx, enc, qri)?;
encode_query_results::<const_is_rvalue_promotable_to_static<'_>, _>(tcx, enc, qri)?;
encode_query_results::<symbol_name<'_>, _>(tcx, enc, qri)?;
encode_query_results::<check_match<'_>, _>(tcx, enc, qri)?;
encode_query_results::<codegen_fn_attrs<'_>, _>(tcx, enc, qri)?;
encode_query_results::<specialization_graph_of<'_>, _>(tcx, enc, qri)?;
encode_query_results::<const_eval<'_>, _>(tcx, enc, qri)?;
// FIXME: Include const_eval_raw?
macro_rules! encode_queries {
($($query:ident,)*) => {
$(
encode_query_results::<ty::query::queries::$query<'_>, _>(
tcx,
enc,
qri
)?;
)*
}
}
rustc_cached_queries!(encode_queries!);
Ok(())
})?;

View File

@ -414,6 +414,7 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
let mut dep_node_force_stream = quote! {};
let mut try_load_from_on_disk_cache_stream = quote! {};
let mut no_force_queries = Vec::new();
let mut cached_queries = quote! {};
for group in groups.0 {
let mut group_stream = quote! {};
@ -427,6 +428,12 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
_ => quote! { #result_full },
};
if modifiers.cache.is_some() {
cached_queries.extend(quote! {
#name,
});
}
if modifiers.cache.is_some() && !modifiers.no_force {
try_load_from_on_disk_cache_stream.extend(quote! {
DepKind::#name => {
@ -549,6 +556,12 @@ macro_rules! rustc_dep_node_force {
}
}
}
macro_rules! rustc_cached_queries {
($($macro:tt)*) => {
$($macro)*(#cached_queries);
}
}
#query_description_stream
impl DepNode {