From 771d212198013517a7434aa08ebae2344a856a15 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Thu, 1 May 2025 18:32:26 +0200 Subject: [PATCH] build: gate `web-time` behind `cfg(target_arch = "wasm32")` (#1086) --- Cargo.toml | 1 + src/time.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8e947f3..1eea7ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ sha2 = { version = "0.10", features = ["oid"], optional = true } rsa = { version = "0.9", optional = true } ed25519-dalek = { version = "2", optional = true } +[target.'cfg(target_arch = "wasm32")'.dependencies] ## web-time for wasm support web-time = { version = "1.1.0", optional = true } diff --git a/src/time.rs b/src/time.rs index 7b46b57..8a0760f 100644 --- a/src/time.rs +++ b/src/time.rs @@ -1,6 +1,6 @@ use std::time::SystemTime; -#[cfg(feature = "web")] +#[cfg(all(feature = "web", target_arch = "wasm32"))] pub(crate) fn now() -> SystemTime { fn to_std_systemtime(time: web_time::SystemTime) -> std::time::SystemTime { let duration = time @@ -18,7 +18,7 @@ pub(crate) fn now() -> SystemTime { to_std_systemtime(web_time::SystemTime::now()) } -#[cfg(not(feature = "web"))] +#[cfg(not(all(feature = "web", target_arch = "wasm32")))] pub(crate) fn now() -> SystemTime { // FIXME: change to #[expect(clippy::disallowed_methods, reason = "the `web` feature is disabled")] #[allow(clippy::disallowed_methods)]