diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-22 19:27:50 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-22 19:27:50 +0800 |
commit | c0755f1d37b4e49815cf7c20a9ab27ff3f96dba0 (patch) | |
tree | 80211231a1fd5dac92d996cb61e26570057ad3ac /src | |
parent | 1806e3626bd756811ab9cbbba8ee8d418089a0a7 (diff) | |
download | mrust-c0755f1d37b4e49815cf7c20a9ab27ff3f96dba0.tar.gz |
HIR Typecheck Expr - If an Unsize bound fails, equate the types
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 14b40cc8..091a6c56 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -4585,14 +4585,24 @@ namespace { //bool is_known = !context.m_ivars.type_contains_ivars(v.impl_ty); //for(const auto& t : v.params.m_types) // is_known &= !context.m_ivars.type_contains_ivars(t); - if( is_known ) { + if( !is_known ) + { + // There's still an ivar (or an unbound UFCS), keep trying + return false; + } + else if( v.trait == context.m_crate.get_lang_item_path(sp, "unsize") ) + { + ASSERT_BUG(sp, v.params.m_types.size() == 1, "Incorrect number of parameters for Unsize"); + const auto& src_ty = context.get_type(v.impl_ty); + const auto& dst_ty = context.get_type(v.params.m_types[0]); + + context.equate_types(sp, dst_ty, src_ty); + return true; + } + else + { ERROR(sp, E0000, "Failed to find an impl of " << v.trait << context.m_ivars.fmt(v.params) << " for " << context.m_ivars.fmt_type(v.impl_ty)); } - - //if( v.trait == context.m_crate.get_lang_item_path(sp, "unsize") ) - //{ - //} - return false; } else if( count == 1 ) { DEBUG("Only one impl " << v.trait << context.m_ivars.fmt(possible_params) << " for " << context.m_ivars.fmt_type(possible_impl_ty) |