diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-22 20:21:41 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-22 20:21:41 +0800 |
| commit | d7c9ad94113cca2f782666e37a0aa4fb7b8d7d86 (patch) | |
| tree | 323dfc74a274463500ac52c7bb7b83029b771411 /mingling_macros/src/lib.rs | |
| parent | 232f31c6649e6348a5b0b64362f185f7f4db1dc0 (diff) | |
Support qualified type paths in four macros
Diffstat (limited to 'mingling_macros/src/lib.rs')
| -rw-r--r-- | mingling_macros/src/lib.rs | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs index e774335..204d59c 100644 --- a/mingling_macros/src/lib.rs +++ b/mingling_macros/src/lib.rs @@ -195,35 +195,6 @@ pub(crate) static CHAINS_EXIST: Registry = OnceLock::new(); pub(crate) static RENDERERS_EXIST: Registry = OnceLock::new(); pub(crate) static HELP_REQUESTS: Registry = OnceLock::new(); -/// Checks that a `TypePath` is a simple single-segment identifier (no `::` in the path). -/// -/// This is used by `#[renderer]`, `#[help]`, `#[chain]`, and `#[completion]` attribute macros -/// to ensure that the type in the function signature is a bare identifier like `Empty`, -/// not a qualified path like `other::Empty`. -/// -/// Returns `None` if the type is valid, or a `compile_error!` token stream if it contains `::`. -pub(crate) fn check_single_segment_type( - type_path: &syn::TypePath, - attr_name: &str, -) -> Option<proc_macro2::TokenStream> { - if type_path.path.segments.len() > 1 { - let type_str = quote! { #type_path }; - Some(quote! { - compile_error!(concat!( - "The type `", - #type_str, - "` in ", - #attr_name, - " function must be a simple single-segment type, ", - "e.g. `Empty` instead of `other::Empty`. ", - "Qualified paths with `::` are not allowed here." - )); - }) - } else { - None - } -} - /// Registers an outside-type as a member of a program group without modifying its definition. /// /// This macro allows you to use outside-types from external crates (like `std::io::Error`) |
