summaryrefslogtreecommitdiff
path: root/src/mir/cleanup.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2017-01-07 08:55:27 +0800
committerJohn Hodge <tpg@mutabah.net>2017-01-07 08:55:27 +0800
commit2f9bf5b3e3df34cd7a58dff72f0e7e0dd490c92a (patch)
tree5a9c25bc8a0ab2198c09dc523a13fab71a2047cb /src/mir/cleanup.cpp
parentbaf9ba776242192d4bf7eb81a58932a141605df0 (diff)
downloadmrust-2f9bf5b3e3df34cd7a58dff72f0e7e0dd490c92a.tar.gz
MIR Cleanup - Box deref destructuring in virtualisation
Diffstat (limited to 'src/mir/cleanup.cpp')
-rw-r--r--src/mir/cleanup.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mir/cleanup.cpp b/src/mir/cleanup.cpp
index 12f4149b..aded2beb 100644
--- a/src/mir/cleanup.cpp
+++ b/src/mir/cleanup.cpp
@@ -67,6 +67,8 @@ struct MirMutator
}
};
+void MIR_Cleanup_LValue(const ::MIR::TypeResolve& state, MirMutator& mutator, ::MIR::LValue& lval);
+
const ::HIR::Literal* MIR_Cleanup_GetConstant(const Span& sp, const StaticTraitResolve& resolve, const ::HIR::Path& path, ::HIR::TypeRef& out_ty)
{
TU_MATCHA( (path.m_data), (pe),
@@ -437,7 +439,9 @@ const ::HIR::Literal* MIR_Cleanup_GetConstant(const Span& sp, const StaticTraitR
// Allocate a temporary for the vtable pointer itself
auto vtable_lv = mutator.new_temporary( mv$(vtable_ty) );
// - Load the vtable and store it
- auto vtable_rval = ::MIR::RValue::make_DstMeta({ receiver_lvp.clone() });
+ auto ptr_lv = ::MIR::LValue::make_Deref({ box$(receiver_lvp.clone()) });
+ MIR_Cleanup_LValue(state, mutator, ptr_lv);
+ auto vtable_rval = ::MIR::RValue::make_DstMeta({ mv$(*ptr_lv.as_Deref().val) });
mutator.push_statement( ::MIR::Statement::make_Assign({ vtable_lv.clone(), mv$(vtable_rval) }) );
auto fcn_lval = ::MIR::LValue::make_Field({ box$(::MIR::LValue::make_Deref({ box$(vtable_lv) })), vtable_idx });