diff options
-rw-r--r-- | src/hir/hir.cpp | 13 | ||||
-rw-r--r-- | src/hir_conv/resolve_ufcs.cpp | 12 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp index 6b50c0f2..14a84d86 100644 --- a/src/hir/hir.cpp +++ b/src/hir/hir.cpp @@ -505,6 +505,12 @@ bool ::HIR::Crate::find_trait_impls(const ::HIR::SimplePath& trait, const ::HIR: } } } + for( const auto& ec : this->m_ext_crates ) + { + if( ec.second->find_trait_impls(trait, type, ty_res, callback) ) { + return true; + } + } return false; } bool ::HIR::Crate::find_type_impls(const ::HIR::TypeRef& type, t_cb_resolve_type ty_res, ::std::function<bool(const ::HIR::TypeImpl&)> callback) const @@ -517,5 +523,12 @@ bool ::HIR::Crate::find_type_impls(const ::HIR::TypeRef& type, t_cb_resolve_type } } } + for( const auto& ec : this->m_ext_crates ) + { + DEBUG("- " << ec.first); + if( ec.second->find_type_impls(type, ty_res, callback) ) { + return true; + } + } return false; } diff --git a/src/hir_conv/resolve_ufcs.cpp b/src/hir_conv/resolve_ufcs.cpp index f5e96598..73bf863e 100644 --- a/src/hir_conv/resolve_ufcs.cpp +++ b/src/hir_conv/resolve_ufcs.cpp @@ -326,29 +326,27 @@ namespace { ) else { // 1. Search for applicable inherent methods (COMES FIRST!) - for( const auto& impl : m_crate.m_type_impls ) - { - if( !impl.matches_type(*e.type) ) { - continue ; - } + if( m_crate.find_type_impls(*e.type, [&](const auto& t)->const auto& { return t; }, [&](const auto& impl) { DEBUG("- matched inherent impl " << *e.type); // Search for item in this block switch( pc ) { case ::HIR::Visitor::PathContext::VALUE: if( impl.m_methods.find(e.item) == impl.m_methods.end() ) { - continue ; + return false; } // Found it, just keep going (don't care about details here) break; case ::HIR::Visitor::PathContext::TRAIT: case ::HIR::Visitor::PathContext::TYPE: - continue ; + return false; } auto new_data = ::HIR::Path::Data::make_UfcsInherent({ mv$(e.type), mv$(e.item), mv$(e.params)} ); p.m_data = mv$(new_data); DEBUG("- Resolved, replace with " << p); + return true; + }) ) { return ; } // 2. Search all impls of in-scope traits for this method on this type |