From a0e057540eb996ea43ba5e0dce2b69fa972f718f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 9 Aug 2020 17:47:29 +0200 Subject: [PATCH] evaluate required_consts when pushing stack frame in Miri engine --- src/librustc_mir/interpret/eval_context.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index fc192cd9b3c..7c2f749c156 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -652,6 +652,13 @@ pub fn push_stack_frame( let frame = M::init_frame_extra(self, pre_frame)?; self.stack_mut().push(frame); + // Make sure all the constants required by this frame evaluate successfully (post-monomorphization check). + for const_ in &body.required_consts { + let const_ = + self.subst_from_current_frame_and_normalize_erasing_regions(const_.literal); + self.const_to_op(const_, None)?; + } + // Locals are initially uninitialized. let dummy = LocalState { value: LocalValue::Uninitialized, layout: Cell::new(None) }; let mut locals = IndexVec::from_elem(dummy, &body.local_decls);