summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-07-17 16:40:52 +0800
committerJohn Hodge <tpg@mutabah.net>2016-07-17 16:40:52 +0800
commit9b639d59895a125973ffaf2e7dfd2c3bad50cc97 (patch)
tree179671ea78f0322c9bd661f6d59990a8302197b5 /src
parent50c127caac7113d8286e82ee59fc25b9e1ee5b8d (diff)
downloadmrust-9b639d59895a125973ffaf2e7dfd2c3bad50cc97.tar.gz
HIR Typecheck - Ivars in earlier passes
Diffstat (limited to 'src')
-rw-r--r--src/hir_conv/resolve_ufcs.cpp7
-rw-r--r--src/hir_typeck/static.cpp11
-rw-r--r--src/hir_typeck/static.hpp2
-rw-r--r--src/main.cpp4
4 files changed, 17 insertions, 7 deletions
diff --git a/src/hir_conv/resolve_ufcs.cpp b/src/hir_conv/resolve_ufcs.cpp
index 105dde2e..303926bd 100644
--- a/src/hir_conv/resolve_ufcs.cpp
+++ b/src/hir_conv/resolve_ufcs.cpp
@@ -202,7 +202,8 @@ namespace {
{
auto trait_path_g = ::HIR::GenericPath( mv$(sp) );
for(unsigned int i = 0; i < trait.m_params.m_types.size(); i ++ ) {
- trait_path_g.m_params.m_types.push_back( ::HIR::TypeRef(trait.m_params.m_types[i].m_name, i) );
+ //trait_path_g.m_params.m_types.push_back( ::HIR::TypeRef(trait.m_params.m_types[i].m_name, i) );
+ trait_path_g.m_params.m_types.push_back( ::HIR::TypeRef() );
}
return trait_path_g;
}
@@ -234,8 +235,8 @@ namespace {
const auto& type = *e.type;
return this->m_resolve.find_impl(sp, trait_path.m_path, nullptr, type, [&](const auto& impl){
- DEBUG("FOUND impl from " << impl);
pd = get_ufcs_known(mv$(e), make_generic_path(trait_path.m_path, trait), trait);
+ DEBUG("FOUND impl from " << impl);
return true;
});
}
@@ -290,7 +291,7 @@ namespace {
return ;
}
}
- ERROR(sp, E0000, "Failed to find impl with '" << e.item << "' for " << *e.type);
+ ERROR(sp, E0000, "Failed to find bound with '" << e.item << "' for " << *e.type);
return ;
)
else {
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp
index cb9044bb..4a7de82e 100644
--- a/src/hir_typeck/static.cpp
+++ b/src/hir_typeck/static.cpp
@@ -122,7 +122,7 @@ bool StaticTraitResolve::find_impl(
// Search the crate for impls
ret = m_crate.find_trait_impls(trait_path, type, cb_ident, [&](const auto& impl) {
- DEBUG("- impl" << impl.m_params.fmt_args() << " " << trait_path << impl.m_trait_args << " for " << impl.m_type << " where " << impl.m_params.fmt_bounds());
+ DEBUG("[find_impl] - impl" << impl.m_params.fmt_args() << " " << trait_path << impl.m_trait_args << " for " << impl.m_type << impl.m_params.fmt_bounds());
::std::vector< const ::HIR::TypeRef*> impl_params;
impl_params.resize( impl.m_params.m_types.size() );
@@ -148,8 +148,11 @@ bool StaticTraitResolve::find_impl(
match &= l.match_test_generics_fuzz(sp, r, cb_ident, cb);
}
}
- if( match != ::HIR::Compare::Equal )
+ if( match != ::HIR::Compare::Equal ) {
+ DEBUG("[find_impl] > Type mismatch");
+ // TODO: Support fuzzy matches for some edge cases
return false;
+ }
::std::vector< ::HIR::TypeRef> placeholders;
for(unsigned int i = 0; i < impl_params.size(); i ++ ) {
@@ -199,6 +202,10 @@ bool StaticTraitResolve::find_impl(
auto b_ty_mono = monomorphise_type_with(sp, e.type, cb_monomorph);
auto b_tp_mono = monomorphise_traitpath_with(sp, e.trait, cb_monomorph, false);
DEBUG("- b_ty_mono = " << b_ty_mono << ", b_tp_mono = " << b_tp_mono);
+ // HACK: If the type is '_', assume the bound passes
+ if( b_ty_mono.m_data.is_Infer() ) {
+ continue ;
+ }
if( !this->find_impl(sp, b_tp_mono.m_path.m_path, b_tp_mono.m_path.m_params, b_ty_mono, [](const auto&){return true;}) ) {
DEBUG("> Fail - " << b_ty_mono << ": " << b_tp_mono);
return false;
diff --git a/src/hir_typeck/static.hpp b/src/hir_typeck/static.hpp
index a4baaf57..22f1e4bd 100644
--- a/src/hir_typeck/static.hpp
+++ b/src/hir_typeck/static.hpp
@@ -79,7 +79,7 @@ public:
friend ::std::ostream& operator<<(::std::ostream& os, const ImplRef& x) {
TU_MATCH(Data, (x.m_data), (e),
(TraitImpl,
- os << "impl" << e.impl->m_params.fmt_args() << " SomeTrait" << e.impl->m_trait_args << " for " << e.impl->m_type << e.impl->m_params.fmt_bounds();
+ os << "impl" << e.impl->m_params.fmt_args() << " ?" << e.impl->m_trait_args << " for " << e.impl->m_type << e.impl->m_params.fmt_bounds();
),
(Bounded,
os << "bound";
diff --git a/src/main.cpp b/src/main.cpp
index 24b99705..84ee907d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -155,9 +155,11 @@ int main(int argc, char *argv[])
CompilePhaseV("Resolve Type Aliases", [&]() {
ConvertHIR_ExpandAliases(*hir_crate);
});
+ CompilePhaseV("Resolve Bind", [&]() {
+ ConvertHIR_Bind(*hir_crate);
+ });
CompilePhaseV("Resolve UFCS paths", [&]() {
ConvertHIR_ResolveUFCS(*hir_crate);
- ConvertHIR_Bind(*hir_crate);
});
CompilePhaseV("Constant Evaluate", [&]() {
ConvertHIR_ConstantEvaluate(*hir_crate);