From d28dbd820af73aa9dc93d2df6c89d6f8c840e907 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 18 Aug 2026 05:18:48 +0800 Subject: fix: generate async-compatible empty do_chain fallback When a program declares no chains, the synthesized `do_chain` now respects the `async` feature by emitting a boxed future signature with a `Box::pin(async { panic! })` body, matching the trait requirement and fixing E0053 in async builds. --- mingling_macros/src/func/program_final_gen.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'mingling_macros') diff --git a/mingling_macros/src/func/program_final_gen.rs b/mingling_macros/src/func/program_final_gen.rs index 8123eaf..ceee66d 100644 --- a/mingling_macros/src/func/program_final_gen.rs +++ b/mingling_macros/src/func/program_final_gen.rs @@ -273,9 +273,25 @@ pub(crate) fn program_final_gen_impl(_input: TokenStream) -> TokenStream { .collect(); let do_chain_fn = if chain_tokens.is_empty() { - quote! { - fn do_chain(_any: ::mingling::AnyOutput) -> ::mingling::ChainProcess { - ::core::panic!("No chain found for type id") + // An empty chain list is still valid, but the synthesized `do_chain` + // must match the trait signature for the enabled mode. The sync + // branch used unconditionally breaks the `async` feature (E0053), + // so dispatch on `ASYNC_ENABLED` here as well. + if ASYNC_ENABLED { + quote! { + fn do_chain( + _any: ::mingling::AnyOutput, + ) -> ::std::pin::Pin<::std::boxed::Box> + ::std::marker::Send>> { + ::std::boxed::Box::pin(async { + ::core::panic!("No chain found for type id") + }) + } + } + } else { + quote! { + fn do_chain(_any: ::mingling::AnyOutput) -> ::mingling::ChainProcess { + ::core::panic!("No chain found for type id") + } } } } else if ASYNC_ENABLED { -- cgit