From c64b9886ef2dbe71a9fd01e25b6f46620c0ed2b2 Mon Sep 17 00:00:00 2001 From: Jeff Shumate Date: Mon, 13 Jul 2026 17:08:47 -0700 Subject: [PATCH] Fix wasm32 build without the wasm feature The wasm32 `Instant(u64)` struct and impl were gated on `target_arch = "wasm32"` alone, but the `performance_now` extern and the `TryInto` import they depend on were gated on the `wasm` feature. A wasm32 build without `wasm` therefore selected the browser `Instant` without the code it needs, failing to compile with: error[E0425]: cannot find function `performance_now` in this scope error[E0599]: no method named `try_into` found for type `u128` `performance_now` is a browser API (`performance.now()` via wasm-bindgen), so gate the JS `Instant` on `all(target_arch = "wasm32", feature = "wasm")` and let every other wasm32 target (e.g. WASI, which has a monotonic clock) fall through to the `std::time::Instant` wrapper. Only the cfg predicates change. Signed-off-by: Jeff Shumate --- biscuit-auth/src/time.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/biscuit-auth/src/time.rs b/biscuit-auth/src/time.rs index 69b87f24..65fd0439 100644 --- a/biscuit-auth/src/time.rs +++ b/biscuit-auth/src/time.rs @@ -14,11 +14,11 @@ use wasm_bindgen::prelude::*; pub use std::time::*; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(all(target_arch = "wasm32", feature = "wasm")))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Instant(std::time::Instant); -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(all(target_arch = "wasm32", feature = "wasm")))] #[allow(dead_code)] impl Instant { pub fn now() -> Self { @@ -48,11 +48,11 @@ extern "C" { fn performance_now() -> f64; } -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", feature = "wasm"))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Instant(u64); -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", feature = "wasm"))] impl Instant { pub fn now() -> Self { Self((performance_now() * 1000.0) as u64)