summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-06 17:26:56 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-06 17:26:56 +0800
commitddaddbad7227febdfae053dade5f31279ada8a97 (patch)
tree39cb43c18aaa37d78f71c4d85712608afcbc52f8 /src
parent80185f0d7b674e85c9c3db72ee23bd99aefcdd25 (diff)
downloadmrust-ddaddbad7227febdfae053dade5f31279ada8a97.tar.gz
HIR Typecheck Validate - More cast rules
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/expr_check.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/hir_typeck/expr_check.cpp b/src/hir_typeck/expr_check.cpp
index af2e2e76..b6d41154 100644
--- a/src/hir_typeck/expr_check.cpp
+++ b/src/hir_typeck/expr_check.cpp
@@ -251,6 +251,16 @@ namespace {
(Pointer,
// TODO: Sized check - can't cast to a fat pointer from a thin one
),
+ (Primitive,
+ if( se != ::HIR::CoreType::Usize ) {
+ ERROR(sp, E0000, "Invalid cast to " << dst_ty << " from " << src_ty);
+ }
+ ),
+ (Function,
+ if( de.type != ::HIR::BorrowType::Shared || *de.inner != ::HIR::TypeRef::new_unit() ) {
+ ERROR(sp, E0000, "Invalid cast to " << dst_ty << " from " << src_ty);
+ }
+ ),
(Borrow,
this->check_types_equal(sp, *de.inner, *se.inner);
)