diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-23 00:40:05 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-23 00:40:05 +0800 |
| commit | 1df1fc664c4a4b12807a49ef2f1a0effda6ce064 (patch) | |
| tree | a5bcdab31e18094b226d6cef36d99c879c64e25f /mingling_macros/src/completion.rs | |
| parent | d94103fd7e76dd86cd64c23f00c818165fb7dc22 (diff) | |
Add compile-time duplicate variant detection
Add duplicate variant checks for chain, renderer, help, and completion
registrations to produce a clear compile error instead of silently
generating unreachable code
Diffstat (limited to 'mingling_macros/src/completion.rs')
| -rw-r--r-- | mingling_macros/src/completion.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/mingling_macros/src/completion.rs b/mingling_macros/src/completion.rs index 452c418..c4870d9 100644 --- a/mingling_macros/src/completion.rs +++ b/mingling_macros/src/completion.rs @@ -153,6 +153,18 @@ pub fn completion_attr(attr: TokenStream, item: TokenStream) -> TokenStream { let mut completions = get_global_set(&crate::COMPLETIONS).lock().unwrap(); let completion_str = completion_entry.to_string(); + + // Check for duplicate variant before inserting + let variant_name = previous_type_ident.to_string(); + if let Err(err) = crate::check_duplicate_variant( + &completions, + &variant_name, + "completion", + previous_type_path.span(), + ) { + return err.into(); + } + completions.insert(completion_str); expanded.into() |
