Skip to content

fix(clippy): platform-specific dead_code on Windows + wasm#159

Merged
BunsDev merged 5 commits into
mainfrom
fix/clippy-windows-wasm-platform-gates
May 27, 2026
Merged

fix(clippy): platform-specific dead_code on Windows + wasm#159
BunsDev merged 5 commits into
mainfrom
fix/clippy-windows-wasm-platform-gates

Conversation

@BunsDev

@BunsDev BunsDev commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

Round 3 of the heavy-CI clippy fallout. PR #157 landed the Linux clippy fixes and main is now green for Linux `Formatting + Clippy`. But the Windows + wasm clippy jobs still fail on two platform-specific lints that Linux didn't trigger.

  • `cast_agent/src/comux.rs:23,29` — gate `ListPanesRequest` and `ListPanesResponse` to `#[cfg(unix)]` to match their only call site (the unix-only block at line 96). On Windows the structs compiled but no constructor existed, so dead_code fired.
  • `warp_cli/src/lib.rs:3` — split the `std::ffi::OsString` import out of the unconditional `use std::{env, ffi::OsString, fmt, path::Path}` line and gate it to `#[cfg(not(target_family = "wasm"))]`. The three OsString-using helpers are already wasm-gated; the import was the holdout.

This was originally pushed as commit `b8345389` on `fix/cargo-fmt-on-main` after PR #157's CI surfaced these but before PR #157 was admin-merged at `cf52100b` — so it landed on the now-merged branch instead of main. Cherry-picked here onto fresh main.

No behavioural changes.

Test plan

  • Windows `Formatting + Clippy` passes
  • wasm `Formatting + Clippy` passes
  • Linux `Formatting + Clippy` still passes (regression check)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 27, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

BunsDev and others added 5 commits May 27, 2026 04:45
PR #157's first heavy CI run validated the Linux clippy fix (passes
green) but surfaced two additional platform-specific lints that
Linux didn't trigger:

- cast_agent/src/comux.rs: gate `ListPanesRequest` and
  `ListPanesResponse` to `#[cfg(unix)]` to match the only call site
  (the unix-only block at line 96). On Windows the structs compiled
  but no constructor existed, so dead_code fired.

- warp_cli/src/lib.rs: split the `std::ffi::OsString` import out of
  the unconditional `use std::{env, ffi::OsString, ...}` line and
  gate it to `#[cfg(not(target_family = "wasm"))]`, matching the
  three OsString-using helpers that are already wasm-gated.

No behavioural changes; just import + cfg housekeeping.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rustfmt sorts imports lexically with attributes attaching to their
import. My split of `std::ffi::OsString` out of the unconditional
`use std::{env, ffi::OsString, fmt, path::Path};` line landed in the
wrong order:

    use std::{env, fmt, path::Path};
    #[cfg(not(target_family = "wasm"))]
    use std::ffi::OsString;

rustfmt wants the cfg-gated single-item use first:

    #[cfg(not(target_family = "wasm"))]
    use std::ffi::OsString;
    use std::{env, fmt, path::Path};

Linux/Windows/wasm fmt jobs all caught this on the first CI run.
Clippy itself is fine — only fmt needed the reorder.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two more wasm-only clippy errors surfaced once #157's main-side fmt
fixes shipped:

- crates/lsp/src/model.rs: split `LspStartupError` out of the
  unconditional `use ... supported_servers::{...}` group. The only
  usage (the downcast inside `LspServerModel::start`) is already
  `#[cfg(not(target_arch = "wasm32"))]`; the import is now too.

- crates/lsp/src/supported_servers.rs: gate
  `LspStartupError::missing_binary` to non-wasm too. It's the only
  constructor of `LspStartupError`, and only `start` calls it, so
  on wasm the function was unused.

No behavioural changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tem use

Same rustfmt ordering rule as in warp_cli/src/lib.rs: a cfg-gated
single-item `use` should come before the unconditional multi-item
group. CI fmt caught this on the previous push.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The browser pane and a handful of related helpers compile on wasm but
no caller exercises them there (wry has no wasm backend; tweakcn
imports require `local_fs`; the git label helper is local_fs-only).
Result: ~15 wasm-clippy dead_code errors that don't fire on Linux or
Windows.

Three different fixes, picked per file:

1. Module-level `#![cfg_attr(target_family = "wasm", allow(dead_code))]`
   on the browser scaffolding that has no wasm consumer:
   - browser/find.rs (the FIND_SCRIPT JS strings + helpers)
   - browser/persistence.rs (state_path / load / save)
   - browser/browser_model.rs (BrowserState, TabSnapshot,
     BROWSER_STATE_VERSION, snapshot/restore)
   - browser/webview_host.rs (detach_native and friends)
   - browser/browser_view.rs (the `model` accessor and the
     `persistence` import); also `unused_imports` since
     `super::persistence` is unused on wasm.

2. Feature-gated imports in settings_view/import_theme_modal.rs:
   CustomTheme, write_imported, GamutPolicy are only used from inside
   the `#[cfg(feature = "local_fs")]` block at line 162, so gate the
   imports the same way. (CustomTheme import alphabetized before
   ThemeKind to satisfy rustfmt's group ordering.)

3. Feature-gated function in terminal/view/tab_metadata.rs:
   `compute_git_label_from_paths` is only called from the
   `#[cfg(feature = "local_fs")]` block in current_git_label; tests
   still need it on all platforms, so `#[cfg(any(feature = "local_fs",
   test))]`.

No behavioural changes. Local `cargo fmt --check` clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@BunsDev BunsDev force-pushed the fix/clippy-windows-wasm-platform-gates branch from f72bdc3 to 59e9f9b Compare May 27, 2026 09:45
@BunsDev BunsDev merged commit 1d60c50 into main May 27, 2026
9 checks passed
@BunsDev BunsDev deleted the fix/clippy-windows-wasm-platform-gates branch May 30, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants