diff options
-rw-r--r-- | src/hir/expr.cpp | 1 | ||||
-rw-r--r-- | src/hir/type.hpp | 7 | ||||
-rw-r--r-- | src/hir_typeck/static.cpp | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/hir/expr.cpp b/src/hir/expr.cpp index 589e2811..0512e557 100644 --- a/src/hir/expr.cpp +++ b/src/hir/expr.cpp @@ -21,6 +21,7 @@ void ::HIR::ExprVisitor::visit_node(::HIR::ExprNode& node) { } void ::HIR::ExprVisitorDef::visit_node_ptr(::std::unique_ptr< ::HIR::ExprNode>& node_ptr) { assert(node_ptr); + TRACE_FUNCTION_F(&*node_ptr << " " << typeid(*node_ptr).name()); node_ptr->visit(*this); visit_type(node_ptr->m_res_type); } diff --git a/src/hir/type.hpp b/src/hir/type.hpp index e61c9ec7..fe28deed 100644 --- a/src/hir/type.hpp +++ b/src/hir/type.hpp @@ -196,6 +196,13 @@ public: (Path, struct { ::HIR::Path path; TypePathBinding binding; + + bool is_closure() const { + return path.m_data.is_Generic() + && path.m_data.as_Generic().m_path.m_components.back().size() > 8 + && path.m_data.as_Generic().m_path.m_components.back().compare(0,8, "closure#") == 0 + ; + } }), (Generic, struct { RcString name; diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp index f4fbf04d..51e4b831 100644 --- a/src/hir_typeck/static.cpp +++ b/src/hir_typeck/static.cpp @@ -106,8 +106,9 @@ bool StaticTraitResolve::find_impl( } } else if( TARGETVER_1_29 && trait_path == m_lang_Clone ) { + // NOTE: Duplicated check for enumerate if( type.m_data.is_Tuple() || type.m_data.is_Array() || type.m_data.is_Function() || type.m_data.is_Closure() - || TU_TEST2(type.m_data, Path, .path.m_data, Generic, .m_path.m_components.back().compare(0, 8, "closure#") == 0 ) ) + || TU_TEST1(type.m_data, Path, .is_closure()) ) { if( this->type_is_clone(sp, type) ) { return found_cb( ImplRef(&type, &null_params, &null_assoc), false ); @@ -1576,7 +1577,7 @@ bool StaticTraitResolve::type_is_clone(const Span& sp, const ::HIR::TypeRef& ty) if( it != m_clone_cache.end() ) return it->second; } - if( TU_TEST1(e.path.m_data, Generic, .m_path.m_components.back().compare(0, 8, "closure#") == 0 ) ) + if( e.is_closure() ) { bool rv = true; // TODO: Check all captures |