diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-22 15:59:39 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-22 16:00:27 +0800 |
commit | 226cc4db3cb1bfe8c5abc8ae2247c561b1111559 (patch) | |
tree | 852eccf92552c879da73d38713d2f7a194bab9da | |
parent | 8fbd89944343d479977d2c8d0b0f3fb329299763 (diff) | |
download | mrust-226cc4db3cb1bfe8c5abc8ae2247c561b1111559.tar.gz |
MIR Gen - Don't emit no-op unsizing casts
-rw-r--r-- | src/mir/from_hir.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index e5e11404..95c664b2 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -976,11 +976,16 @@ namespace { { TRACE_FUNCTION_F("_Unsize"); this->visit_node_ptr(node.m_value); - auto ptr_lval = 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 ptr_lval = m_builder.get_result_in_lvalue(node.m_value->span(), node.m_value->m_res_type); + if( ty_out.m_data.is_Borrow() && ty_in.m_data.is_Borrow() ) { const auto& oe = ty_out.m_data.as_Borrow(); |