summaryrefslogtreecommitdiff
path: root/src/hir/hir_ops.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2019-10-22 21:22:54 +0800
committerJohn Hodge <tpg@mutabah.net>2019-10-22 21:22:54 +0800
commit64e60f872d04053b43afb7b7eb164c3ffd6dbcfb (patch)
treefc59d8461d4e5f0f13b2ebee36e3a4022acf5067 /src/hir/hir_ops.cpp
parentd413820fa8bedf5e9dab047e4dd45a6f57d62eef (diff)
downloadmrust-64e60f872d04053b43afb7b7eb164c3ffd6dbcfb.tar.gz
HIR Const Eval - Ensure that requisite items are constevaled before attempting downstream
Diffstat (limited to 'src/hir/hir_ops.cpp')
-rw-r--r--src/hir/hir_ops.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/hir/hir_ops.cpp b/src/hir/hir_ops.cpp
index a548b725..f187bafe 100644
--- a/src/hir/hir_ops.cpp
+++ b/src/hir/hir_ops.cpp
@@ -11,6 +11,7 @@
#include <hir_typeck/expr_visit.hpp> // for invoking typecheck
#include "item_path.hpp"
#include "expr_state.hpp"
+#include <hir_conv/main_bindings.hpp>
#include <hir_expand/main_bindings.hpp>
#include <mir/main_bindings.hpp>
@@ -1087,6 +1088,16 @@ const ::MIR::Function* HIR::Crate::get_or_gen_mir(const ::HIR::ItemPath& ip, con
auto& ep_mut = const_cast<::HIR::ExprPtr&>(ep);
+ // TODO: Ensure that all referenced items have constants evaluated
+ if( ep.m_state->stage < ::HIR::ExprState::Stage::ConstEval )
+ {
+ if( ep.m_state->stage == ::HIR::ExprState::Stage::ConstEvalRequest )
+ ERROR(Span(), E0000, "Loop in constant evaluation");
+ ep.m_state->stage = ::HIR::ExprState::Stage::ConstEvalRequest;
+ ConvertHIR_ConstantEvaluate_Expr(*this, ip, ep_mut);
+ ep.m_state->stage = ::HIR::ExprState::Stage::ConstEval;
+ }
+
// Ensure typechecked
if( ep.m_state->stage < ::HIR::ExprState::Stage::Typecheck )
{