summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-03 16:54:19 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-03 16:54:19 +0800
commitdf6b00d53966d9cf30e5ef959dbb18005f44fcbf (patch)
tree8b23e5d2f3df83538ca974d802b3ce529377e300
parent2a7cda10dd855d433b5d2bb2d87d736201a27499 (diff)
downloadmrust-df6b00d53966d9cf30e5ef959dbb18005f44fcbf.tar.gz
HIR - Hack: Treat impl placeholder generics as ivars in match_test_generics_fuzz
-rw-r--r--src/hir/type.cpp5
-rw-r--r--src/hir_typeck/helpers.cpp11
2 files changed, 16 insertions, 0 deletions
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index f17613ea..c9f3fe85 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -575,6 +575,11 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x
DEBUG("- Fuzzy match due to opaque");
return Compare::Fuzzy;
}
+ // HACK: If the RHS is a placeholder generic, allow it.
+ if( x.m_data.is_Generic() && (x.m_data.as_Generic().binding >> 8) == 2 ) {
+ DEBUG("- Fuzzy match due to placeholder");
+ return Compare::Fuzzy;
+ }
DEBUG("- Tag mismatch " << v << " and " << x);
return Compare::Unequal;
}
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index bbde5163..b76b5e74 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -2208,6 +2208,17 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
}
};
+ //auto cb_res = [&](const auto& ty)->const auto& {
+ // if( ty.m_data.is_Infer() ) {
+ // return this->m_ivars.get_type(ty);
+ // }
+ // //else if( ty.m_data.is_Generic() && ty.m_data.as_Generic().binding >> 8 == 2 ) {
+ // // return ::HIR::TypeRef();
+ // //}
+ // else {
+ // return ty;
+ // }
+ // };
// NOTE: If this type references an associated type, the match will incorrectly fail.
// - HACK: match_test_generics_fuzz has been changed to return Fuzzy if there's a tag mismatch and the LHS is an Opaque path
auto match = ::HIR::Compare::Equal;