From 0a122d3a507973fef34b96afe5443f1416314457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 5 Apr 2019 13:11:44 +0200 Subject: [PATCH 1/3] Clean up query cache code --- src/librustc/dep_graph/graph.rs | 37 ++++------- src/librustc/mir/interpret/error.rs | 2 +- src/librustc/query/mod.rs | 61 ++++++++++------- src/librustc/ty/query/config.rs | 32 +-------- src/librustc/ty/query/on_disk_cache.rs | 24 +------ src/librustc/ty/query/plumbing.rs | 65 +----------------- src/librustc_macros/src/lib.rs | 2 + src/librustc_macros/src/query.rs | 92 ++++++++++++++++++++------ 8 files changed, 131 insertions(+), 184 deletions(-) diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index c2e3c12cea8ed..93c22c3e713c0 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -842,31 +842,20 @@ impl DepGraph { // This method will only load queries that will end up in the disk cache. // Other queries will not be executed. pub fn exec_cache_promotions<'tcx>(&self, tcx: TyCtxt<'tcx>) { - let green_nodes: Vec = { - let data = self.data.as_ref().unwrap(); - data.colors.values.indices().filter_map(|prev_index| { - match data.colors.get(prev_index) { - Some(DepNodeColor::Green(_)) => { - let dep_node = data.previous.index_to_node(prev_index); - if dep_node.cache_on_disk(tcx) { - Some(dep_node) - } else { - None - } - } - None | - Some(DepNodeColor::Red) => { - // We can skip red nodes because a node can only be marked - // as red if the query result was recomputed and thus is - // already in memory. - None - } + let data = self.data.as_ref().unwrap(); + for prev_index in data.colors.values.indices() { + match data.colors.get(prev_index) { + Some(DepNodeColor::Green(_)) => { + let dep_node = data.previous.index_to_node(prev_index); + dep_node.try_load_from_on_disk_cache(tcx); } - }).collect() - }; - - for dep_node in green_nodes { - dep_node.load_from_on_disk_cache(tcx); + None | + Some(DepNodeColor::Red) => { + // We can skip red nodes because a node can only be marked + // as red if the query result was recomputed and thus is + // already in memory. + } + } } } diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index e8113b4516cda..256b3f1015093 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -18,7 +18,7 @@ use errors::DiagnosticBuilder; use syntax_pos::{Pos, Span}; use syntax::symbol::Symbol; -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)] pub enum ErrorHandled { /// Already reported a lint or an error for this evaluation. Reported, diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 10efef54526a6..74114533faaa8 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -2,7 +2,7 @@ use crate::ty::query::QueryDescription; use crate::ty::query::queries; use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt}; use crate::ty::subst::SubstsRef; -use crate::dep_graph::SerializedDepNodeIndex; +use crate::dep_graph::{RecoverKey,DepKind, DepNode, SerializedDepNodeIndex}; use crate::hir::def_id::{CrateNum, DefId, DefIndex}; use crate::mir; use crate::mir::interpret::GlobalId; @@ -33,13 +33,13 @@ rustc_queries! { Other { /// Records the type of every item. query type_of(key: DefId) -> Ty<'tcx> { - cache { key.is_local() } + cache_on_disk_if { key.is_local() } } /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its /// associated generics. query generics_of(key: DefId) -> &'tcx ty::Generics { - cache { key.is_local() } + cache_on_disk_if { key.is_local() } load_cached(tcx, id) { let generics: Option = tcx.queries.on_disk_cache .try_load_query_result(tcx, id); @@ -62,7 +62,9 @@ rustc_queries! { /// predicate gets in the way of some checks, which are intended /// to operate over only the actual where-clauses written by the /// user.) - query predicates_of(_: DefId) -> &'tcx ty::GenericPredicates<'tcx> {} + query predicates_of(key: DefId) -> &'tcx ty::GenericPredicates<'tcx> { + cache_on_disk_if { key.is_local() } + } query native_libraries(_: CrateNum) -> Lrc> { desc { "looking up the native libraries of a linked crate" } @@ -93,7 +95,7 @@ rustc_queries! { /// of the MIR qualify_consts pass. The actual meaning of /// the value isn't known except to the pass itself. query mir_const_qualif(key: DefId) -> (u8, &'tcx BitSet) { - cache { key.is_local() } + cache_on_disk_if { key.is_local() } } /// Fetch the MIR for a given `DefId` right after it's built - this includes @@ -115,7 +117,7 @@ rustc_queries! { /// MIR after our optimization passes have run. This is MIR that is ready /// for codegen. This is also the only query that can fetch non-local MIR, at present. query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> { - cache { key.is_local() } + cache_on_disk_if { key.is_local() } load_cached(tcx, id) { let mir: Option> = tcx.queries.on_disk_cache .try_load_query_result(tcx, id); @@ -285,7 +287,9 @@ rustc_queries! { TypeChecking { /// The result of unsafety-checking this `DefId`. - query unsafety_check_result(_: DefId) -> mir::UnsafetyCheckResult {} + query unsafety_check_result(key: DefId) -> mir::UnsafetyCheckResult { + cache_on_disk_if { key.is_local() } + } /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error query unsafe_derive_on_repr_packed(_: DefId) -> () {} @@ -348,7 +352,7 @@ rustc_queries! { } query typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> { - cache { key.is_local() } + cache_on_disk_if { key.is_local() } load_cached(tcx, id) { let typeck_tables: Option> = tcx .queries.on_disk_cache @@ -360,7 +364,9 @@ rustc_queries! { } Other { - query used_trait_imports(_: DefId) -> &'tcx DefIdSet {} + query used_trait_imports(key: DefId) -> &'tcx DefIdSet { + cache_on_disk_if { key.is_local() } + } } TypeChecking { @@ -372,11 +378,15 @@ rustc_queries! { } BorrowChecking { - query borrowck(_: DefId) -> &'tcx BorrowCheckResult {} + query borrowck(key: DefId) -> &'tcx BorrowCheckResult { + cache_on_disk_if { key.is_local() } + } /// Borrow-checks the function body. If this is a closure, returns /// additional requirements that the closure's creator must verify. - query mir_borrowck(_: DefId) -> mir::BorrowCheckResult<'tcx> {} + query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> { + cache_on_disk_if(tcx, _) { key.is_local() && tcx.is_closure(key) } + } } TypeChecking { @@ -412,9 +422,10 @@ rustc_queries! { "const-evaluating `{}`", tcx.def_path_str(key.value.instance.def.def_id()) } - cache { true } - load_cached(tcx, id) { - tcx.queries.on_disk_cache.try_load_query_result(tcx, id).map(Ok) + 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()) } } @@ -427,9 +438,9 @@ rustc_queries! { "const-evaluating + checking `{}`", tcx.def_path_str(key.value.instance.def.def_id()) } - cache { true } - load_cached(tcx, id) { - tcx.queries.on_disk_cache.try_load_query_result(tcx, id).map(Ok) + cache_on_disk_if(_, opt_result) { + // Only store results without errors + opt_result.map_or(true, |r| r.is_ok()) } } @@ -453,7 +464,9 @@ rustc_queries! { } TypeChecking { - query check_match(_: DefId) -> () {} + query check_match(key: DefId) -> () { + cache_on_disk_if { key.is_local() } + } /// Performs part of the privacy check and computes "access levels". query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels { @@ -483,7 +496,6 @@ rustc_queries! { query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName { no_force desc { "computing the symbol for `{}`", key } - cache { true } } query def_kind(_: DefId) -> Option {} @@ -501,7 +513,9 @@ rustc_queries! { } Codegen { - query codegen_fn_attrs(_: DefId) -> CodegenFnAttrs {} + query codegen_fn_attrs(_: DefId) -> CodegenFnAttrs { + cache_on_disk_if { true } + } } Other { @@ -519,7 +533,7 @@ rustc_queries! { "const checking if rvalue is promotable to static `{}`", tcx.def_path_str(key) } - cache { true } + cache_on_disk_if { true } } query rvalue_promotable_map(key: DefId) -> &'tcx ItemLocalSet { desc { |tcx| @@ -548,7 +562,6 @@ rustc_queries! { key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) ) -> Vtable<'tcx, ()> { no_force - cache { true } desc { |tcx| "checking if `{}` fulfills its obligations", tcx.def_path_str(key.1.def_id()) @@ -560,7 +573,9 @@ rustc_queries! { query trait_impls_of(key: DefId) -> &'tcx ty::trait_def::TraitImpls { desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) } } - query specialization_graph_of(_: DefId) -> &'tcx specialization_graph::Graph {} + query specialization_graph_of(_: DefId) -> &'tcx specialization_graph::Graph { + cache_on_disk_if { true } + } query is_object_safe(key: DefId) -> bool { desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) } } diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index 13d93f173e845..a005beedd6409 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -50,7 +50,7 @@ pub(crate) trait QueryDescription<'tcx>: QueryAccessors<'tcx> { fn describe(tcx: TyCtxt<'_>, key: Self::Key) -> Cow<'static, str>; #[inline] - fn cache_on_disk(_: TyCtxt<'tcx>, _: Self::Key) -> bool { + fn cache_on_disk(_: TyCtxt<'tcx>, _: Self::Key, _: Option<&Self::Value>) -> bool { false } @@ -75,33 +75,3 @@ impl<'tcx> QueryDescription<'tcx> for queries::analysis<'tcx> { "running analysis passes on this crate".into() } } - -macro_rules! impl_disk_cacheable_query( - ($query_name:ident, |$tcx:tt, $key:tt| $cond:expr) => { - impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> { - #[inline] - fn cache_on_disk($tcx: TyCtxt<'tcx>, $key: Self::Key) -> bool { - $cond - } - - #[inline] - fn try_load_from_disk(tcx: TyCtxt<'tcx>, - id: SerializedDepNodeIndex) - -> Option { - tcx.queries.on_disk_cache.try_load_query_result(tcx, id) - } - } - } -); - -impl_disk_cacheable_query!(mir_borrowck, |tcx, def_id| { - def_id.is_local() && tcx.is_closure(def_id) -}); - -impl_disk_cacheable_query!(unsafety_check_result, |_, def_id| def_id.is_local()); -impl_disk_cacheable_query!(borrowck, |_, def_id| def_id.is_local()); -impl_disk_cacheable_query!(check_match, |_, def_id| def_id.is_local()); -impl_disk_cacheable_query!(predicates_of, |_, def_id| def_id.is_local()); -impl_disk_cacheable_query!(used_trait_imports, |_, def_id| def_id.is_local()); -impl_disk_cacheable_query!(codegen_fn_attrs, |_, _| true); -impl_disk_cacheable_query!(specialization_graph_of, |_, _| true); diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 982886f0f1573..8b2183c42efd4 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -221,26 +221,8 @@ impl<'sess> OnDiskCache<'sess> { encode_query_results::, _>(tcx, enc, qri)?; encode_query_results::, _>(tcx, enc, qri)?; encode_query_results::, _>(tcx, enc, qri)?; - - // const eval is special, it only encodes successfully evaluated constants - use crate::ty::query::QueryAccessors; - let cache = const_eval::query_cache(tcx).borrow(); - assert!(cache.active.is_empty()); - for (key, entry) in cache.results.iter() { - use crate::ty::query::config::QueryDescription; - if const_eval::cache_on_disk(tcx, key.clone()) { - if let Ok(ref value) = entry.value { - let dep_node = SerializedDepNodeIndex::new(entry.index.index()); - - // Record position of the cache entry - qri.push((dep_node, AbsoluteBytePos::new(enc.position()))); - - // Encode the type check tables with the SerializedDepNodeIndex - // as tag. - enc.encode_tagged(dep_node, value)?; - } - } - } + encode_query_results::, _>(tcx, enc, qri)?; + // FIXME: Include const_eval_raw? Ok(()) })?; @@ -1090,7 +1072,7 @@ where let map = Q::query_cache(tcx).borrow(); assert!(map.active.is_empty()); for (key, entry) in map.results.iter() { - if Q::cache_on_disk(tcx, key.clone()) { + if Q::cache_on_disk(tcx, key.clone(), Some(&entry.value)) { let dep_node = SerializedDepNodeIndex::new(entry.index.index()); // Record position of the cache entry diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 7d5f984c1b6f2..832c8319718ed 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -444,7 +444,7 @@ impl<'tcx> TyCtxt<'tcx> { debug_assert!(self.dep_graph.is_green(dep_node)); // First we try to load the result from the on-disk cache - let result = if Q::cache_on_disk(self.global_tcx(), key.clone()) && + let result = if Q::cache_on_disk(self.global_tcx(), key.clone(), None) && self.sess.opts.debugging_opts.incremental_queries { self.sess.profiler(|p| p.incremental_load_result_start(Q::NAME)); let result = Q::try_load_from_disk(self.global_tcx(), prev_dep_node_index); @@ -1210,66 +1210,3 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool true } - - -// FIXME(#45015): Another piece of boilerplate code that could be generated in -// a combined define_dep_nodes!()/define_queries!() macro. -macro_rules! impl_load_from_cache { - ($($dep_kind:ident => $query_name:ident,)*) => { - impl DepNode { - // Check whether the query invocation corresponding to the given - // DepNode is eligible for on-disk-caching. - pub fn cache_on_disk(&self, tcx: TyCtxt<'_>) -> bool { - use crate::ty::query::queries; - use crate::ty::query::QueryDescription; - - match self.kind { - $(DepKind::$dep_kind => { - let def_id = self.extract_def_id(tcx).unwrap(); - queries::$query_name::cache_on_disk(tcx.global_tcx(), def_id) - })* - _ => false - } - } - - // This is method will execute the query corresponding to the given - // DepNode. It is only expected to work for DepNodes where the - // above `cache_on_disk` methods returns true. - // Also, as a sanity check, it expects that the corresponding query - // invocation has been marked as green already. - pub fn load_from_on_disk_cache(&self, tcx: TyCtxt<'_>) { - match self.kind { - $(DepKind::$dep_kind => { - debug_assert!(tcx.dep_graph - .node_color(self) - .map(|c| c.is_green()) - .unwrap_or(false)); - - let def_id = self.extract_def_id(tcx).unwrap(); - let _ = tcx.$query_name(def_id); - })* - _ => { - bug!() - } - } - } - } - } -} - -impl_load_from_cache!( - typeck_tables_of => typeck_tables_of, - optimized_mir => optimized_mir, - unsafety_check_result => unsafety_check_result, - borrowck => borrowck, - mir_borrowck => mir_borrowck, - mir_const_qualif => mir_const_qualif, - const_is_rvalue_promotable_to_static => const_is_rvalue_promotable_to_static, - check_match => check_match, - type_of => type_of, - generics_of => generics_of, - predicates_of => predicates_of, - used_trait_imports => used_trait_imports, - codegen_fn_attrs => codegen_fn_attrs, - specialization_graph_of => specialization_graph_of, -); diff --git a/src/librustc_macros/src/lib.rs b/src/librustc_macros/src/lib.rs index 98fba55218f9b..e9cf7bca25c4b 100644 --- a/src/librustc_macros/src/lib.rs +++ b/src/librustc_macros/src/lib.rs @@ -1,6 +1,8 @@ #![feature(proc_macro_hygiene)] #![deny(rust_2018_idioms)] +#![recursion_limit="128"] + extern crate proc_macro; use synstructure::decl_derive; diff --git a/src/librustc_macros/src/query.rs b/src/librustc_macros/src/query.rs index 0474d2a2e3b3a..9fae0fb48a36f 100644 --- a/src/librustc_macros/src/query.rs +++ b/src/librustc_macros/src/query.rs @@ -1,4 +1,5 @@ use proc_macro::TokenStream; +use proc_macro2::{TokenTree, Delimiter}; use syn::{ Token, Ident, Type, Attribute, ReturnType, Expr, Block, Error, braced, parenthesized, parse_macro_input, @@ -35,7 +36,7 @@ enum QueryModifier { Desc(Option, Punctuated), /// Cache the query to disk if the `Expr` returns true. - Cache(Option, Expr), + Cache(Option<(IdentOrWild, IdentOrWild)>, Block), /// Custom code to load the query from disk. LoadCached(Ident, Ident, Block), @@ -77,21 +78,26 @@ impl Parse for QueryModifier { }; let desc = attr_content.parse_terminated(Expr::parse)?; Ok(QueryModifier::Desc(tcx, desc)) - } else if modifier == "cache" { + } else if modifier == "cache_on_disk_if" { // Parse a cache modifier like: - // `cache { |tcx| key.is_local() }` - let attr_content; - braced!(attr_content in input); - let tcx = if attr_content.peek(Token![|]) { - attr_content.parse::()?; - let tcx = attr_content.parse()?; - attr_content.parse::()?; - Some(tcx) + // `cache(tcx, value) { |tcx| key.is_local() }` + let has_args = if let TokenTree::Group(group) = input.fork().parse()? { + group.delimiter() == Delimiter::Parenthesis + } else { + false + }; + let args = if has_args { + let args; + parenthesized!(args in input); + let tcx = args.parse()?; + args.parse::()?; + let value = args.parse()?; + Some((tcx, value)) } else { None }; - let expr = attr_content.parse()?; - Ok(QueryModifier::Cache(tcx, expr)) + let block = input.parse()?; + Ok(QueryModifier::Cache(args, block)) } else if modifier == "load_cached" { // Parse a load_cached modifier like: // `load_cached(tcx, id) { tcx.queries.on_disk_cache.try_load_query_result(tcx, id) }` @@ -203,8 +209,8 @@ struct QueryModifiers { /// The description of the query. desc: Option<(Option, Punctuated)>, - /// Cache the query to disk if the `Expr` returns true. - cache: Option<(Option, Expr)>, + /// Cache the query to disk if the `Block` returns true. + cache: Option<(Option<(IdentOrWild, IdentOrWild)>, Block)>, /// Custom code to load the query from disk. load_cached: Option<(Ident, Ident, Block)>, @@ -247,11 +253,11 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers { } load_cached = Some((tcx, id, block)); } - QueryModifier::Cache(tcx, expr) => { + QueryModifier::Cache(args, expr) => { if cache.is_some() { panic!("duplicate modifier `cache` for query `{}`", query.name); } - cache = Some((tcx, expr)); + cache = Some((args, expr)); } QueryModifier::Desc(tcx, list) => { if desc.is_some() { @@ -321,7 +327,7 @@ fn add_query_description_impl( let key = &query.key.0; // Find out if we should cache the query on disk - let cache = modifiers.cache.as_ref().map(|(tcx, expr)| { + let cache = modifiers.cache.as_ref().map(|(args, expr)| { let try_load_from_disk = if let Some((tcx, id, block)) = modifiers.load_cached.as_ref() { // Use custom code to load the query from disk quote! { @@ -346,11 +352,22 @@ fn add_query_description_impl( } }; - let tcx = tcx.as_ref().map(|t| quote! { #t }).unwrap_or(quote! { _ }); + let tcx = args.as_ref().map(|t| { + let t = &(t.0).0; + quote! { #t } + }).unwrap_or(quote! { _ }); + let value = args.as_ref().map(|t| { + let t = &(t.1).0; + quote! { #t } + }).unwrap_or(quote! { _ }); quote! { #[inline] #[allow(unused_variables)] - fn cache_on_disk(#tcx: TyCtxt<'tcx>, #key: Self::Key) -> bool { + fn cache_on_disk( + #tcx: TyCtxt<'tcx>, + #key: Self::Key, + #value: Option<&Self::Value> + ) -> bool { #expr } @@ -395,6 +412,7 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { let mut query_description_stream = quote! {}; let mut dep_node_def_stream = quote! {}; let mut dep_node_force_stream = quote! {}; + let mut try_load_from_on_disk_cache_stream = quote! {}; let mut no_force_queries = Vec::new(); for group in groups.0 { @@ -409,6 +427,22 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { _ => quote! { #result_full }, }; + if modifiers.cache.is_some() && !modifiers.no_force { + try_load_from_on_disk_cache_stream.extend(quote! { + DepKind::#name => { + debug_assert!(tcx.dep_graph + .node_color(self) + .map(|c| c.is_green()) + .unwrap_or(false)); + + let key = RecoverKey::recover(tcx.global_tcx(), self).unwrap(); + if queries::#name::cache_on_disk(tcx.global_tcx(), key, None) { + let _ = tcx.#name(key); + } + } + }); + } + let mut attributes = Vec::new(); // Pass on the fatal_cycle modifier @@ -470,7 +504,11 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { }); } - add_query_description_impl(&query, modifiers, &mut query_description_stream); + add_query_description_impl( + &query, + modifiers, + &mut query_description_stream, + ); } let name = &group.name; query_stream.extend(quote! { @@ -520,5 +558,19 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { } } #query_description_stream + + impl DepNode { + /// Check whether the query invocation corresponding to the given + /// DepNode is eligible for on-disk-caching. If so, this is method + /// will execute the query corresponding to the given DepNode. + /// Also, as a sanity check, it expects that the corresponding query + /// invocation has been marked as green already. + pub fn try_load_from_on_disk_cache(&self, tcx: TyCtxt<'_>) { + match self.kind { + #try_load_from_on_disk_cache_stream + _ => (), + } + } + } }) } From fbfee70510e7b3e6ce454563e87bc04a42ab9de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Wed, 26 Jun 2019 10:16:56 +0200 Subject: [PATCH 2/3] Keep caching for non-promoted queries --- src/librustc/query/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 74114533faaa8..d2082ab87e738 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -496,6 +496,7 @@ rustc_queries! { query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName { no_force desc { "computing the symbol for `{}`", key } + cache_on_disk_if { true } } query def_kind(_: DefId) -> Option {} @@ -562,6 +563,7 @@ rustc_queries! { key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) ) -> Vtable<'tcx, ()> { no_force + cache_on_disk_if { true } desc { |tcx| "checking if `{}` fulfills its obligations", tcx.def_path_str(key.1.def_id()) From 6a5afdd9654adc73ba413414573227700dc82feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 27 Jun 2019 06:41:06 +0200 Subject: [PATCH 3/3] Store const_eval_raw results to disk --- src/librustc/query/mod.rs | 1 - src/librustc/ty/query/on_disk_cache.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index d2082ab87e738..85b1e91ee35c8 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -424,7 +424,6 @@ rustc_queries! { } 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()) } } diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 8b2183c42efd4..336caa391e40e 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -221,8 +221,8 @@ impl<'sess> OnDiskCache<'sess> { encode_query_results::, _>(tcx, enc, qri)?; encode_query_results::, _>(tcx, enc, qri)?; encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; encode_query_results::, _>(tcx, enc, qri)?; - // FIXME: Include const_eval_raw? Ok(()) })?;