Skip to content

Commit 9fa14e4

Browse files
committed
Skip checking for Storage* statements in constants/statics
1 parent 9839e5f commit 9fa14e4

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/librustc_mir/interpret/eval_context.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::fmt::Write;
22

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

389390
let mut locals = vec![Some(Value::ByVal(PrimVal::Undef)); num_locals];
390-
trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
391-
for block in mir.basic_blocks() {
392-
for stmt in block.statements.iter() {
393-
use rustc::mir::StatementKind::{StorageDead, StorageLive};
394-
match stmt.kind {
395-
StorageLive(local) | StorageDead(local) => if local.index() > 0 {
396-
locals[local.index() - 1] = None;
397-
},
398-
_ => {}
391+
match self.tcx.describe_def(instance.def_id()) {
392+
// statics and constants don't have `Storage*` statements, no need to look for them
393+
Some(Def::Static(..)) | Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => {},
394+
_ => {
395+
trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
396+
for block in mir.basic_blocks() {
397+
for stmt in block.statements.iter() {
398+
use rustc::mir::StatementKind::{StorageDead, StorageLive};
399+
match stmt.kind {
400+
StorageLive(local) | StorageDead(local) => if local.index() > 0 {
401+
locals[local.index() - 1] = None;
402+
},
403+
_ => {}
404+
}
405+
}
399406
}
400-
}
407+
},
401408
}
402409

403410
self.stack.push(Frame {

0 commit comments

Comments
 (0)