Patch lazy_static to std::sync::LazyLock

This does remove the no-`std` variant of `lazy_static`, but that was unused and
`std` was not additively implemented (making it poor to work with).

This primarily tidies our `deny.toml` with one less `git` dependency.
This commit is contained in:
Luke Parker
2025-12-11 03:48:33 -05:00
parent 5a3cf1f2be
commit ee9b9778b5
5 changed files with 34 additions and 8 deletions

3
Cargo.lock generated
View File

@@ -4148,8 +4148,7 @@ dependencies = [
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "git+https://github.com/rust-lang-nursery/lazy-static.rs?rev=5735630d46572f1e5377c8f2ba0f79d18f53b10c#5735630d46572f1e5377c8f2ba0f79d18f53b10c"
version = "1.99.0"
[[package]]
name = "leb128fmt"

View File

@@ -200,8 +200,9 @@ dalek-ff-group = { path = "patches/dalek-ff-group" }
minimal-ed448 = { path = "crypto/ed448" }
modular-frost = { path = "crypto/frost" }
# Patch due to `std` now including the required functionality
is_terminal_polyfill = { path = "./patches/is_terminal_polyfill" }
# Patches due to `std` now including the required functionality
is_terminal_polyfill = { path = "patches/is_terminal_polyfill" }
lazy_static = { path = "patches/lazy_static" }
# This has a non-deprecated `std` alternative since Rust's 2024 edition
home = { path = "patches/home" }
@@ -209,9 +210,6 @@ home = { path = "patches/home" }
darling = { path = "patches/darling" }
thiserror = { path = "patches/thiserror" }
# https://github.com/rust-lang-nursery/lazy-static.rs/issues/201
lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev = "5735630d46572f1e5377c8f2ba0f79d18f53b10c" }
# directories-next was created because directories was unmaintained
# directories-next is now unmaintained while directories is maintained
# The directories author pulls in ridiculously pointless crates and prefers

View File

@@ -147,7 +147,6 @@ unknown-registry = "deny"
unknown-git = "deny"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
allow-git = [
"https://github.com/rust-lang-nursery/lazy-static.rs",
"https://github.com/kayabaNerve/elliptic-curves",
"https://github.com/monero-oxide/monero-oxide",
"https://github.com/serai-dex/patch-polkadot-sdk",

View File

@@ -0,0 +1,16 @@
[package]
name = "lazy_static"
version = "1.99.0"
description = "`lazy_static` which patches to `std::sync::LazyLock`"
license = "MIT"
repository = "https://github.com/serai-dex/serai/tree/develop/patches/lazy_static"
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
keywords = []
edition = "2021"
rust-version = "1.80"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
[workspace]

View File

@@ -0,0 +1,14 @@
#[macro_export]
macro_rules! lazy_static {
($($(#[$attr: meta])* $vis: vis static ref $name: ident: $type: ty = $value: expr;)*) => {
$(
$(#[$attr])*
$vis static $name: std::sync::LazyLock<$type> = std::sync::LazyLock::new(|| $value);
)*
}
}
/// Explicitly initialize a static declared with [`lazy_static`].
pub fn initialize<T, F: Fn() -> T>(lazy: &std::sync::LazyLock<T, F>) {
std::sync::LazyLock::force(lazy);
}