diff options
Diffstat (limited to 'src/hir')
-rw-r--r-- | src/hir/hir.cpp | 20 | ||||
-rw-r--r-- | src/hir/hir.hpp | 3 |
2 files changed, 22 insertions, 1 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 ) diff --git a/src/hir/hir.hpp b/src/hir/hir.hpp index e1406067..c439960a 100644 --- a/src/hir/hir.hpp +++ b/src/hir/hir.hpp @@ -190,7 +190,7 @@ struct Trait ::std::string m_lifetime; ::std::vector< ::HIR::TraitPath > m_parent_traits; - bool m_is_marker; + bool m_is_marker; // aka OIBIT ::std::unordered_map< ::std::string, AssociatedType > m_types; ::std::unordered_map< ::std::string, TraitValueItem > m_values; @@ -361,6 +361,7 @@ public: } bool find_trait_impls(const ::HIR::SimplePath& path, const ::HIR::TypeRef& type, t_cb_resolve_type ty_res, ::std::function<bool(const ::HIR::TraitImpl&)> callback) const; + bool find_auto_trait_impls(const ::HIR::SimplePath& path, const ::HIR::TypeRef& type, t_cb_resolve_type ty_res, ::std::function<bool(const ::HIR::MarkerImpl&)> callback) const; bool find_type_impls(const ::HIR::TypeRef& type, t_cb_resolve_type ty_res, ::std::function<bool(const ::HIR::TypeImpl&)> callback) const; }; |