diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-28 19:14:35 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-28 19:14:35 +0800 |
| commit | a11628efe9288739f5066af20121a6cda114e5f5 (patch) | |
| tree | ee3bb56e62fcdd7785b36de4895f3b8d3c527bd8 /mingling_macros/src | |
| parent | 2dff21cc78fd2d6a4fa4f227f6ad94e3f7baa943 (diff) | |
refactor(macros): move pathf include from gen_program into
program_final_gen
Diffstat (limited to 'mingling_macros/src')
| -rw-r--r-- | mingling_macros/src/func/gen_program.rs | 10 | ||||
| -rw-r--r-- | mingling_macros/src/func/program_final_gen.rs | 12 |
2 files changed, 12 insertions, 10 deletions
diff --git a/mingling_macros/src/func/gen_program.rs b/mingling_macros/src/func/gen_program.rs index 6b6a643..c5358bc 100644 --- a/mingling_macros/src/func/gen_program.rs +++ b/mingling_macros/src/func/gen_program.rs @@ -15,15 +15,6 @@ pub(crate) fn gen_program_impl(_input: TokenStream) -> TokenStream { #[cfg(not(feature = "comp"))] let comp_gen = quote! {}; - // When pathf is enabled, include the type_using.rs generated by the build - // script so that types from submodules are in scope for gen_program!(). - #[cfg(feature = "pathf")] - let pathf_include = quote! { - include!(concat!(env!("OUT_DIR"), "/", env!("CARGO_PKG_NAME"), "/type_using.rs")); - }; - #[cfg(not(feature = "pathf"))] - let pathf_include = quote! {}; - TokenStream::from(quote! { /// Alias for the current program type `crate::ThisProgram` pub type Next = ::mingling::ChainProcess<crate::ThisProgram>; @@ -49,7 +40,6 @@ pub(crate) fn gen_program_impl(_input: TokenStream) -> TokenStream { } } - #pathf_include #comp_gen ::mingling::macros::program_fallback_gen!(); ::mingling::macros::program_final_gen!(); diff --git a/mingling_macros/src/func/program_final_gen.rs b/mingling_macros/src/func/program_final_gen.rs index 41420a4..e427f05 100644 --- a/mingling_macros/src/func/program_final_gen.rs +++ b/mingling_macros/src/func/program_final_gen.rs @@ -280,6 +280,15 @@ pub(crate) fn program_final_gen_impl(_input: TokenStream) -> TokenStream { quote! { u128 } }; + // When pathf is enabled, include the type_using.rs generated by the build + // script so that types from submodules are in scope for gen_program!(). + #[cfg(feature = "pathf")] + let pathf_include = quote! { + include!(concat!(env!("OUT_DIR"), "/", env!("CARGO_PKG_NAME"), "/type_using.rs")); + }; + #[cfg(not(feature = "pathf"))] + let pathf_include = quote! {}; + let expanded = quote! { #[derive(Debug, PartialEq, Eq, Clone, Copy)] #[repr(#repr_type)] @@ -297,10 +306,13 @@ pub(crate) fn program_final_gen_impl(_input: TokenStream) -> TokenStream { } impl ::mingling::ProgramCollect for #name { + #pathf_include + type Enum = #name; type ErrorDispatcherNotFound = ErrorDispatcherNotFound; type ErrorRendererNotFound = ErrorRendererNotFound; type ResultEmpty = ResultEmpty; + fn build_renderer_not_found(member_id: Self::Enum) -> ::mingling::AnyOutput<Self::Enum> { ::mingling::AnyOutput::new(ErrorRendererNotFound::new(member_id.to_string())) } |
