]> git.lizzy.rs Git - rust.git/commitdiff
Cache `eval_to_allocation_raw` on disk
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 21 Sep 2020 09:38:39 +0000 (11:38 +0200)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 21 Sep 2020 09:38:39 +0000 (11:38 +0200)
compiler/rustc_middle/src/mir/interpret/value.rs
compiler/rustc_middle/src/query/mod.rs

index 1f547d9dc3a43a44b2fe8837a90f9ab754192da4..206f01c2498286dd1283d15af60aa365dd51a158 100644 (file)
@@ -13,7 +13,7 @@
 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`).
index c0a606a586b6b5b549a458584b5f5512f88d3085..b181c3b05af218d632c3d73c638aa883b03ab8f5 100644 (file)
@@ -716,6 +716,10 @@ fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
                 "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