summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-21 17:40:56 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-21 17:40:56 +0800
commit6a293dffc754462c870f371b69a823b34198e894 (patch)
tree1b90782342d33cf36bc1dfe35f5d70708d90051c /src
parentd28ef52c6424d04662bf4070d263b2bd10e132a0 (diff)
downloadmrust-6a293dffc754462c870f371b69a823b34198e894.tar.gz
MIR Gen - Mark values used in calls as moved
Diffstat (limited to 'src')
-rw-r--r--src/mir/from_hir.cpp4
-rw-r--r--src/mir/from_hir.hpp4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 3a85ebbd..ba8bb7a1 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -1015,9 +1015,10 @@ namespace {
{
this->visit_node_ptr(arg);
values.push_back( m_builder.lvalue_or_temp( arg->m_res_type, m_builder.get_result(arg->span()) ) );
+ m_builder.moved_lvalue( values.back() );
}
- // TODO: Obtain function type for this function
+ // TODO: Obtain function type for this function (i.e. a type that is specifically for this function)
auto fcn_ty_data = ::HIR::FunctionType {
false,
"",
@@ -1063,6 +1064,7 @@ namespace {
{
this->visit_node_ptr(arg);
values.push_back( m_builder.lvalue_or_temp( arg->m_res_type, m_builder.get_result(arg->span()) ) );
+ m_builder.moved_lvalue( values.back() );
}
diff --git a/src/mir/from_hir.hpp b/src/mir/from_hir.hpp
index 47bdfb5d..7ade2b6d 100644
--- a/src/mir/from_hir.hpp
+++ b/src/mir/from_hir.hpp
@@ -144,6 +144,8 @@ public:
/// Introduce a new variable within the current scope
void define_variable(unsigned int idx);
+ // Helper - Marks a variable/... as moved (and checks if the move is valid)
+ void moved_lvalue(const ::MIR::LValue& lv);
private:
VarState get_variable_state(unsigned int idx) const;
void set_variable_state(unsigned int idx, VarState state);
@@ -152,8 +154,6 @@ private:
void drop_scope_values(const ScopeDef& sd);
void complete_scope(ScopeDef& sd);
- // Helper - Marks a variable/... as moved (and checks if the move is valid)
- void moved_lvalue(const ::MIR::LValue& lv);
void with_val_type(const ::MIR::LValue& val, ::std::function<void(const ::HIR::TypeRef&)> cb);
bool lvalue_is_copy(const ::MIR::LValue& lv);