summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2017-01-07 10:09:02 +0800
committerJohn Hodge <tpg@mutabah.net>2017-01-07 10:09:02 +0800
commitfc7d85e0f6005f6ef35b3ca94620896ed56fc6b8 (patch)
treece0fe2c4457f13c36655cdad730367d1dff0aa4d
parentfdd328057b3fcabea5ea35af3579c4f5283bba13 (diff)
downloadmrust-fc7d85e0f6005f6ef35b3ca94620896ed56fc6b8.tar.gz
Codegen C - is_dst fix
-rw-r--r--src/trans/codegen_c.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 6250d147..8d28a459 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -1259,6 +1259,7 @@ namespace {
bool special = false;
::HIR::TypeRef tmp;
const auto& ty = mir_res.get_lvalue_type(tmp, ve.val);
+ // If the destination is a thin pointer
if( ve.type.m_data.is_Pointer() && !is_dst( *ve.type.m_data.as_Pointer().inner ) )
{
// NOTE: Checks the result of the deref
@@ -2506,7 +2507,7 @@ namespace {
return ::HIR::TypeRef();
}
}
- MetadataType metadata_type(const ::HIR::TypeRef& ty)
+ MetadataType metadata_type(const ::HIR::TypeRef& ty) const
{
if( ty == ::HIR::CoreType::Str || ty.m_data.is_Slice() ) {
return MetadataType::Slice;
@@ -2579,16 +2580,9 @@ namespace {
}
}
- int is_dst(const ::HIR::TypeRef& ty) const
+ bool is_dst(const ::HIR::TypeRef& ty) const
{
- if( ty == ::HIR::CoreType::Str )
- return 1;
- if( ty.m_data.is_Slice() )
- return 1;
- if( ty.m_data.is_TraitObject() )
- return 2;
- // TODO: Unsized named types.
- return 0;
+ return metadata_type(ty) != MetadataType::None;
}
};
Span CodeGenerator_C::sp;