From cd4f12dd46d26e59bbdfc1f83c815c0af5c46307 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 12 Jul 2016 18:20:10 +1000 Subject: HIR Typecheck CS - Allow casts from fn-types to `*const ()` --- src/hir_typeck/expr_cs.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index db86900e..c98d9c59 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -1312,7 +1312,15 @@ namespace { (Pointer, TU_MATCH_DEF( ::HIR::TypeRef::Data, (src_ty.m_data), (s_e), ( - ERROR(sp, E0000, "Invalid cast to pointer"); + ERROR(sp, E0000, "Invalid cast to pointer from " << src_ty); + ), + (Function, + if( e.type == ::HIR::BorrowType::Shared && *e.inner == ::HIR::TypeRef::new_unit() ) { + this->m_completed = true; + } + else { + ERROR(sp, E0000, "Invalid cast to pointer from " << src_ty); + } ), (Primitive, if( s_e != ::HIR::CoreType::Usize ) { -- cgit v1.2.3