From 567768bf3f11091ca4a9ba94267b0368e10a2c89 Mon Sep 17 00:00:00 2001 From: Graham Kelly Date: Thu, 6 Jun 2024 17:44:40 -0400 Subject: [PATCH] compiles --- wars/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wars/src/lib.rs b/wars/src/lib.rs index 80fca45..fdc514e 100644 --- a/wars/src/lib.rs +++ b/wars/src/lib.rs @@ -305,11 +305,14 @@ impl Opts> { }; let g = self.render_generics("e! {c}, &self.module.signatures[*sig_index]); quote! { - match #root::_rexport::tramp::tramp(#root::func::call_ref::<#g,C>(ctx,#root::func::cast(#r.clone()),#root::_rexport::tuple_list::tuple_list!(#(#root::func::cast::<_,_,C>(#vals .clone())),*))){ + { + let r = #r.clone(); + match #root::_rexport::tramp::tramp(#root::func::call_ref::<#g,C>(ctx,#root::func::cast(r),#root::_rexport::tuple_list::tuple_list!(#(#root::func::cast::<_,_,C>(#vals .clone())),*))){ Ok(a) => a, Err(e) => return #root::_rexport::tramp::BorrowRec::Ret(Err(e)) } } + } }, Operator::RefFunc { func_index } => { self.render_fun_ref("e! {C},*func_index) @@ -577,8 +580,9 @@ impl Opts> { }; let g = self.render_generics("e! {c}, &self.module.signatures[*sig]); quote! { + let r = #r.clone(); return #root::_rexport::tramp::BorrowRec::Call(#root::_rexport::tramp::Thunk::new(move||{ - #root::func::call_ref::<#g,C>(ctx,#root::func::cast(#r.clone()),#root::_rexport::tuple_list::tuple_list!(#(#root::func::cast::<_,_,C>(#vals .clone())),*)) + #root::func::call_ref::<#g,C>(ctx,#root::func::cast(r),#root::_rexport::tuple_list::tuple_list!(#(#root::func::cast::<_,_,C>(#vals .clone())),*)) })) } } @@ -997,7 +1001,7 @@ pub fn go(opts: &Opts>) -> proc_macro2::TokenStream { #(#fs)* } - pub fn init(ctx: &mut C) -> #root::_rexport::anyhow::Result<()>{ + pub fn init(ctx: &mut C) -> #root::_rexport::anyhow::Result<()>{ #(#init);*; return Ok(()) }