summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-01 13:24:00 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-01 13:24:00 +0800
commitdc4d17fb2edc6cd68e31632484ad01d470984934 (patch)
tree2195d3491d0e0dfe407f018f4b1b5760dac0722b
parentfc4c8a1e3d2994b24bc4f7f573d49be99c1dabcf (diff)
downloadmrust-dc4d17fb2edc6cd68e31632484ad01d470984934.tar.gz
HIR Typecheck CS - Don't coerce on let unless type is specified
-rw-r--r--src/hir_typeck/expr_cs.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 792007fb..f051b0b8 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -433,7 +433,14 @@ namespace {
if( node.m_value )
{
this->context.add_ivars( node.m_value->m_res_type );
- this->context.equate_types_coerce( node.span(), node.m_type, node.m_value );
+ // If the type was omitted or was just `_`, equate
+ if( node.m_type.m_data.is_Infer() ) {
+ this->context.equate_types( node.span(), node.m_type, node.m_value->m_res_type );
+ }
+ // otherwise coercions apply
+ else {
+ this->context.equate_types_coerce( node.span(), node.m_type, node.m_value );
+ }
node.m_value->visit( *this );
}