about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-09-21 11:38:39 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-09-21 11:38:39 +0200
commitc160bf3c3ef4434d76cc4d093b34e9bb1fdab2a1 (patch)
tree7c3289ba51b2a97acff5c208553580de21f01c6b
parent70148d7b3161912381b1a5c427c3a690e12c5b24 (diff)
downloadrust-c160bf3c3ef4434d76cc4d093b34e9bb1fdab2a1.tar.gz
rust-c160bf3c3ef4434d76cc4d093b34e9bb1fdab2a1.zip
Cache `eval_to_allocation_raw` on disk
-rw-r--r--compiler/rustc_middle/src/mir/interpret/value.rs2
-rw-r--r--compiler/rustc_middle/src/query/mod.rs4
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs
index 1f547d9dc3a..206f01c2498 100644
--- a/compiler/rustc_middle/src/mir/interpret/value.rs
+++ b/compiler/rustc_middle/src/mir/interpret/value.rs
@@ -13,7 +13,7 @@ use crate::ty::{ParamEnv, Ty, TyCtxt};
 use super::{sign_extend, truncate, AllocId, Allocation, InterpResult, Pointer, PointerArithmetic};
 
 /// Represents the result of const evaluation via the `eval_to_allocation` query.
-#[derive(Clone, HashStable)]
+#[derive(Clone, HashStable, TyEncodable, TyDecodable)]
 pub struct ConstAlloc<'tcx> {
     // the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
     // (so you can use `AllocMap::unwrap_memory`).
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index c0a606a586b..b181c3b05af 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -716,6 +716,10 @@ rustc_queries! {
                 "const-evaluating + checking `{}`",
                 key.value.display(tcx)
             }
+            cache_on_disk_if(_, opt_result) {
+                // Only store results without errors
+                opt_result.map_or(true, |r| r.is_ok())
+            }
         }
 
         /// Evaluates const items or anonymous constants