diff options
author | John Hodge <tpg@mutabah.net> | 2017-01-05 22:42:52 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-01-05 22:42:52 +0800 |
commit | 15d9f1afe308055475384b28ca5952311729603c (patch) | |
tree | bd3b3a15fc030f155db30ecd4c44a08f07786609 /src | |
parent | 6bdaa38d2911132cebe40a1fd36a49b388e8a7dc (diff) | |
download | mrust-15d9f1afe308055475384b28ca5952311729603c.tar.gz |
MIR Cleanup - Raw pointers are valid for DstMeta
Diffstat (limited to 'src')
-rw-r--r-- | src/mir/cleanup.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mir/cleanup.cpp b/src/mir/cleanup.cpp index 267667db..89de457e 100644 --- a/src/mir/cleanup.cpp +++ b/src/mir/cleanup.cpp @@ -919,8 +919,17 @@ void MIR_Cleanup(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path, // If the type is an array (due to a monomorpised generic?) then replace. ::HIR::TypeRef tmp; const auto& ty = state.get_lvalue_type(tmp, re.val); - const auto& ity = *ty.m_data.as_Borrow().inner; - if( const auto* te = ity.m_data.opt_Array() ) { + const ::HIR::TypeRef* ity_p; + if( const auto* te = ty.m_data.opt_Borrow() ) { + ity_p = &*te->inner; + } + else if( const auto* te = ty.m_data.opt_Pointer() ) { + ity_p = &*te->inner; + } + else { + BUG(Span(), "Unexpected input type for DstMeta - " << ty); + } + if( const auto* te = ity_p->m_data.opt_Array() ) { se.src = ::MIR::Constant::make_Uint( te->size_val ); } ), |