diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-29 15:31:59 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-29 15:31:59 +0800 |
commit | 3a31e6b5f85436d9b239e23cfcb6bf39e5ad052d (patch) | |
tree | f8cbae6cc7d75cfdad7ea44005a3e3f52ee3d594 /src/hir/hir.cpp | |
parent | a19bd7137b56c92f3363ea2eb6e2e4ed0a0fd271 (diff) | |
download | mrust-3a31e6b5f85436d9b239e23cfcb6bf39e5ad052d.tar.gz |
HIR Typecheck Expr - Draft auto trait impl search
Diffstat (limited to 'src/hir/hir.cpp')
-rw-r--r-- | src/hir/hir.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp index aa3344eb..40ad9f86 100644 --- a/src/hir/hir.cpp +++ b/src/hir/hir.cpp @@ -560,6 +560,26 @@ bool ::HIR::Crate::find_trait_impls(const ::HIR::SimplePath& trait, const ::HIR: } return false; } +bool ::HIR::Crate::find_auto_trait_impls(const ::HIR::SimplePath& trait, const ::HIR::TypeRef& type, t_cb_resolve_type ty_res, ::std::function<bool(const ::HIR::MarkerImpl&)> callback) const +{ + auto its = this->m_marker_impls.equal_range( trait ); + for( auto it = its.first; it != its.second; ++ it ) + { + const auto& impl = it->second; + if( impl.matches_type(type, ty_res) ) { + if( callback(impl) ) { + return true; + } + } + } + for( const auto& ec : this->m_ext_crates ) + { + if( ec.second->find_auto_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 { for( const auto& impl : this->m_type_impls ) |