From d894aaaf200e8c1b849a2ad1b6f2eb72148f03a3 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 19 May 2024 22:17:28 +0800 Subject: [PATCH] HIR Expand - More handling for generator trait type param --- src/hir_expand/closures.cpp | 4 ++++ src/hir_typeck/expr_check.cpp | 2 +- src/hir_typeck/static.cpp | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/hir_expand/closures.cpp b/src/hir_expand/closures.cpp index a44a45d61..24adddb0d 100644 --- a/src/hir_expand/closures.cpp +++ b/src/hir_expand/closures.cpp @@ -1645,6 +1645,10 @@ namespace { // -- Create impl ::HIR::TraitImpl impl; impl.m_params = std::move(params); + if( TARGETVER_LEAST_1_74 ) + { + impl.m_trait_args.m_types.push_back( monomorph_cb.monomorph_type(sp, node.m_resume_ty) ); + } impl.m_type = ::HIR::TypeRef::new_path( ::HIR::GenericPath(gen_struct_path, impl.m_params.make_nop_params(0)), &gen_struct_ref ); impl.m_types.insert(std::make_pair( RcString::new_interned("Yield" ), ::HIR::TraitImpl::ImplEnt { false, monomorph_cb.monomorph_type(sp, node.m_yield_ty) } )); impl.m_types.insert(std::make_pair( RcString::new_interned("Return"), ::HIR::TraitImpl::ImplEnt { false, monomorph_cb.monomorph_type(sp, node.m_return) } )); diff --git a/src/hir_typeck/expr_check.cpp b/src/hir_typeck/expr_check.cpp index efe9061a4..950a49b09 100644 --- a/src/hir_typeck/expr_check.cpp +++ b/src/hir_typeck/expr_check.cpp @@ -1144,7 +1144,7 @@ namespace { } void visit(::HIR::ExprNode_GeneratorWrapper& node) override { - TRACE_FUNCTION_F(&node << " /*gen*/ |...| ..."); + TRACE_FUNCTION_F(&node << " /*gen w*/ |...| ..."); if( node.m_code ) { diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp index 39a140544..a88cbf5bc 100644 --- a/src/hir_typeck/static.cpp +++ b/src/hir_typeck/static.cpp @@ -277,7 +277,12 @@ bool StaticTraitResolve::find_impl( ::HIR::TraitPath::assoc_list_t assoc; assoc.insert(::std::make_pair("Yield" , ::HIR::TraitPath::AtyEqual { trait_path.clone(), e.node->m_yield_ty.clone() })); assoc.insert(::std::make_pair("Return", ::HIR::TraitPath::AtyEqual { trait_path.clone(), e.node->m_return.clone() })); - return found_cb( ImplRef(type.clone(), HIR::PathParams(), mv$(assoc)), ::HIR::Compare::Equal ); + HIR::PathParams params; + if( TARGETVER_LEAST_1_74 ) + { + params.m_types.push_back(e.node->m_resume_ty.clone()); + } + return found_cb( ImplRef(type.clone(), mv$(params), mv$(assoc)), ::HIR::Compare::Equal ); } } // ----