summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-07 15:23:11 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-07 15:23:11 +0800
commit343d70590763fb415495c2973f3cfd272e60a96a (patch)
tree00be69b836cd3f4a112235580efaec1b08de7fce /src
parent6bfa68684d38b86236fd308250fd93ebd8ad22f9 (diff)
downloadmrust-343d70590763fb415495c2973f3cfd272e60a96a.tar.gz
MIR Gen - Handle no-op casts
Diffstat (limited to 'src')
-rw-r--r--src/mir/from_hir.cpp9
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() ) {