From 46877e289087c67d03572019fca9792d95e55e0c Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Wed, 28 Aug 2019 20:18:25 -0400 Subject: [PATCH] Fix const eval bug breaking run-pass tests in Miri PR #63580 broke miri's ability to run the run-pass test suite with MIR optimizations enabled. The issue was that we weren't properly handling the substs and DefId associated with a Promoted value. This didn't break anything in rustc because in rustc this code runs before the Inliner pass which is where the DefId and substs can diverge from their initial values. It broke Miri though because it ran this code again after running the optimization pass. --- src/librustc_mir/interpret/place.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 23c9e7fdf67ce..f358bb00f4d12 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -585,8 +585,9 @@ where use rustc::mir::StaticKind; Ok(match place_static.kind { - StaticKind::Promoted(promoted, _) => { - let instance = self.frame().instance; + StaticKind::Promoted(promoted, promoted_substs) => { + let substs = self.subst_from_frame_and_normalize_erasing_regions(promoted_substs); + let instance = ty::Instance::new(place_static.def_id, substs); self.const_eval_raw(GlobalId { instance, promoted: Some(promoted),