diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-27 12:53:31 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-27 12:53:31 +0800 |
commit | 5fbfd267b54e243ebe2ad3820d75359d7ed95988 (patch) | |
tree | c55f8a72a2c25d9cee659b33f11232ffe130dd65 /src/mir/from_hir.cpp | |
parent | 93f6bc5fa72608ea8f032a429ae4d1613befc04c (diff) | |
download | mrust-5fbfd267b54e243ebe2ad3820d75359d7ed95988.tar.gz |
HIR Typecheck - Support casting all integers to pointers
Diffstat (limited to 'src/mir/from_hir.cpp')
-rw-r--r-- | src/mir/from_hir.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index 586a152e..7ead584c 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -777,7 +777,19 @@ namespace { BUG(node.span(), "Invalid cast to " << ty_out); ), (Pointer, - if( ty_in.m_data.is_Primitive() && ty_in.m_data.as_Primitive() == ::HIR::CoreType::Usize ) { + if( ty_in.m_data.is_Primitive() ) { + const auto& ie = ty_in.m_data.as_Primitive(); + switch(ie) + { + case ::HIR::CoreType::Bool: + case ::HIR::CoreType::Char: + case ::HIR::CoreType::Str: + case ::HIR::CoreType::F32: + case ::HIR::CoreType::F64: + BUG(node.span(), "Cannot cast to pointer from " << ty_in); + default: + break; + } // TODO: Only valid if T: Sized in *{const/mut/move} T } else TU_IFLET( ::HIR::TypeRef::Data, ty_in.m_data, Borrow, se, |