diff options
author | John Hodge <tpg@mutabah.net> | 2016-07-07 06:01:52 +1000 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-07-07 06:01:52 +1000 |
commit | d03c31318ac1dc03094a690046cbc93ab5b39f51 (patch) | |
tree | f97d2e502fb6e1ed5ffa58a905dd1f3a0d21b5cc /src | |
parent | 977be3a912941e5cc944ea6870b50d13937c9f27 (diff) | |
download | mrust-d03c31318ac1dc03094a690046cbc93ab5b39f51.tar.gz |
HIR Typecheck CS - Closure handling in equate_types and type.cpp
Diffstat (limited to 'src')
-rw-r--r-- | src/hir/type.cpp | 26 | ||||
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 12 |
2 files changed, 35 insertions, 3 deletions
diff --git a/src/hir/type.cpp b/src/hir/type.cpp index 58530a76..7431ff9d 100644 --- a/src/hir/type.cpp +++ b/src/hir/type.cpp @@ -653,10 +653,32 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x return le.inner->compare_with_placeholders(sp, *re.inner, resolve_placeholder); ), (Function, - TODO(sp, "Compare " << *this << " and " << right); + if( le.m_abi != re.m_abi || le.is_unsafe != re.is_unsafe ) + return Compare::Unequal; + if( le.m_arg_types.size() != re.m_arg_types.size() ) + return Compare::Unequal; + auto rv = Compare::Equal; + for( unsigned int i = 0; i < le.m_arg_types.size(); i ++ ) + { + rv &= le.m_arg_types[i].compare_with_placeholders( sp, re.m_arg_types[i], resolve_placeholder ); + if( rv == Compare::Unequal ) + return Compare::Unequal; + } + rv &= le.m_rettype->compare_with_placeholders( sp, *re.m_rettype, resolve_placeholder ); + return rv; ), (Closure, - TODO(sp, "Compare " << *this << " and " << right); + if( le.m_arg_types.size() != re.m_arg_types.size() ) + return Compare::Unequal; + auto rv = Compare::Equal; + for( unsigned int i = 0; i < le.m_arg_types.size(); i ++ ) + { + rv &= le.m_arg_types[i].compare_with_placeholders( sp, re.m_arg_types[i], resolve_placeholder ); + if( rv == Compare::Unequal ) + return Compare::Unequal; + } + rv &= le.m_rettype->compare_with_placeholders( sp, *re.m_rettype, resolve_placeholder ); + return rv; ) ) throw ""; diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index d0f15d10..2bac66ea 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -1735,7 +1735,14 @@ void Context::equate_types(const Span& sp, const ::HIR::TypeRef& li, const ::HIR } ), (Closure, - TODO(sp, "apply_equality - Closure"); + if( l_e.m_arg_types.size() != r_e.m_arg_types.size() ) { + ERROR(sp, E0000, "Type mismatch between " << l_t << " and " << r_t); + } + this->equate_types(sp, *l_e.m_rettype, *r_e.m_rettype); + for( unsigned int i = 0; i < l_e.m_arg_types.size(); i ++ ) + { + this->equate_types(sp, l_e.m_arg_types[i], r_e.m_arg_types[i]); + } ) ) } @@ -2588,6 +2595,9 @@ namespace { // No applicable impl // - TODO: This should really only fire when there isn't an impl. But it currently fires when _ DEBUG("No impl of " << v.trait << v.params << " for " << v.impl_ty); + //if( !context.m_ivars.type_contains_ivars(v.impl_ty) ) { + // ERROR(sp, E0000, "Failed to find an impl of " << v.trait << v.params << " for " << context.m_ivars.fmt_type(v.impl_ty)); + //} return false; } else if( count == 1 ) { |