Skip to content
Permalink
Browse files

Derive which queries to save using the proc macro

  • Loading branch information...
Zoxc committed Jun 27, 2019
1 parent ef064d2 commit b9344e31f53b4621b78521a42f719d53dd37b79e
Showing with 26 additions and 24 deletions.
  1. +0 −5 src/librustc/query/mod.rs
  2. +13 −19 src/librustc/ty/query/on_disk_cache.rs
  3. +13 −0 src/librustc_macros/src/query.rs
@@ -422,11 +422,6 @@ rustc_queries! {
"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
@@ -201,28 +201,22 @@ impl<'sess> OnDiskCache<'sess> {
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(())
})?;
@@ -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 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
}
}
}
macro_rules! rustc_cached_queries {
($($macro:tt)*) => {
$($macro)*(#cached_queries);
}
}

#query_description_stream

impl DepNode {

0 comments on commit b9344e3

Please sign in to comment.
You can’t perform that action at this time.