summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-09-01 10:48:18 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-09-01 10:48:18 +0800
commit4261a96ad5abeb3af1385eed4abeafc6f4e9823f (patch)
treef37518525d62d05d577d19c628c760db08bb42b0
parentb6726e67982b9a73b9f5286c17ff81688ce06b11 (diff)
downloadmrust-4261a96ad5abeb3af1385eed4abeafc6f4e9823f.tar.gz
HIR Typecheck Expressions - Fix some little coercion bugs
-rw-r--r--src/hir_typeck/expr_cs.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index e2f386ed..48f5095b 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -4135,8 +4135,8 @@ namespace {
DEBUG("Literal ivars");
return CoerceResult::Equality;
}
- context.possible_equate_type_coerce_to(src.m_data.as_Infer().index, dst);
- context.possible_equate_type_coerce_from(dst.m_data.as_Infer().index, src);
+ context.possible_equate_type_unsize_to(src.m_data.as_Infer().index, dst);
+ context.possible_equate_type_unsize_from(dst.m_data.as_Infer().index, src);
DEBUG("Both ivars");
return CoerceResult::Unknown;
}
@@ -4148,7 +4148,7 @@ namespace {
DEBUG("Literal with primitive");
return CoerceResult::Equality;
}
- context.possible_equate_type_coerce_from(dep->index, src);
+ context.possible_equate_type_unsize_from(dep->index, src);
DEBUG("Dst ivar");
return CoerceResult::Unknown;
}
@@ -4160,7 +4160,7 @@ namespace {
DEBUG("Literal with primitive");
return CoerceResult::Equality;
}
- context.possible_equate_type_coerce_to(sep->index, dst);
+ context.possible_equate_type_unsize_to(sep->index, dst);
DEBUG("Src ivar");
return CoerceResult::Unknown;
}
@@ -5811,6 +5811,13 @@ namespace {
}
}
+ // De-duplicate lists (after unification) using strict equality
+ H::dedup_type_list_with(types_from, [&](const auto& l, const auto& r) {
+ return context.m_ivars.types_equal(l, r) ? DedupKeep::Left : DedupKeep::Both;
+ });
+ H::dedup_type_list_with(types_to, [&](const auto& l, const auto& r) {
+ return context.m_ivars.types_equal(l, r) ? DedupKeep::Left : DedupKeep::Both;
+ });
// Prefer cases where this type is being created from a known type
if( types_from.size() == 1 ) {