summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-28 21:06:57 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-28 21:06:57 +0800
commita008403477341808ace1dda16051a373059658dd (patch)
treee96f4ec3da30f24bf31c744356b00ba1a7d72eeb /src
parent2b580da3472e3f7f1bc79b3b0766c00010307453 (diff)
downloadmrust-a008403477341808ace1dda16051a373059658dd.tar.gz
Const Eval - Don't attempt to evaluate extern statics
Diffstat (limited to 'src')
-rw-r--r--src/hir_conv/constant_evaluation.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp
index 2d2736fe..967f209c 100644
--- a/src/hir_conv/constant_evaluation.cpp
+++ b/src/hir_conv/constant_evaluation.cpp
@@ -951,6 +951,7 @@ namespace {
void visit_constant(::HIR::ItemPath p, ::HIR::Constant& item) override
{
visit_type(item.m_type);
+ assert(item.m_value);
item.m_value_res = evaluate_constant(item.m_value->span(), m_crate, NewvalState { m_new_values, *m_mod_path, FMT(p.get_name() << "$") }, item.m_value, {});
DEBUG("constant: " << item.m_type << " = " << item.m_value_res);
visit_expr(item.m_value);
@@ -958,9 +959,12 @@ namespace {
void visit_static(::HIR::ItemPath p, ::HIR::Static& item) override
{
visit_type(item.m_type);
- item.m_value_res = evaluate_constant(item.m_value->span(), m_crate, NewvalState { m_new_values, *m_mod_path, FMT(p.get_name() << "$") }, item.m_value, {});
- DEBUG("static: " << item.m_type << " = " << item.m_value_res);
- visit_expr(item.m_value);
+ if( item.m_value )
+ {
+ item.m_value_res = evaluate_constant(item.m_value->span(), m_crate, NewvalState { m_new_values, *m_mod_path, FMT(p.get_name() << "$") }, item.m_value, {});
+ DEBUG("static: " << item.m_type << " = " << item.m_value_res);
+ visit_expr(item.m_value);
+ }
}
void visit_enum(::HIR::ItemPath p, ::HIR::Enum& item) override {
for(auto& var : item.m_variants)