Skip to content

Commit

Permalink
Skip checking for Storage* statements in constants/statics
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 22, 2018
1 parent 9839e5f commit 9fa14e4
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::fmt::Write;

use rustc::hir::def_id::DefId;
use rustc::hir::def::Def;
use rustc::hir::map::definitions::DefPathData;
use rustc::middle::const_val::{ConstVal, ErrKind};
use rustc::mir;
Expand Down Expand Up @@ -387,17 +388,23 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
let num_locals = mir.local_decls.len() - 1;

let mut locals = vec![Some(Value::ByVal(PrimVal::Undef)); num_locals];
trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
for block in mir.basic_blocks() {
for stmt in block.statements.iter() {
use rustc::mir::StatementKind::{StorageDead, StorageLive};
match stmt.kind {
StorageLive(local) | StorageDead(local) => if local.index() > 0 {
locals[local.index() - 1] = None;
},
_ => {}
match self.tcx.describe_def(instance.def_id()) {
// statics and constants don't have `Storage*` statements, no need to look for them
Some(Def::Static(..)) | Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => {},
_ => {
trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
for block in mir.basic_blocks() {
for stmt in block.statements.iter() {
use rustc::mir::StatementKind::{StorageDead, StorageLive};
match stmt.kind {
StorageLive(local) | StorageDead(local) => if local.index() > 0 {
locals[local.index() - 1] = None;
},
_ => {}
}
}
}
}
},
}

self.stack.push(Frame {
Expand Down

0 comments on commit 9fa14e4

Please sign in to comment.