From: bjorn3 Date: Wed, 21 Mar 2018 13:34:46 +0000 (+0100) Subject: Fix test error X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=5aa29c4c823cbe02a2d84080eefe3eb1aecf0a06;p=rust.git Fix test error --- diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs index 82eb28287b0..47f6f61072e 100644 --- a/src/librustc_mir/interpret/const_eval.rs +++ b/src/librustc_mir/interpret/const_eval.rs @@ -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