Skip to content

Commit

Permalink
HIR Expand - More handling for generator trait type param
Browse files Browse the repository at this point in the history
  • Loading branch information
thepowersgang committed May 19, 2024
1 parent cec0731 commit d894aaa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/hir_expand/closures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<HIR::TypeRef> { false, monomorph_cb.monomorph_type(sp, node.m_yield_ty) } ));
impl.m_types.insert(std::make_pair( RcString::new_interned("Return"), ::HIR::TraitImpl::ImplEnt<HIR::TypeRef> { false, monomorph_cb.monomorph_type(sp, node.m_return) } ));
Expand Down
2 changes: 1 addition & 1 deletion src/hir_typeck/expr_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
7 changes: 6 additions & 1 deletion src/hir_typeck/static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
// ----
Expand Down

0 comments on commit d894aaa

Please sign in to comment.