summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hir/from_ast.cpp3
-rw-r--r--src/hir/visitor.cpp2
-rw-r--r--src/hir_typeck/helpers.cpp2
-rw-r--r--src/hir_typeck/impl_ref.hpp7
-rw-r--r--src/hir_typeck/static.cpp18
5 files changed, 22 insertions, 10 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index 3f492633..29711937 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -975,6 +975,7 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat
else
{
::HIR::ItemPath path(type, trait_name);
+ DEBUG(path);
::std::map< ::std::string, ::HIR::TraitImpl::ImplEnt< ::HIR::Function> > methods;
::std::map< ::std::string, ::HIR::TraitImpl::ImplEnt< ::HIR::ExprPtr> > constants;
@@ -989,9 +990,11 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat
),
// TODO: Associated constants
(Type,
+ DEBUG("- type " << item.name);
types.insert( ::std::make_pair(item.name, ::HIR::TraitImpl::ImplEnt< ::HIR::TypeRef> { item.is_specialisable, LowerHIR_Type(e.type()) }) );
),
(Function,
+ DEBUG("- method " << item.name);
methods.insert( ::std::make_pair(item.name, ::HIR::TraitImpl::ImplEnt< ::HIR::Function> { item.is_specialisable, LowerHIR_Function(item_path, e) }) );
)
)
diff --git a/src/hir/visitor.cpp b/src/hir/visitor.cpp
index daef834d..faca63da 100644
--- a/src/hir/visitor.cpp
+++ b/src/hir/visitor.cpp
@@ -101,7 +101,7 @@ void ::HIR::Visitor::visit_type_impl(::HIR::TypeImpl& impl)
void ::HIR::Visitor::visit_trait_impl(const ::HIR::SimplePath& trait_path, ::HIR::TraitImpl& impl)
{
::HIR::ItemPath p( impl.m_type, trait_path );
- TRACE_FUNCTION_F("trait_path=" << trait_path);
+ TRACE_FUNCTION_F(p);
this->visit_params(impl.m_params);
// - HACK: Create a generic path to visit (so that proper checks are performed)
{
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index f2cef059..7792ed25 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -2090,7 +2090,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
//if( match == ::HIR::Compare::Fuzzy ) {
// TODO(sp, "- Pass on fuzzy match status");
//}
- return callback(ImplRef(mv$(impl_params), impl, mv$(placeholders)), match);
+ return callback(ImplRef(mv$(impl_params), trait, impl, mv$(placeholders)), match);
//return callback(ty_mono, args_mono, types/*, (match == ::HIR::Compare::Fuzzy)*/);
}
);
diff --git a/src/hir_typeck/impl_ref.hpp b/src/hir_typeck/impl_ref.hpp
index e98ec988..f818492b 100644
--- a/src/hir_typeck/impl_ref.hpp
+++ b/src/hir_typeck/impl_ref.hpp
@@ -10,6 +10,7 @@ struct ImplRef
(TraitImpl, struct {
::std::vector<const ::HIR::TypeRef*> params;
::std::vector<::HIR::TypeRef> params_ph;
+ const ::HIR::SimplePath* trait_path;
const ::HIR::TraitImpl* impl;
}),
(BoundedPtr, struct {
@@ -27,10 +28,10 @@ struct ImplRef
Data m_data;
ImplRef():
- m_data(Data::make_TraitImpl({ {}, {}, nullptr }))
+ m_data(Data::make_TraitImpl({ {}, {}, nullptr, nullptr }))
{}
- ImplRef(::std::vector<const ::HIR::TypeRef*> params, const ::HIR::TraitImpl& impl, ::std::vector< ::HIR::TypeRef> params_ph={}):
- m_data(Data::make_TraitImpl({ mv$(params), mv$(params_ph), &impl }))
+ ImplRef(::std::vector<const ::HIR::TypeRef*> params, const ::HIR::SimplePath& trait, const ::HIR::TraitImpl& impl, ::std::vector< ::HIR::TypeRef> params_ph={}):
+ m_data(Data::make_TraitImpl({ mv$(params), mv$(params_ph), &trait, &impl }))
{}
ImplRef(const ::HIR::TypeRef* type, const ::HIR::PathParams* args, const ::std::map< ::std::string, ::HIR::TypeRef>* assoc):
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp
index 0e0468f3..623d9e79 100644
--- a/src/hir_typeck/static.cpp
+++ b/src/hir_typeck/static.cpp
@@ -166,7 +166,7 @@ bool StaticTraitResolve::find_impl__check_crate(
}
}
if( match != ::HIR::Compare::Equal ) {
- DEBUG("[find_impl] > Type mismatch");
+ DEBUG(" > Type mismatch");
// TODO: Support fuzzy matches for some edge cases
return false;
}
@@ -240,18 +240,22 @@ bool StaticTraitResolve::find_impl__check_crate(
auto cmp = have .match_test_generics_fuzz(sp, exp, cb_ident, cb_match);
ASSERT_BUG(sp, cmp == ::HIR::Compare::Equal, "Assoc ty " << name << " mismatch, " << have << " != des " << exp);
}
+ else
+ {
+ DEBUG("Assoc `" << name << "` unbound, can't compare with " << exp);
+ }
}
return true;
});
if( !rv ) {
- DEBUG("[find_impl] > Fail - " << b_ty_mono << ": " << b_tp_mono);
+ DEBUG("> Fail - " << b_ty_mono << ": " << b_tp_mono);
return false;
}
)
)
}
- return found_cb( ImplRef(impl_params, impl) );
+ return found_cb( ImplRef(impl_params, trait_path, impl) );
}
void StaticTraitResolve::expand_associated_types(const Span& sp, ::HIR::TypeRef& input) const
@@ -780,6 +784,7 @@ bool ImplRef::type_is_specializable(const char* name) const
}
else {
os << "impl";
+ os << "(" << e.impl << ")";
if( e.impl->m_params.m_types.size() )
{
os << "<";
@@ -791,12 +796,11 @@ bool ImplRef::type_is_specializable(const char* name) const
}
os << ">";
}
- os << " ?" << e.impl->m_trait_args << " for " << e.impl->m_type << e.impl->m_params.fmt_bounds();
+ os << " " << *e.trait_path << e.impl->m_trait_args << " for " << e.impl->m_type << e.impl->m_params.fmt_bounds();
os << " {";
for( unsigned int i = 0; i < e.impl->m_params.m_types.size(); i ++ )
{
const auto& ty_d = e.impl->m_params.m_types[i];
- os << ty_d.m_name;
os << ty_d.m_name << " = ";
if( e.params[i] ) {
os << *e.params[i];
@@ -806,6 +810,10 @@ bool ImplRef::type_is_specializable(const char* name) const
}
os << ",";
}
+ for(const auto& aty : e.impl->m_types)
+ {
+ os << "Self::" << aty.first << " = " << aty.second.data << ",";
+ }
os << "}";
}
),