summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-22 15:32:38 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-22 16:00:27 +0800
commit074cef4835dd2ade75ed2a3d7e44e02883de631c (patch)
tree5729c795e27288bd6d2abc30f6179a4b9ed66c1c
parentd9e027e992b798dafde2b6e90aecca90aee525eb (diff)
downloadmrust-074cef4835dd2ade75ed2a3d7e44e02883de631c.tar.gz
HIR Typecheck Expr - Add ivar possibilities from CoerceUnsized
-rw-r--r--src/hir_typeck/expr_cs.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index fc590276..accb1636 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -4491,7 +4491,25 @@ namespace {
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]);
- if( !src_ty.m_data.is_Infer() && !dst_ty.m_data.is_Infer() )
+ if( src_ty.m_data.is_Infer() && dst_ty.m_data.is_Infer() )
+ {
+ // Both infer, nothing to do?
+ }
+ else if( src_ty.m_data.is_Infer() )
+ {
+ // Source can possibly equate to dst_ty
+ context.possible_equate_type_to(src_ty.m_data.as_Infer().index, dst_ty);
+ DEBUG("- Src Infer, add possibility");
+ return false;
+ }
+ else if( dst_ty.m_data.is_Infer() )
+ {
+ // Destination can possibly equate from src_ty
+ context.possible_equate_type_to(dst_ty.m_data.as_Infer().index, src_ty);
+ DEBUG("- Dst Infer, add possibility");
+ return false;
+ }
+ else
{
// If the trait is CoerceUnsized and no impl could be found, equate.
bool found = context.m_resolve.find_trait_impls(sp, v.trait, v.params, v.impl_ty, [&](auto, auto) { return true; });