diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-21 19:18:14 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-21 19:18:14 +0800 |
commit | a751bd155143c38a5ffd2b2499227a89c2628226 (patch) | |
tree | 127f1c8d08db0b59392b4110e89130d39ff05fda /src | |
parent | 540853263dee7b53d5950e7a5d3c3d58c2806f87 (diff) | |
download | mrust-a751bd155143c38a5ffd2b2499227a89c2628226.tar.gz |
HIR Typecheck Expr - Allow coercing borrows to "lower" pointers (mut->const)
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 8427ce55..2f9bcaa8 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -3707,11 +3707,13 @@ namespace { (Pointer, // Pointers coerce from borrows and similar pointers TU_IFLET(::HIR::TypeRef::Data, ty_src.m_data, Borrow, s_e, - // TODO: Borrows can coerce to pointers while reducing in strength - if( s_e.type != l_e.type ) { + // Borrows can coerce to pointers while reducing in strength + // - Shared < Unique. If the destination is not weaker or equal to the source, it's an error + if( !(l_e.type <= s_e.type) ) { ERROR(sp, E0000, "Type mismatch between " << ty_dst << " and " << ty_src << " - Mutability not compatible"); } - // TODO: This can unsize as well as convert? + + // TODO: Can this can unsize as well as convert to raw? context.equate_types(sp, *l_e.inner, *s_e.inner); // Add downcast auto span = node_ptr->span(); |