summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-06 11:16:42 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-06 11:16:42 +0800
commit4492443559b1795aa1d0c3fc1887f72fc78af468 (patch)
treec8e3c64f1b6aadf4bf064f9aa8885067d2c8ac1b
parent88039f7100b9ce9b831a0cc4d09c5b479c41c58a (diff)
downloadmrust-4492443559b1795aa1d0c3fc1887f72fc78af468.tar.gz
HIR Typecheck CS - Add cast when &T used for *const T
-rw-r--r--src/hir_typeck/expr_cs.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index af50c6d9..b73d926b 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -3243,6 +3243,12 @@ namespace {
// Pointers coerce from borrows and similar pointers
TU_IFLET(::HIR::TypeRef::Data, ty_src.m_data, Borrow, r_e,
context.equate_types(sp, *l_e.inner, *r_e.inner);
+ // Add cast
+ auto span = node_ptr->span();
+ node_ptr = ::HIR::ExprNodeP(new ::HIR::ExprNode_Cast( mv$(span), mv$(node_ptr), ty_dst.clone() ));
+ node_ptr->m_res_type = ty_dst.clone();
+
+ context.m_ivars.mark_change();
return true;
)
else TU_IFLET(::HIR::TypeRef::Data, ty_src.m_data, Pointer, r_e,