From f2c13a0040d6b6c2de24af2af9bca1080109ef87 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 19 Aug 2025 13:36:01 -0400 Subject: [PATCH] Expose Once within std-shims, bump spin to 0.9 This is technically a semver break due to bumping spin to 0.10, with the types from spin being directly exposed. Long-term, we should not directly expose spin but instead have our own types which are thin wrappers around spin (clearly defining our API and allowing upgrading internals without breaking semver). --- Cargo.lock | 8 +++++++- common/std-shims/Cargo.toml | 2 +- common/std-shims/README.md | 7 ++++++- common/std-shims/src/sync.rs | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c953da7a..98f41495 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9613,6 +9613,12 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spin" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" + [[package]] name = "spki" version = "0.7.3" @@ -9689,7 +9695,7 @@ name = "std-shims" version = "0.1.2" dependencies = [ "hashbrown 0.14.5", - "spin 0.9.8", + "spin 0.10.0", ] [[package]] diff --git a/common/std-shims/Cargo.toml b/common/std-shims/Cargo.toml index ef746a64..5900ca6a 100644 --- a/common/std-shims/Cargo.toml +++ b/common/std-shims/Cargo.toml @@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"] workspace = true [dependencies] -spin = { version = "0.9", default-features = false, features = ["use_ticket_mutex", "lazy"] } +spin = { version = "0.10", default-features = false, features = ["use_ticket_mutex", "once", "lazy"] } hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] } [features] diff --git a/common/std-shims/README.md b/common/std-shims/README.md index 88f8eadd..b5bc121d 100644 --- a/common/std-shims/README.md +++ b/common/std-shims/README.md @@ -3,4 +3,9 @@ A crate which passes through to std when the default `std` feature is enabled, yet provides a series of shims when it isn't. -`HashSet` and `HashMap` are provided via `hashbrown`. +No guarantee of one-to-one parity is provided. The shims provided aim to be sufficient for the +average case. + +`HashSet` and `HashMap` are provided via `hashbrown`. Synchronization primitives are provided via +`spin` (avoiding a requirement on `critical-section`). +types are not guaranteed to be diff --git a/common/std-shims/src/sync.rs b/common/std-shims/src/sync.rs index 8193bcfb..14d32721 100644 --- a/common/std-shims/src/sync.rs +++ b/common/std-shims/src/sync.rs @@ -26,6 +26,6 @@ mod mutex_shim { pub use mutex_shim::{ShimMutex as Mutex, MutexGuard}; #[cfg(feature = "std")] -pub use std::sync::LazyLock; +pub use std::sync::{OnceLock, LazyLock}; #[cfg(not(feature = "std"))] -pub use spin::Lazy as LazyLock; +pub use spin::{Once as OnceLock, Lazy as LazyLock};