Skip to content

Commit

Permalink
Rollup merge of #64100 - wesleywiser:fix_miri_const_eval, r=oli-obk
Browse files Browse the repository at this point in the history
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.

r? @oli-obk
cc @RalfJung
  • Loading branch information
Centril authored Sep 5, 2019
2 parents 2f8cbfc + 46877e2 commit d43b9f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit d43b9f3

Please sign in to comment.