mirror of
https://github.com/nushell/nushell.git
synced 2025-08-17 08:21:22 +02:00
Replace std::time::Instant
with web_time::Instant
(#14668)
# Description The `std::time::Instant` type panics in the WASM context. To prevent this, I replaced all uses of `std::time::Instant` in WASM-relevant crates with `web_time::Instant`. This ensures commands using `Instant` work in WASM without issues. For non-WASM targets, `web-time` simply reexports `std::time`, so this change doesn’t affect regular builds ([docs](https://docs.rs/web-time/latest/web_time/)). To ensure future code doesn't reintroduce `std::time::Instant` in WASM contexts, I added a `clippy wasm` command to the toolkit. This runs `cargo clippy` with a `clippy.toml` configured to disallow `std::time::Instant`. Since `web-time` aliases `std::time` by default, the `clippy.toml` is stored in `clippy/wasm` and is only loaded when targeting WASM. I also added a new CI job that tests this too. # User-Facing Changes None.
This commit is contained in:
@ -20,6 +20,7 @@ libc = { workspace = true }
|
||||
log = { workspace = true }
|
||||
sysinfo = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
web-time = { workspace = true }
|
||||
|
||||
[target.'cfg(target_family = "unix")'.dependencies]
|
||||
nix = { workspace = true, default-features = false, features = ["fs", "term", "process", "signal"] }
|
||||
|
@ -18,7 +18,8 @@ use std::ptr;
|
||||
use std::ptr::null_mut;
|
||||
use std::sync::LazyLock;
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::Duration;
|
||||
use web_time::Instant;
|
||||
|
||||
use windows::core::{PCWSTR, PWSTR};
|
||||
|
||||
|
Reference in New Issue
Block a user