about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2018-03-22 16:59:02 +0100
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2018-03-22 16:59:02 +0100
commit9fa14e47d4a14fcda4adff658ccfdda3c8b9005f (patch)
treec9b0f61ac8de050912897432886547a4178a6440 /src
parent9839e5fa103d117cbdb936e8594ba832e1eeb320 (diff)
downloadrust-9fa14e47d4a14fcda4adff658ccfdda3c8b9005f.tar.gz
rust-9fa14e47d4a14fcda4adff658ccfdda3c8b9005f.zip
Skip checking for Storage* statements in constants/statics
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/interpret/eval_context.rs27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index ee8419404ca..376c7f24058 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -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;
@@ -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 {