summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-04-22 08:09:31 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-04-22 08:09:31 +0800
commit018a5a14dbf4ea94bdbb1bd17db9f7ef3852c2b0 (patch)
tree84d65ba37106e61759ae282d2adfadfddafabb85 /src
parent3bf9a102de5421864863c26626f667ab2429e8bc (diff)
downloadmrust-018a5a14dbf4ea94bdbb1bd17db9f7ef3852c2b0.tar.gz
Typecheck Expressions - Minor tweaks from trying to use all trait impls in impl search
Diffstat (limited to 'src')
-rw-r--r--src/hir/hir_ops.cpp6
-rw-r--r--src/hir_typeck/helpers.cpp31
2 files changed, 24 insertions, 13 deletions
diff --git a/src/hir/hir_ops.cpp b/src/hir/hir_ops.cpp
index a082becd..4b35a0f0 100644
--- a/src/hir/hir_ops.cpp
+++ b/src/hir/hir_ops.cpp
@@ -271,6 +271,10 @@ namespace {
return ::OrdGreater;
}
+ if( left == right ) {
+ return ::OrdEqual;
+ }
+
TU_MATCH(::HIR::TypeRef::Data, (left.m_data), (le),
(Generic,
throw "";
@@ -335,7 +339,7 @@ namespace {
),
(Function,
TU_IFLET(::HIR::TypeRef::Data, right.m_data, Function, re,
- TODO(sp, "Function");
+ TODO(sp, "Function - " << left << " vs " << right);
//return typelist_ord_specific(sp, le.arg_types, re.arg_types);
)
else {
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index 053aab4d..5db296ea 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -2637,10 +2637,12 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
};
// - If the type is a path (struct/enum/...), search for impls for all contained types.
- TU_IFLET( ::HIR::TypeRef::Data, type.m_data, Path, e,
+ if(const auto* ep = type.m_data.opt_Path())
+ {
+ const auto& e = *ep;
::HIR::Compare res = ::HIR::Compare::Equal;
- TU_MATCH( ::HIR::Path::Data, (e.path.m_data), (pe),
- (Generic,
+ TU_MATCH_HDRA( (e.path.m_data), {)
+ TU_ARMA(Generic, pe) { //(
::HIR::TypeRef tmp;
auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
@@ -2726,25 +2728,30 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
)
)
DEBUG("- Nothing failed, calling callback");
- ),
- (UfcsUnknown,
+ }
+ TU_ARMA(UfcsUnknown, pe) {
BUG(sp, "UfcsUnknown in typeck - " << type);
- ),
- (UfcsKnown,
+ }
+ TU_ARMA(UfcsKnown, pe) {
// If unbound, use Fuzzy {
if(e.binding.is_Unbound()) {
DEBUG("- Unbound UfcsKnown, returning Fuzzy");
return ::HIR::Compare::Fuzzy;
}
// Otherwise, it's opaque. Check the bounds on the trait.
+ if( TU_TEST1(pe.type->m_data, Generic, .binding >> 8 == 2) )
+ {
+ DEBUG("- UfcsKnown of placeholder, returning Fuzzy");
+ return ::HIR::Compare::Fuzzy;
+ }
TODO(sp, "Check trait bounds for bound on " << type);
- ),
- (UfcsInherent,
+ }
+ TU_ARMA(UfcsInherent, pe) {
TODO(sp, "Auto trait lookup on UFCS Inherent type");
- )
- )
+ }
+ }
return res;
- )
+ }
else TU_IFLET( ::HIR::TypeRef::Data, type.m_data, Generic, e,
auto l_res = ::HIR::Compare::Unequal;
this->find_trait_impls(sp, trait, *params_ptr, type, [&](auto, auto cmp){ l_res = cmp; return (cmp == ::HIR::Compare::Equal); });