|
1 | 1 | use std::fmt::Write;
|
2 | 2 |
|
3 | 3 | use rustc::hir::def_id::DefId;
|
| 4 | +use rustc::hir::def::Def; |
4 | 5 | use rustc::hir::map::definitions::DefPathData;
|
5 | 6 | use rustc::middle::const_val::{ConstVal, ErrKind};
|
6 | 7 | use rustc::mir;
|
@@ -387,17 +388,23 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
|
387 | 388 | let num_locals = mir.local_decls.len() - 1;
|
388 | 389 |
|
389 | 390 | 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 | + } |
399 | 406 | }
|
400 |
| - } |
| 407 | + }, |
401 | 408 | }
|
402 | 409 |
|
403 | 410 | self.stack.push(Frame {
|
|
0 commit comments