diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-28 19:59:21 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-28 19:59:21 +0800 |
| commit | e3c060b3281b6255c2cdebdcf2dda2a22a758662 (patch) | |
| tree | 2e98570320de3a591acfa7af7a6c45e0842b93e5 /mingling_macros/src/func/program_final_gen.rs | |
| parent | a11628efe9288739f5066af20121a6cda114e5f5 (diff) | |
feat(macros): wrap gen_program output in a hidden module
Move pathf type resolution from `program_final_gen` to `gen_program` and
isolate generated code inside `__this_program_impl` to prevent namespace
pollution
Diffstat (limited to 'mingling_macros/src/func/program_final_gen.rs')
| -rw-r--r-- | mingling_macros/src/func/program_final_gen.rs | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/mingling_macros/src/func/program_final_gen.rs b/mingling_macros/src/func/program_final_gen.rs index e427f05..0eed1db 100644 --- a/mingling_macros/src/func/program_final_gen.rs +++ b/mingling_macros/src/func/program_final_gen.rs @@ -36,8 +36,8 @@ fn parse_entry_pair(entry: &proc_macro2::TokenStream) -> (proc_macro2::Ident, pr } /// Helper: convert a string ident into a token stream for the generated code. -/// Types are now brought into scope by `gen_program!()` via `include!()` of the -/// pathf-generated `type_using.rs`, so bare idents suffice. +/// Types are expected to be in scope (e.g. via pathf glob re-exports), so bare +/// idents suffice. fn ident_tokens(name: &str) -> proc_macro2::TokenStream { let ident = proc_macro2::Ident::new(name, proc_macro2::Span::call_site()); quote! { #ident } @@ -280,15 +280,6 @@ 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)] @@ -306,8 +297,6 @@ 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; |
