summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2017-09-07 10:44:25 +0800
committerJohn Hodge <tpg@ucc.asn.au>2017-09-07 10:44:25 +0800
commit4f246978f8c776d9e9738c41f4430e2b94df8642 (patch)
tree40dc72b6b0206cf3fdf837dfe6ed4369d90e8315 /src
parent4ea273b59158b788c0c96344d4ebe690fb261aa5 (diff)
downloadmrust-4f246978f8c776d9e9738c41f4430e2b94df8642.tar.gz
HIR Typecheck - Pick the most specific type when fuzzy matching
Diffstat (limited to 'src')
-rw-r--r--src/hir_typeck/helpers.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index 1cf2e320..8c69c38d 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -2670,7 +2670,15 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
}
else {
DEBUG("[ftic_check_params] Param " << idx << " " << *impl_params[idx] << " == " << ty);
- return impl_params[idx]->compare_with_placeholders(sp, ty, this->m_ivars.callback_resolve_infer());
+ auto rv = impl_params[idx]->compare_with_placeholders(sp, ty, this->m_ivars.callback_resolve_infer());
+ // If the existing is an ivar, replace with this.
+ // - TODO: Store the least fuzzy option, or store all fuzzy options?
+ if( rv == ::HIR::Compare::Fuzzy && impl_params[idx]->m_data.is_Infer() )
+ {
+ DEBUG("[ftic_check_params] Param " << idx << " fuzzy, use " << ty);
+ impl_params[idx] = &ty;
+ }
+ return rv;
}
};