Skip to content

Commit 46877e2

Browse files
committedSep 2, 2019
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.
1 parent fdaf594 commit 46877e2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎src/librustc_mir/interpret/place.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,9 @@ where
585585
use rustc::mir::StaticKind;
586586

587587
Ok(match place_static.kind {
588-
StaticKind::Promoted(promoted, _) => {
589-
let instance = self.frame().instance;
588+
StaticKind::Promoted(promoted, promoted_substs) => {
589+
let substs = self.subst_from_frame_and_normalize_erasing_regions(promoted_substs);
590+
let instance = ty::Instance::new(place_static.def_id, substs);
590591
self.const_eval_raw(GlobalId {
591592
instance,
592593
promoted: Some(promoted),

0 commit comments

Comments
 (0)
Please sign in to comment.