From 7536a6a436353a4869e3c5c2825671c8708bd5bd Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 28 Apr 2026 10:17:50 +0000 Subject: [PATCH] chore: prune #[allow(dead_code)] cluster (#327) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit audit #327 listed 13 sites. count drifted to 10 (storage.rs and 2 others removed in earlier work). per-site breakdown: deletes (genuinely unused): - crates/web/src/app.rs::toggle_theme — never called; on_toggle_theme Callback wires through palette_actions, not this fn. remove redundant annotation (symbol used): - crates/web/src/palette_recents.rs::clear — used by browser tests. - crates/web/tests/browser.rs::TestShell, mount_test_with_shell, ensure_components_css_loaded, mod test_support — all referenced throughout browser.rs flow tests. - crates/web/src/state.rs::set_pinned_messages — used in state.rs:952. - crates/web/src/state.rs::set_pin_labels — fed by struct init only; field access not warned because crate-wide #![allow(dead_code)] in willow-web/src/lib.rs already masks it. annotation was redundant. - crates/web/src/components/mobile_shell.rs::MobilePush — match arms on Thread/Call/Onboarding count as use; no warning even when one variant is constructed. keep with reason: - crates/actor/src/fsm.rs::DoorState::Open — test fixture for StrictDoor rejection path; never constructed because tests start in Closed and assert further transitions are rejected. Kept with #[allow(dead_code, reason = ...)] (rust 1.81+). verification: cargo check --workspace --all-targets clean; cargo clippy -D warnings clean; cargo test --workspace passes; wasm32 lib + tests build clean. scope-creep guard hit: removing willow-web's crate-wide #![allow(dead_code)] surfaces 9 unrelated dead symbols across 5 files. left as-is — separate follow-up. Refs #327 --- crates/actor/src/fsm.rs | 5 ++++- crates/web/src/app.rs | 8 -------- crates/web/src/components/mobile_shell.rs | 1 - crates/web/src/palette_recents.rs | 1 - crates/web/src/state.rs | 2 -- crates/web/tests/browser.rs | 4 ---- 6 files changed, 4 insertions(+), 17 deletions(-) diff --git a/crates/actor/src/fsm.rs b/crates/actor/src/fsm.rs index 4e359059..303e9a0d 100644 --- a/crates/actor/src/fsm.rs +++ b/crates/actor/src/fsm.rs @@ -215,7 +215,10 @@ mod tests { struct StrictDoor; #[derive(Debug, Clone, PartialEq)] - #[allow(dead_code)] + #[allow( + dead_code, + reason = "Open variant exists for completeness; tests start in Closed and assert StrictDoor rejects further transitions." + )] enum DoorState { Open, Closed, diff --git a/crates/web/src/app.rs b/crates/web/src/app.rs index fe896bf9..2b31d1bf 100644 --- a/crates/web/src/app.rs +++ b/crates/web/src/app.rs @@ -45,14 +45,6 @@ fn detect_platform() -> &'static str { } } -#[allow(dead_code)] -pub fn toggle_theme() { - js_sys::eval( - r#"var h=document.documentElement;var c=h.getAttribute('data-theme')||'dark';var n=c==='dark'?'light':'dark';h.setAttribute('data-theme',n);localStorage.setItem('willow-theme',n);"#, - ) - .ok(); -} - /// How many milliseconds to wait before clearing the loading state automatically. const LOADING_TIMEOUT_MS: u32 = 5_000; diff --git a/crates/web/src/components/mobile_shell.rs b/crates/web/src/components/mobile_shell.rs index 2f87d7ed..1741479c 100644 --- a/crates/web/src/components/mobile_shell.rs +++ b/crates/web/src/components/mobile_shell.rs @@ -60,7 +60,6 @@ impl MobileTab { /// Full-screen pushes that can be stacked over a primary tab. Each /// push hides the tab bar and renders translated in from the right. #[derive(Clone, PartialEq, Eq, Debug)] -#[allow(dead_code)] pub enum MobilePush { /// Channel chat view (name = channel id). Channel(String), diff --git a/crates/web/src/palette_recents.rs b/crates/web/src/palette_recents.rs index 4040f948..f360e412 100644 --- a/crates/web/src/palette_recents.rs +++ b/crates/web/src/palette_recents.rs @@ -61,7 +61,6 @@ pub fn push(entry: Recent) { } /// Clear all recents. -#[allow(dead_code)] pub fn clear() { if let Some(s) = storage() { let _ = s.remove_item(KEY); diff --git a/crates/web/src/state.rs b/crates/web/src/state.rs index 5279c681..e1d55e85 100644 --- a/crates/web/src/state.rs +++ b/crates/web/src/state.rs @@ -358,9 +358,7 @@ pub struct ChatWriteSignals { pub set_channels: WriteSignal>, pub set_replying_to: WriteSignal>, pub set_editing: WriteSignal>, - #[allow(dead_code)] pub set_pinned_messages: WriteSignal>, - #[allow(dead_code)] pub set_pin_labels: WriteSignal>, pub set_channel_views: WriteSignal>, } diff --git a/crates/web/tests/browser.rs b/crates/web/tests/browser.rs index bc8e4a5d..4a8869b4 100644 --- a/crates/web/tests/browser.rs +++ b/crates/web/tests/browser.rs @@ -42,7 +42,6 @@ where /// [`mount_test_with_shell`] to pin the choice via a `data-shell` /// attribute on ``. #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[allow(dead_code)] pub enum TestShell { Desktop, Mobile, @@ -54,7 +53,6 @@ pub enum TestShell { /// `.shell-desktop` / `.shell-mobile` visibility on that attribute /// when present (falls back to the viewport media query when the /// attribute is absent). -#[allow(dead_code)] pub fn mount_test_with_shell(shell: TestShell, view: F) -> web_sys::HtmlElement where F: FnOnce() -> V + 'static, @@ -80,7 +78,6 @@ where /// does not pull in the app's CSS via `index.html`; without this, every /// element keeps its UA-default `display` and the shell override cannot /// be observed. -#[allow(dead_code)] fn ensure_components_css_loaded(doc: &web_sys::Document) { const STYLE_ID: &str = "willow-test-components-css"; if doc.get_element_by_id(STYLE_ID).is_some() { @@ -5771,7 +5768,6 @@ mod notifications { /// `mobile_actions`). Each group used to carry its own copies of /// `click_selector` / `fill_selector` / etc.; they are hoisted here so /// new modules can reuse them without duplication. -#[allow(dead_code)] mod test_support { use super::*; use willow_web::app::App;