diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-04 15:18:47 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-04 15:18:47 +0800 |
commit | 2d58f74a1453646f330f4c83c1a421429bf6fc9e (patch) | |
tree | 665b0241b38a173bc48e3432a1886dfcb676ff78 /src | |
parent | 15281cae87f6715e452d683f6a4d0d8c3a63a62a (diff) | |
download | mrust-2d58f74a1453646f330f4c83c1a421429bf6fc9e.tar.gz |
HIR Typecheck Expr - Edge case for coercions
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 4ffd4b2a..350ac042 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -3088,11 +3088,16 @@ namespace { if( context.m_ivars.types_equal(ty_dst, *out_ty) == false ) { // Check equivalence + if( ty_dst.m_data.tag() == out_ty->m_data.tag() ) { TU_MATCH_DEF( ::HIR::TypeRef::Data, (ty_dst.m_data, out_ty->m_data), (d_e, s_e), ( - DEBUG(""); - continue ; + if( ty_dst .compare_with_placeholders(sp, *out_ty, context.m_ivars.callback_resolve_infer()) == ::HIR::Compare::Unequal ) { + DEBUG("Same tag, but not fuzzy match"); + continue ; + } + DEBUG("Same tag and fuzzy match - assuming " << ty_dst << " == " << *out_ty); + context.equate_types(sp, ty_dst, *out_ty); ), (Slice, // Equate! @@ -3208,6 +3213,13 @@ namespace { } DEBUG("TODO - Borrow Coercion " << context.m_ivars.fmt_type(ty_dst) << " from " << context.m_ivars.fmt_type(ty_src)); + if( ty_dst.compare_with_placeholders(sp, ty_src, context.m_ivars.callback_resolve_infer()) != ::HIR::Compare::Unequal ) + { + context.equate_types(sp, ty_dst, ty_src); + return true; + } + + // Keep trying return false; } bool check_coerce(Context& context, const Context::Coercion& v) { |