From 5766e71fa7b3378d0b30d026eae23293e8e8bb32 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Tue, 13 Mar 2018 21:36:49 -0400 Subject: [PATCH] Cache the specialization_graph query Fixes #48987 --- src/librustc/traits/specialize/specialization_graph.rs | 2 ++ src/librustc/ty/fast_reject.rs | 2 +- src/librustc/ty/maps/config.rs | 1 + src/librustc/ty/maps/on_disk_cache.rs | 1 + src/librustc/ty/maps/plumbing.rs | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index f8b895177f381..e0d662657b7de 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -36,6 +36,7 @@ use util::nodemap::{DefIdMap, FxHashMap}; /// parents of a given specializing impl, which is needed for extracting /// default items amongst other things. In the simple "chain" rule, every impl /// has at most one parent. +#[derive(RustcEncodable, RustcDecodable)] pub struct Graph { // all impls have a parent; the "root" impls have as their parent the def_id // of the trait @@ -47,6 +48,7 @@ pub struct Graph { /// Children of a given impl, grouped into blanket/non-blanket varieties as is /// done in `TraitDef`. +#[derive(RustcEncodable, RustcDecodable)] struct Children { // Impls of a trait (or specializations of a given impl). To allow for // quicker lookup, the impls are indexed by a simplified version of their diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index 93d8a4d979de6..889648a46be12 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -28,7 +28,7 @@ pub type SimplifiedType = SimplifiedTypeGen; /// because we sometimes need to use SimplifiedTypeGen values as stable sorting /// keys (in which case we use a DefPathHash as id-type) but in the general case /// the non-stable but fast to construct DefId-version is the better choice. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, RustcEncodable, RustcDecodable)] pub enum SimplifiedTypeGen where D: Copy + Debug + Ord + Eq + Hash { diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 11675f542873d..008e3b7d85969 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -721,3 +721,4 @@ impl_disk_cacheable_query!(type_of, |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!(trans_fn_attrs, |_| true); +impl_disk_cacheable_query!(specialization_graph_of, |_| true); diff --git a/src/librustc/ty/maps/on_disk_cache.rs b/src/librustc/ty/maps/on_disk_cache.rs index 35e874b74d9ae..e7dd4c82254c0 100644 --- a/src/librustc/ty/maps/on_disk_cache.rs +++ b/src/librustc/ty/maps/on_disk_cache.rs @@ -221,6 +221,7 @@ 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)?; // const eval is special, it only encodes successfully evaluated constants use ty::maps::plumbing::GetCacheInternal; diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index bc7186f781a82..0bff13a71e39d 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -1001,4 +1001,5 @@ impl_load_from_cache!( PredicatesOfItem => predicates_of, UsedTraitImports => used_trait_imports, TransFnAttrs => trans_fn_attrs, + SpecializationGraph => specialization_graph_of, );