diff options
author | John Hodge <tpg@mutabah.net> | 2016-07-07 16:45:21 +1000 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-07-07 16:45:21 +1000 |
commit | dca7fb1c1da918a46fb40e18745e420a16627b8e (patch) | |
tree | 7d829bf3f424f706181ef56c42397c4dd9563c5c /src | |
parent | 50da728d45e191f8a75926848cc0f13285bc9375 (diff) | |
download | mrust-dca7fb1c1da918a46fb40e18745e420a16627b8e.tar.gz |
HIR Typecheck CS - Better impl searching, fixed function bounds
Diffstat (limited to 'src')
-rw-r--r-- | src/expand/derive.cpp | 2 | ||||
-rw-r--r-- | src/hir_typeck/expr_cs.cpp | 10 | ||||
-rw-r--r-- | src/hir_typeck/helpers.cpp | 5 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/expand/derive.cpp b/src/expand/derive.cpp index 0d83c09a..5df16616 100644 --- a/src/expand/derive.cpp +++ b/src/expand/derive.cpp @@ -335,7 +335,7 @@ template<typename T> static void derive_item(const Span& sp, AST::Module& mod, const AST::MetaItem& attr, const AST::Path& path, const T& item) { if( !attr.has_sub_items() ) { - //throw CompileError::Generic("#[derive()] requires a list of known traits to derive"); + //ERROR(sp, E0000, "#[derive()] requires a list of known traits to derive"); return ; } diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp index 2bac66ea..eba4eef0 100644 --- a/src/hir_typeck/expr_cs.cpp +++ b/src/hir_typeck/expr_cs.cpp @@ -303,7 +303,7 @@ namespace { auto real_trait = monomorphise_genericpath_with(sp, be.trait.m_path, cache.m_monomorph_cb, false); DEBUG("Bound " << be.type << ": " << be.trait); DEBUG("= (" << real_type << ": " << real_trait << ")"); - const auto& trait_params = be.trait.m_path.m_params; + const auto& trait_params = real_trait.m_params; context.equate_types_assoc(sp, ::HIR::TypeRef(), be.trait.m_path.m_path, mv$(trait_params.clone().m_types), real_type, ""); ), (TypeEquality, @@ -2595,13 +2595,13 @@ namespace { // No applicable impl // - TODO: This should really only fire when there isn't an impl. But it currently fires when _ DEBUG("No impl of " << v.trait << v.params << " for " << v.impl_ty); - //if( !context.m_ivars.type_contains_ivars(v.impl_ty) ) { - // ERROR(sp, E0000, "Failed to find an impl of " << v.trait << v.params << " for " << context.m_ivars.fmt_type(v.impl_ty)); - //} + if( !context.m_ivars.type_contains_ivars(v.impl_ty) ) { + ERROR(sp, E0000, "Failed to find an impl of " << v.trait << v.params << " for " << context.m_ivars.fmt_type(v.impl_ty)); + } return false; } else if( count == 1 ) { - DEBUG("Only one impl " << v.trait << possible_params << " for " << possible_impl_ty << " - ty=" << output_type); + DEBUG("Only one impl " << v.trait << possible_params << " for " << possible_impl_ty << " - params=" << possible_params << ", ty=" << possible_impl_ty << ", out=" << output_type); // Only one possible impl if( v.name[0] ) { context.equate_types(sp, v.left_ty, output_type); diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index b86949b3..9e9467b0 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -1311,6 +1311,7 @@ bool TraitResolution::find_trait_impls_bound(const Span& sp, const ::HIR::Simple { return this->iterate_bounds([&](const auto& b) { TU_IFLET(::HIR::GenericBound, b, TraitBound, e, + DEBUG("- " << e.type << " : " << e.trait); // TODO: Allow fuzzy equality? if( e.type != type ) return false; @@ -1365,12 +1366,12 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp, ::std::vector< const ::HIR::TypeRef*> impl_params; impl_params.resize( impl.m_params.m_types.size() ); auto cb = [&](auto idx, const auto& ty) { - DEBUG("[find_trait_impls_crate] " << idx << " = " << ty); + DEBUG("[find_trait_impls_crate] Param " << idx << " = " << ty); assert( idx < impl_params.size() ); if( ! impl_params[idx] ) { impl_params[idx] = &ty; } - else if( *impl_params[idx] != ty ) { + else if( ! this->m_ivars.types_equal(*impl_params[idx], ty) ) { // Strict equality is OK, as all types should be sane // - TODO: What if there's an un-expanded associated? match = ::HIR::Compare::Unequal; |