From 7764da6ad85e9d5f2580b91e08b40c107e3b4312 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 16:27:30 -0800 Subject: [PATCH] Updates: Runtime derives Default on wasm32, so wasm32 clippy passes `cargo clippy --target wasm32-unknown-unknown -p vectorcraft-ui-egui -- -D warnings` stopped twice. In vectorcraft-text, MAX_FILE_SEARCHES is used only by the system font search, which is not compiled for wasm32, so it was dead code there. In vectorcraft-ui-egui, Runtime holds only manual_window_open and status_message on wasm32, and the hand-written Default set them to false and None, so clippy's derivable_impls stopped the run. - MAX_FILE_SEARCHES is compiled only for targets other than wasm32, like the SysFallback struct next to it. - Runtime derives Default on wasm32, and the hand-written Default, which creates the updater, is compiled only for other targets. --- crates/text/src/fontdb/names.rs | 1 + crates/ui-egui/src/updates_ui.rs | 11 ++--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/text/src/fontdb/names.rs b/crates/text/src/fontdb/names.rs index 7531b130ec..47faeeddae 100644 --- a/crates/text/src/fontdb/names.rs +++ b/crates/text/src/fontdb/names.rs @@ -15,6 +15,7 @@ pub(super) struct SysFallback { /// The most characters searched for in the font files themselves between two scans of the font /// folders. Real text has a few uncovered characters; a document of thousands of distinct /// private-use code points would reread the whole catalog for each. +#[cfg(not(target_arch = "wasm32"))] pub(super) const MAX_FILE_SEARCHES: u32 = 1024; /// Fonts made for Thai, tried first (when installed) for Thai the font in use lacks: Windows diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 77a00c33a5..41f5e68372 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -9,6 +9,7 @@ use craft_update::updater::{Action, Status, Updater}; #[cfg(not(target_arch = "wasm32"))] use craft_update::{CheckResultDialog, CheckResultResponse}; +#[cfg_attr(target_arch = "wasm32", derive(Default))] pub(crate) struct Runtime { #[cfg(not(target_arch = "wasm32"))] updater: Updater, @@ -30,23 +31,15 @@ pub(crate) struct Runtime { pub(crate) status_message: Option, } +#[cfg(not(target_arch = "wasm32"))] impl Default for Runtime { fn default() -> Self { Self { - #[cfg(not(target_arch = "wasm32"))] updater: Updater::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")), - #[cfg(not(target_arch = "wasm32"))] startup_check: false, - #[cfg(not(target_arch = "wasm32"))] check_requested: false, - #[cfg(not(target_arch = "wasm32"))] repaint: None, - #[cfg(not(target_arch = "wasm32"))] was_blocking: false, - #[cfg(target_arch = "wasm32")] - manual_window_open: false, - #[cfg(target_arch = "wasm32")] - status_message: None, } } }