From 8cd80ce0c61189394c8754de6dc9bb3a42ee9ffc Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Sun, 23 Aug 2026 23:25:52 -0500 Subject: [PATCH] chore: Stop rust-analyzer from marking all #[hook] macros as inactive_code This change adds `#[allow(rust_analyzer::inactive_code)]` to the `#[cfg(doctest)]` copy of a hooked function that `#[hook]` emits alongside the real implementation. A recent rust-analyzer change now diagnoses inactive `#[cfg]` branches whose tokens trace back to user-written source, and since that doctest-only copy reuses the original function spans verbatim, it makes rust-analyzer grey out the hook's real body in the editor. The allow is scoped to that inert copy only, so genuine `#[cfg]` usage inside a hook's own body is still diagnosed normally. --- packages/yew-macro/src/hook/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/yew-macro/src/hook/mod.rs b/packages/yew-macro/src/hook/mod.rs index 3989b51174a..e9384786dc9 100644 --- a/packages/yew-macro/src/hook/mod.rs +++ b/packages/yew-macro/src/hook/mod.rs @@ -240,6 +240,7 @@ pub fn hook_impl(hook: HookFn) -> syn::Result { } #[cfg(doctest)] + #[allow(rust_analyzer::inactive_code)] #original_fn };