diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-23 01:12:01 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-23 01:12:01 +0800 |
| commit | 8498a8c4826a10c8c04ad1b9c45d83fb0759121b (patch) | |
| tree | 532792a6ce9d57306238a2f3489d222908afa8f5 /mingling_macros/src/lib.rs | |
| parent | 514357b74e66c3eb626ca51a818c816a82ffc85f (diff) | |
Add entry-str dedup and registry cleanup in final gen
Diffstat (limited to 'mingling_macros/src/lib.rs')
| -rw-r--r-- | mingling_macros/src/lib.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs index 5bc73a4..8aa16f2 100644 --- a/mingling_macros/src/lib.rs +++ b/mingling_macros/src/lib.rs @@ -199,11 +199,16 @@ pub(crate) static HELP_REQUESTS: Registry = OnceLock::new(); /// Returns a `compile_error` token stream if a duplicate is found. pub(crate) fn check_duplicate_variant( set: &std::collections::BTreeSet<String>, + entry_str: &str, variant_name: &str, kind: &str, error_span: proc_macro2::Span, ) -> Result<(), proc_macro2::TokenStream> { for existing in set.iter() { + if existing == entry_str { + // Exact same entry - re-registration from RA re-analysis, skip + continue; + } if entry_has_variant(existing, variant_name) { return Err(syn::Error::new( error_span, @@ -1972,6 +1977,23 @@ pub fn program_final_gen(_input: TokenStream) -> TokenStream { } }; + // Clear all global registries to prevent stale state in Rust Analyzer + get_global_set(&PACKED_TYPES).lock().unwrap().clear(); + get_global_set(&CHAINS).lock().unwrap().clear(); + get_global_set(&CHAINS_EXIST).lock().unwrap().clear(); + get_global_set(&RENDERERS).lock().unwrap().clear(); + get_global_set(&RENDERERS_EXIST).lock().unwrap().clear(); + get_global_set(&HELP_REQUESTS).lock().unwrap().clear(); + #[cfg(feature = "comp")] + get_global_set(&COMPLETIONS).lock().unwrap().clear(); + #[cfg(feature = "dispatch_tree")] + get_global_set(&COMPILE_TIME_DISPATCHERS) + .lock() + .unwrap() + .clear(); + #[cfg(feature = "general_renderer")] + get_global_set(&GENERAL_RENDERERS).lock().unwrap().clear(); + TokenStream::from(expanded) } |
