summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-01 16:54:23 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-01 16:54:23 +0800
commit5acc77c720f46814a829e2f106db08ad51a820d2 (patch)
tree5ae02ec616ffc20d40b4eeaf19ceb0ccf5574080
parentbf2f4a5483c6e6c36718c287f21759a294682e60 (diff)
downloadmrust-5acc77c720f46814a829e2f106db08ad51a820d2.tar.gz
HIR - Look for impls in extern crates
-rw-r--r--src/hir/hir.cpp13
-rw-r--r--src/hir_conv/resolve_ufcs.cpp12
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