summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-07-09 15:51:54 +1000
committerJohn Hodge <tpg@mutabah.net>2016-07-09 15:51:54 +1000
commit1b3f1ea19e20a5e799e3c1325db99afcd82dede3 (patch)
tree2c4342ad59402856530771b7d275db57fb7e1e59 /src
parenta8df1eb68bfe5e267f2bbb49b354854ce4959ed0 (diff)
downloadmrust-1b3f1ea19e20a5e799e3c1325db99afcd82dede3.tar.gz
HIR Typecheck CS - Support raw pointer deref
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr_cs.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 4c5e15bd..705cafd1 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -627,8 +627,7 @@ namespace {
TRACE_FUNCTION_F(&node << " *...");
this->context.add_ivars( node.m_value->m_res_type );
- const auto& op_trait = this->context.m_crate.get_lang_item_path(node.span(), "deref");
- this->context.equate_types_assoc(node.span(), node.m_res_type, op_trait, {}, node.m_value->m_res_type.clone(), "Target");
+ this->context.add_revisit(node);
node.m_value->visit( *this );
}
@@ -1387,7 +1386,27 @@ namespace {
}
}
void visit(::HIR::ExprNode_Deref& node) override {
- no_revisit(node);
+ const auto& ty = this->context.get_type(node.m_value->m_res_type);
+
+ TU_MATCH_DEF(::HIR::TypeRef::Data, (ty.m_data), (e),
+ (
+ const auto& op_trait = this->context.m_crate.get_lang_item_path(node.span(), "deref");
+ this->context.equate_types_assoc(node.span(), node.m_res_type, op_trait, {}, node.m_value->m_res_type.clone(), "Target");
+ ),
+ (Infer,
+ // Keep trying
+ return ;
+ ),
+ (Borrow,
+ // - Not really needed, but this is cheaper.
+ this->context.equate_types(node.span(), node.m_res_type, *e.inner);
+ ),
+ (Pointer,
+ // TODO: Figure out if this node is in an unsafe block.
+ this->context.equate_types(node.span(), node.m_res_type, *e.inner);
+ )
+ )
+ this->m_completed = true;
}
void visit(::HIR::ExprNode_TupleVariant& node) override {