summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-04-16 11:40:49 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-04-16 11:40:49 +0800
commit8ba1fb776a5a61d3e8b7680e37232bd431f6f7f0 (patch)
treed42c7128094e562064f97cc85ef325d8dacaa2c3 /src
parent2acb5a8ac29ddc6f6894802d255d686fdb18329d (diff)
downloadmrust-8ba1fb776a5a61d3e8b7680e37232bd431f6f7f0.tar.gz
HIR Type Match - Handle matching two Infers
Diffstat (limited to 'src')
-rw-r--r--src/hir/type.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index 9b0bf766..7168da53 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -606,7 +606,26 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x
return Compare::Unequal;
}
TU_MATCH(::HIR::TypeRef::Data, (v.m_data, x.m_data), (te, xe),
- (Infer, throw "";),
+ (Infer,
+ // Both sides are infer
+ switch(te.ty_class)
+ {
+ case ::HIR::InferClass::None:
+ case ::HIR::InferClass::Diverge:
+ return Compare::Fuzzy;
+ default:
+ switch(xe.ty_class)
+ {
+ case ::HIR::InferClass::None:
+ case ::HIR::InferClass::Diverge:
+ return Compare::Fuzzy;
+ default:
+ if( te.ty_class != xe.ty_class )
+ return Compare::Unequal;
+ return Compare::Fuzzy;
+ }
+ }
+ ),
(Generic, throw "";),
(Primitive,
return (te == xe ? Compare::Equal : Compare::Unequal);