diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-22 15:46:34 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-22 16:00:27 +0800 |
commit | 8fbd89944343d479977d2c8d0b0f3fb329299763 (patch) | |
tree | c742f92dcf07180527b4073cbdca616e8f14d21d /src | |
parent | 074cef4835dd2ade75ed2a3d7e44e02883de631c (diff) | |
download | mrust-8fbd89944343d479977d2c8d0b0f3fb329299763.tar.gz |
HIR Types - Treat unbound path types as fuzzy matches in compare_with_placeholders
Diffstat (limited to 'src')
-rw-r--r-- | src/hir/type.cpp | 6 | ||||
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/hir/type.cpp b/src/hir/type.cpp index 76154008..6f465c44 100644 --- a/src/hir/type.cpp +++ b/src/hir/type.cpp @@ -932,6 +932,12 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x // - See `(Generic,` below if( left.m_data.tag() != right.m_data.tag() ) { + if( left.m_data.is_Path() && left.m_data.as_Path().binding.is_Unbound() ) { + return Compare::Fuzzy; + } + if( right.m_data.is_Path() && right.m_data.as_Path().binding.is_Unbound() ) { + return Compare::Fuzzy; + } return Compare::Unequal; } TU_MATCH(::HIR::TypeRef::Data, (left.m_data, right.m_data), (le, re), diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index accb1636..b0d8f0b5 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -4533,11 +4533,13 @@ namespace { auto out_ty_o = impl.get_type(v.name.c_str()); if( out_ty_o == ::HIR::TypeRef() ) { + //BUG(sp, "Getting associated type '" << v.name << "' which isn't in " << v.trait << " (" << ty << ")"); out_ty_o = ::HIR::TypeRef( ::HIR::Path(::HIR::Path( v.impl_ty.clone(), ::HIR::GenericPath(v.trait, v.params.clone()), v.name, ::HIR::PathParams() )) ); } out_ty_o = context.m_resolve.expand_associated_types(sp, mv$(out_ty_o)); - //BUG(sp, "Getting associated type '" << v.name << "' which isn't in " << v.trait << " (" << ty << ")"); - + + // TODO: if this is an unbound UfcsUnknown, treat as a fuzzy match. + // - Shouldn't compare_with_placeholders do that? const auto& out_ty = out_ty_o; // - If we're looking for an associated type, allow it to eliminate impossible impls |