diff --git a/app/src/browser/browser_model.rs b/app/src/browser/browser_model.rs index f3d0d4fb..07efc2f3 100644 --- a/app/src/browser/browser_model.rs +++ b/app/src/browser/browser_model.rs @@ -1,3 +1,7 @@ +// The persistence snapshot + tab-strip scaffolding compile on wasm +// (they're plain serde types) but no caller exercises them there. +#![cfg_attr(target_family = "wasm", allow(dead_code))] + pub const DEFAULT_BROWSER_URL: &str = "about:home"; use serde::{Deserialize, Serialize}; diff --git a/app/src/browser/browser_view.rs b/app/src/browser/browser_view.rs index a48e5798..8b669523 100644 --- a/app/src/browser/browser_view.rs +++ b/app/src/browser/browser_view.rs @@ -1,3 +1,8 @@ +// BrowserView is a non-wasm-only render surface; many of its helpers +// (persistence import, internal model accessor) compile on wasm but +// the WKWebView-driven code paths that consume them don't. +#![cfg_attr(target_family = "wasm", allow(dead_code, unused_imports))] + use std::collections::HashMap; use std::{cell::RefCell, rc::Rc}; diff --git a/app/src/browser/find.rs b/app/src/browser/find.rs index 20987aa9..7774aef8 100644 --- a/app/src/browser/find.rs +++ b/app/src/browser/find.rs @@ -1,3 +1,8 @@ +// Find scripts only run from the native (non-wasm) wry webview host; +// on wasm the JS strings + helper functions exist in tree but are +// unreachable. Allow dead_code on wasm builds only. +#![cfg_attr(target_family = "wasm", allow(dead_code))] + //! Find-in-page overlay model + injected JS glue. //! //! The overlay is a thin row that renders below the toolbar when active. diff --git a/app/src/browser/persistence.rs b/app/src/browser/persistence.rs index 8df03458..df25a30f 100644 --- a/app/src/browser/persistence.rs +++ b/app/src/browser/persistence.rs @@ -1,3 +1,7 @@ +// Persistence is only invoked from the native (non-wasm) browser pane +// path. On wasm the helpers exist but are never called. +#![cfg_attr(target_family = "wasm", allow(dead_code))] + //! Persistence of `BrowserState` to a JSON file under the CastCodes //! support directory. Atomic write via temp-file + rename. Load is //! lenient: any failure (missing file, malformed JSON, unknown version) diff --git a/app/src/browser/webview_host.rs b/app/src/browser/webview_host.rs index 5299e5cd..b478e2b6 100644 --- a/app/src/browser/webview_host.rs +++ b/app/src/browser/webview_host.rs @@ -1,3 +1,7 @@ +// wry's WKWebView wrapper has no wasm backend; the struct + methods +// compile on wasm but never get invoked. +#![cfg_attr(target_family = "wasm", allow(dead_code))] + #[cfg(target_os = "macos")] use std::{ffi::c_void, ptr::NonNull}; diff --git a/app/src/settings_view/import_theme_modal.rs b/app/src/settings_view/import_theme_modal.rs index ec3345ec..a54cdab6 100644 --- a/app/src/settings_view/import_theme_modal.rs +++ b/app/src/settings_view/import_theme_modal.rs @@ -11,10 +11,12 @@ use std::time::Duration; use crate::appearance::Appearance; use crate::editor::{EditorView, Event as EditorEvent, SingleLineEditorOptions}; use crate::modal::Modal; -use crate::themes::theme::{CustomTheme, ThemeKind}; -use crate::themes::tweakcn_import::{ - extract_theme_id, fetch_share_url, write_imported, GamutPolicy, ImportError, ParsedBlocks, -}; +#[cfg(feature = "local_fs")] +use crate::themes::theme::CustomTheme; +use crate::themes::theme::ThemeKind; +use crate::themes::tweakcn_import::{extract_theme_id, fetch_share_url, ImportError, ParsedBlocks}; +#[cfg(feature = "local_fs")] +use crate::themes::tweakcn_import::{write_imported, GamutPolicy}; #[cfg(feature = "local_fs")] use crate::user_config; use warpui::elements::{ diff --git a/app/src/terminal/view/tab_metadata.rs b/app/src/terminal/view/tab_metadata.rs index 304c89ae..c62f456d 100644 --- a/app/src/terminal/view/tab_metadata.rs +++ b/app/src/terminal/view/tab_metadata.rs @@ -37,6 +37,7 @@ impl GitLabel { /// `git_dir` is the per-worktree gitdir (e.g. `/repo/.git/worktrees/feature-a`). /// `common_dir` is the shared gitdir (e.g. `/repo/.git`). /// When they're equal, the CWD is in the main worktree. +#[cfg(any(feature = "local_fs", test))] fn compute_git_label_from_paths( cwd: &std::path::Path, branch: Option, diff --git a/crates/lsp/src/model.rs b/crates/lsp/src/model.rs index 71848b84..44c8dc4e 100644 --- a/crates/lsp/src/model.rs +++ b/crates/lsp/src/model.rs @@ -1,7 +1,9 @@ +#[cfg(not(target_arch = "wasm32"))] +use crate::supported_servers::LspStartupError; use crate::{ config::{lsp_uri_to_path, LanguageId}, server_repo_watcher::LspRepoWatcher, - supported_servers::{LSPServerType, LspStartupError, LspStartupFailureReason}, + supported_servers::{LSPServerType, LspStartupFailureReason}, types::{ DefinitionLocation, DocumentVersion, HoverResult, Location, ReferenceLocation, TextDocumentContentChangeEvent, TextEdit, WatchedFileChangeEvent, diff --git a/crates/lsp/src/supported_servers.rs b/crates/lsp/src/supported_servers.rs index 5b5b55f0..77867526 100644 --- a/crates/lsp/src/supported_servers.rs +++ b/crates/lsp/src/supported_servers.rs @@ -128,6 +128,9 @@ pub struct LspStartupError { } impl LspStartupError { + // Only constructed by the non-wasm `LspServerModel::start` path; gate + // to match so wasm clippy doesn't flag the constructor as dead code. + #[cfg(not(target_arch = "wasm32"))] pub(crate) fn missing_binary(server_type: LSPServerType) -> Self { Self { reason: LspStartupFailureReason::MissingBinary { server_type }, diff --git a/crates/warp_cli/src/lib.rs b/crates/warp_cli/src/lib.rs index ad58b96b..b5cf3eea 100644 --- a/crates/warp_cli/src/lib.rs +++ b/crates/warp_cli/src/lib.rs @@ -1,6 +1,8 @@ #![cfg_attr(target_family = "wasm", allow(dead_code))] -use std::{env, ffi::OsString, fmt, path::Path}; +#[cfg(not(target_family = "wasm"))] +use std::ffi::OsString; +use std::{env, fmt, path::Path}; use clap::{CommandFactory, Parser, Subcommand, ValueEnum}; use url::Url;