aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_macros/src')
-rw-r--r--mingling_macros/src/dispatcher.rs5
-rw-r--r--mingling_macros/src/lib.rs25
-rw-r--r--mingling_macros/src/res_injection.rs5
-rw-r--r--mingling_macros/src/structural_data.rs1
4 files changed, 26 insertions, 10 deletions
diff --git a/mingling_macros/src/dispatcher.rs b/mingling_macros/src/dispatcher.rs
index 36bdf31..2a7c850 100644
--- a/mingling_macros/src/dispatcher.rs
+++ b/mingling_macros/src/dispatcher.rs
@@ -217,7 +217,10 @@ pub fn register_dispatcher(input: TokenStream) -> TokenStream {
} = syn::parse_macro_input!(input as RegisterDispatcherInput);
let node_name_str = node_name.value();
- let static_name = format!("__internal_dispatcher_{}", snake_case!(node_name_str.clone()));
+ let static_name = format!(
+ "__internal_dispatcher_{}",
+ snake_case!(node_name_str.clone())
+ );
let static_ident = Ident::new(&static_name, proc_macro2::Span::call_site());
// Register node info in the global collection at compile time
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs
index 546416d..c82466d 100644
--- a/mingling_macros/src/lib.rs
+++ b/mingling_macros/src/lib.rs
@@ -241,10 +241,27 @@ pub(crate) fn check_duplicate_variant(
/// Checks if a stored entry string contains the given variant name.
/// Handles both "StructName => Variant," and "Self::Variant => ..." formats.
fn entry_has_variant(entry: &str, variant_name: &str) -> bool {
- entry.contains(&format!("=> {variant_name},"))
- || entry.contains(&format!("=> {variant_name} "))
- || entry.contains(&format!("=> {variant_name}"))
- || entry.contains(&format!(":: {variant_name} =>"))
+ let variant_match = format!("=> {variant_name}");
+
+ // "StructName => Variant," — exact match with trailing comma
+ if entry.contains(&format!("{variant_match},")) {
+ return true;
+ }
+ // "StructName => Variant " — exact match with trailing space
+ if entry.contains(&format!("{variant_match} ")) {
+ return true;
+ }
+ // "StructName => Variant" (fallback) — must NOT be followed by identifier chars
+ if let Some(idx) = entry.find(&variant_match) {
+ let after = idx + variant_match.len();
+ if after >= entry.len()
+ || !entry[after..].starts_with(|c: char| c.is_alphanumeric() || c == '_')
+ {
+ return true;
+ }
+ }
+ // "Self::Variant => ..." — match-arm existence check format
+ entry.contains(&format!(":: {variant_name} =>"))
}
/// Registers an outside-type as a member of a program group without modifying its definition.
diff --git a/mingling_macros/src/res_injection.rs b/mingling_macros/src/res_injection.rs
index f2952cc..09da889 100644
--- a/mingling_macros/src/res_injection.rs
+++ b/mingling_macros/src/res_injection.rs
@@ -160,10 +160,7 @@ pub(crate) fn generate_immut_resource_bindings<'a>(
/// Generates a unique binding name for a mutable resource variable.
fn mut_res_binding_name(var_name: &Ident) -> Ident {
- syn::Ident::new(
- &format!("__{}_binding", var_name),
- var_name.span(),
- )
+ syn::Ident::new(&format!("__{}_binding", var_name), var_name.span())
}
/// Wraps the function body in nested `__modify_res_and_return_route` closures for
diff --git a/mingling_macros/src/structural_data.rs b/mingling_macros/src/structural_data.rs
index 37fee0f..d556d8c 100644
--- a/mingling_macros/src/structural_data.rs
+++ b/mingling_macros/src/structural_data.rs
@@ -222,7 +222,6 @@ impl syn::parse::Parse for PackStructuralInput {
/// impl ::mingling::StructuralData for Info {}
/// ```
pub(crate) fn group_structural(input: TokenStream) -> TokenStream {
-
// Parse the same input as group!
let input_parsed = syn::parse_macro_input!(input as GroupStructuralInput);