about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>2017-07-14 17:46:28 +0200
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>2017-07-14 17:46:28 +0200
commit45ab975610d67f2fe6d55bc4ea0d72d80e5083ac (patch)
tree092a748f6a48b70268aada95a5dc2d5dd661ca52 /src
parent2e562a4d642736f78f52292feb05a5a1048de7d5 (diff)
downloadrust-45ab975610d67f2fe6d55bc4ea0d72d80e5083ac.tar.gz
rust-45ab975610d67f2fe6d55bc4ea0d72d80e5083ac.zip
Add a comment explaining the static "local" during `deallocate_local`
Diffstat (limited to 'src')
-rw-r--r--src/eval_context.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/eval_context.rs b/src/eval_context.rs
index 07f63fad6cf..2f28063ff86 100644
--- a/src/eval_context.rs
+++ b/src/eval_context.rs
@@ -414,7 +414,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
             let ptr = ptr.to_ptr()?;
             self.memory.dump_alloc(ptr.alloc_id);
             match self.memory.get(ptr.alloc_id)?.kind {
-                ::memory::Kind::Static | ::memory::Kind::UninitializedStatic => {},
+                // for a constant like `const FOO: &i32 = &1;` the local containing
+                // the `1` is referred to by the global. We transitively marked everything
+                // the global refers to as static itself, so we don't free it here
+                ::memory::Kind::Static => {}
                 ::memory::Kind::Stack => self.memory.deallocate(ptr, None, ::memory::Kind::Stack)?,
                 other => bug!("local contained non-stack memory: {:?}", other),
             }