]> git.lizzy.rs Git - rust.git/commitdiff
Fix test error
authorbjorn3 <bjorn3@users.noreply.github.com>
Wed, 21 Mar 2018 13:34:46 +0000 (14:34 +0100)
committerbjorn3 <bjorn3@users.noreply.github.com>
Wed, 21 Mar 2018 13:43:07 +0000 (14:43 +0100)
src/librustc_mir/interpret/const_eval.rs

index 82eb28287b033c16c87e186421042ade8ff36138..47f6f61072e13acb232e5edc8c74249bf3fa56c0 100644 (file)
@@ -339,6 +339,14 @@ fn init_static<'a>(
         ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
         cid: GlobalId<'tcx>,
     ) -> EvalResult<'tcx, AllocId> {
+        let alloc = ecx
+                    .tcx
+                    .interpret_interner
+                    .get_cached(cid.instance.def_id());
+        // Don't evaluate when already cached to prevent cycles
+        if let Some(alloc) = alloc {
+            return Ok(alloc)
+        }
         // ensure the static is computed
         ecx.const_eval(cid)?;
         Ok(ecx