diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-07 15:23:11 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-07 15:23:11 +0800 |
commit | 343d70590763fb415495c2973f3cfd272e60a96a (patch) | |
tree | 00be69b836cd3f4a112235580efaec1b08de7fce /src | |
parent | 6bfa68684d38b86236fd308250fd93ebd8ad22f9 (diff) | |
download | mrust-343d70590763fb415495c2973f3cfd272e60a96a.tar.gz |
MIR Gen - Handle no-op casts
Diffstat (limited to 'src')
-rw-r--r-- | src/mir/from_hir.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index 8ff72d50..6d801007 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -767,14 +767,19 @@ namespace { { TRACE_FUNCTION_F("_Cast"); this->visit_node_ptr(node.m_value); - auto val = m_builder.get_result_in_lvalue(node.m_value->span(), node.m_value->m_res_type); const auto& ty_out = node.m_res_type; const auto& ty_in = node.m_value->m_res_type; + if( ty_out == ty_in ) { + return ; + } + + auto val = m_builder.get_result_in_lvalue(node.m_value->span(), node.m_value->m_res_type); + TU_MATCH_DEF( ::HIR::TypeRef::Data, (ty_out.m_data), (de), ( - BUG(node.span(), "Invalid cast to " << ty_out); + BUG(node.span(), "Invalid cast to " << ty_out << " from " << ty_in); ), (Pointer, if( ty_in.m_data.is_Primitive() ) { |