diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-22 09:56:04 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-22 09:56:04 +0800 |
| commit | e843405ecfee06ea158fb0070d4c70c2f228c82c (patch) | |
| tree | b3fb888dd00797a9880d76b704fd8564a27b7799 /mingling_macros/src | |
| parent | 7adbe2715285d7baedfb91f5e81f5ea64f7d1a5a (diff) | |
Refactor renderer to use injected resources directly
Diffstat (limited to 'mingling_macros/src')
| -rw-r--r-- | mingling_macros/src/renderer.rs | 8 | ||||
| -rw-r--r-- | mingling_macros/src/res_injection.rs | 2 |
2 files changed, 4 insertions, 6 deletions
diff --git a/mingling_macros/src/renderer.rs b/mingling_macros/src/renderer.rs index db04c19..7f85a60 100644 --- a/mingling_macros/src/renderer.rs +++ b/mingling_macros/src/renderer.rs @@ -115,16 +115,14 @@ pub fn renderer_attr(attr: TokenStream, item: TokenStream) -> TokenStream { quote! { #(#fn_body_stmts)* } }; - // Build the original function with resource injection (no `.into()` — signature is exactly as user wrote) + // Build the original function with resource injection - use the resource bindings directly + // from the function parameters rather than re-fetching from context. let original_fn_body = if has_resources { - let wrapped_body = - wrap_body_with_mut_resources(&fn_body_stmts, &mut_resources, program_type); quote! { let mut dummy_r = ::mingling::RenderResult::default(); { let __renderer_inner_result = &mut dummy_r; - #(#immut_resource_stmts)* - #wrapped_body + #(#fn_body_stmts)* } #result_return } diff --git a/mingling_macros/src/res_injection.rs b/mingling_macros/src/res_injection.rs index 0f180db..bdb3b73 100644 --- a/mingling_macros/src/res_injection.rs +++ b/mingling_macros/src/res_injection.rs @@ -149,7 +149,7 @@ pub(crate) fn generate_immut_resource_bindings<'a>( .filter(|r| !r.is_mut) .map(|res| { let var_binding_name = syn::Ident::new( - &format!("{}_binding", &res.var_name.to_string()), + &format!("__{}_binding", &res.var_name.to_string()), res.var_name.span(), ); let var_name = &res.var_name; |
