From acd33f4db75ad45d08ee3ee9a91ea6cf504c1534 Mon Sep 17 00:00:00 2001 From: Spenser Black Date: Mon, 12 Aug 2024 15:49:32 +0000 Subject: [PATCH] Drop `once_cell::sync::Lazy` in favor of `std::sync::LazyLock` This almost completely drops the `once_cell` crate, but `OnceCell` is still in use. While the `OnceCell` type is available in the standard library, the `get_or_try_init` method is not yet stabilized. This bumps the MSRV up to 1.80, which is the first version to stabilize `std::sync::LazyLock`. --- .github/workflows/msrv.yml | 2 +- Cargo.lock | 10 ---------- Cargo.toml | 1 - clippy.toml | 2 +- etc/msrv-badge.svg | 6 +++--- gix-config/Cargo.toml | 3 +-- gix-credentials/Cargo.toml | 1 - .../tests/program/from_custom_definition.rs | 4 ++-- gix-date/Cargo.toml | 1 - gix-date/tests/time/baseline.rs | 4 ++-- gix-fsck/tests/connectivity/mod.rs | 4 ++-- gix-path/Cargo.toml | 3 +-- gix-path/src/env/git/mod.rs | 12 ++++++------ gix-path/src/env/mod.rs | 6 +++--- gix-pathspec/Cargo.toml | 1 - gix-pathspec/tests/parse/mod.rs | 4 ++-- gix-refspec/tests/matching/mod.rs | 8 ++++---- gix-tempfile/Cargo.toml | 3 +-- gix-tempfile/src/lib.rs | 4 ++-- gix-tempfile/src/signal.rs | 4 ++-- gix-url/tests/baseline.rs | 10 +++++----- gix-worktree-state/tests/Cargo.toml | 1 - gix-worktree-state/tests/state/checkout.rs | 6 +++--- gix-worktree-stream/tests/stream.rs | 5 ++--- gix/Cargo.toml | 3 +-- gix/src/interrupt.rs | 13 ++++++++----- .../config/config_snapshot/credential_helpers.rs | 4 ++-- gix/tests/revision/spec/from_bytes/util.rs | 4 ++-- src/shared.rs | 2 +- tests/tools/Cargo.toml | 1 - tests/tools/src/lib.rs | 12 ++++++------ 31 files changed, 63 insertions(+), 81 deletions(-) diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml index e65d54c188c..9cb0c9df669 100644 --- a/.github/workflows/msrv.yml +++ b/.github/workflows/msrv.yml @@ -25,7 +25,7 @@ jobs: env: # dictated by `firefox` to support the `helix` editor, but now probably effectively be controlled by `jiff`, which also aligns with `regex`. # IMPORTANT: adjust etc/msrv-badge.svg as well - rust_version: 1.74.0 + rust_version: 1.80.0 steps: - uses: actions/checkout@v4 - uses: extractions/setup-just@v2 diff --git a/Cargo.lock b/Cargo.lock index d2fa693c9e4..2ec9598bf55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1231,7 +1231,6 @@ dependencies = [ "gix", "gix-features 0.38.2", "is-terminal", - "once_cell", "prodash 29.0.0", "serde_derive", "terminal_size", @@ -1334,7 +1333,6 @@ dependencies = [ "gix-worktree-state", "gix-worktree-stream", "is_ci", - "once_cell", "parking_lot", "pretty_assertions", "prodash 29.0.0", @@ -1532,7 +1530,6 @@ dependencies = [ "gix-ref 0.45.0", "gix-sec 0.10.7", "memchr", - "once_cell", "serde", "smallvec", "thiserror", @@ -1583,7 +1580,6 @@ dependencies = [ "gix-testtools", "gix-trace 0.1.9", "gix-url", - "once_cell", "serde", "thiserror", ] @@ -1610,7 +1606,6 @@ dependencies = [ "gix-testtools", "itoa", "jiff", - "once_cell", "serde", "thiserror", ] @@ -2201,7 +2196,6 @@ dependencies = [ "gix-trace 0.1.9", "home", "known-folders", - "once_cell", "tempfile", "thiserror", "windows 0.58.0", @@ -2232,7 +2226,6 @@ dependencies = [ "gix-glob 0.16.4", "gix-path 0.10.9", "gix-testtools", - "once_cell", "serial_test", "thiserror", ] @@ -2519,7 +2512,6 @@ dependencies = [ "document-features", "gix-fs 0.11.2", "libc", - "once_cell", "parking_lot", "signal-hook", "signal-hook-registry", @@ -2559,7 +2551,6 @@ dependencies = [ "gix-worktree 0.34.1 (registry+https://github.com/rust-lang/crates.io-index)", "io-close", "is_ci", - "once_cell", "parking_lot", "tar", "tempfile", @@ -2786,7 +2777,6 @@ dependencies = [ "gix-odb", "gix-testtools", "gix-worktree-state", - "once_cell", "symlink", "walkdir", ] diff --git a/Cargo.toml b/Cargo.toml index 56dd00e2f0a..3543e07ff94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -190,7 +190,6 @@ terminal_size = "0.3.0" # Avoid pre-compiled binaries, see https://github.com/serde-rs/serde/issues/2538 and https://github.com/serde-rs/serde/pull/2590 serde_derive = ">=1.0.185" -once_cell = "1.18.0" document-features = { version = "0.2.0", optional = true } [profile.dev.package] diff --git a/clippy.toml b/clippy.toml index 3b9db9dfebc..5729b3f05da 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.74.0" +msrv = "1.80.0" diff --git a/etc/msrv-badge.svg b/etc/msrv-badge.svg index c346e1cb307..5bde79c479c 100644 --- a/etc/msrv-badge.svg +++ b/etc/msrv-badge.svg @@ -1,5 +1,5 @@ - rustc: 1.74.0+ + rustc: 1.80.0+ @@ -15,7 +15,7 @@ rustc - - 1.74.0+ + + 1.80.0+ diff --git a/gix-config/Cargo.toml b/gix-config/Cargo.toml index ccc4d343386..24bf9ff7e26 100644 --- a/gix-config/Cargo.toml +++ b/gix-config/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" keywords = ["git-config", "git", "config", "gitoxide"] categories = ["config", "parser-implementations"] include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.65" +rust-version = "1.80" autotests = false [features] @@ -31,7 +31,6 @@ unicode-bom.workspace = true bstr = { version = "1.3.0", default-features = false, features = ["std"] } serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] } smallvec = "1.9.0" -once_cell = "1.14.0" document-features = { version = "0.2.0", optional = true } diff --git a/gix-credentials/Cargo.toml b/gix-credentials/Cargo.toml index 9156eb0af05..b6fcc8f1c1c 100644 --- a/gix-credentials/Cargo.toml +++ b/gix-credentials/Cargo.toml @@ -36,7 +36,6 @@ document-features = { version = "0.2.1", optional = true } [dev-dependencies] gix-testtools = { path = "../tests/tools" } gix-sec = { path = "../gix-sec" } -once_cell = "1.19.0" [package.metadata.docs.rs] all-features = true diff --git a/gix-credentials/tests/program/from_custom_definition.rs b/gix-credentials/tests/program/from_custom_definition.rs index 4ef71f4ee4a..d0df6cb691d 100644 --- a/gix-credentials/tests/program/from_custom_definition.rs +++ b/gix-credentials/tests/program/from_custom_definition.rs @@ -1,7 +1,7 @@ use gix_credentials::{helper, program::Kind, Program}; -static GIT: once_cell::sync::Lazy<&'static str> = - once_cell::sync::Lazy::new(|| gix_path::env::exe_invocation().to_str().expect("not illformed")); +static GIT: std::sync::LazyLock<&'static str> = + std::sync::LazyLock::new(|| gix_path::env::exe_invocation().to_str().expect("not illformed")); #[cfg(windows)] const SH: &str = "sh"; diff --git a/gix-date/Cargo.toml b/gix-date/Cargo.toml index 12f78326d89..4b00086cbc0 100644 --- a/gix-date/Cargo.toml +++ b/gix-date/Cargo.toml @@ -27,7 +27,6 @@ document-features = { version = "0.2.0", optional = true } [dev-dependencies] gix-testtools = { path = "../tests/tools" } -once_cell = "1.12.0" gix-hash = { path = "../gix-hash" } [package.metadata.docs.rs] diff --git a/gix-date/tests/time/baseline.rs b/gix-date/tests/time/baseline.rs index 7f8c2aa01d7..4eff7cef066 100644 --- a/gix-date/tests/time/baseline.rs +++ b/gix-date/tests/time/baseline.rs @@ -5,7 +5,7 @@ use gix_date::{ SecondsSinceUnixEpoch, }; use gix_testtools::Result; -use once_cell::sync::Lazy; +use std::sync::LazyLock; struct Sample { format_name: Option, @@ -13,7 +13,7 @@ struct Sample { seconds: SecondsSinceUnixEpoch, } -static BASELINE: Lazy> = Lazy::new(|| { +static BASELINE: LazyLock> = LazyLock::new(|| { (|| -> Result<_> { let base = gix_testtools::scripted_fixture_read_only("generate_git_date_baseline.sh")?; let mut map = HashMap::new(); diff --git a/gix-fsck/tests/connectivity/mod.rs b/gix-fsck/tests/connectivity/mod.rs index 3468f0bc290..28d048af652 100644 --- a/gix-fsck/tests/connectivity/mod.rs +++ b/gix-fsck/tests/connectivity/mod.rs @@ -2,7 +2,7 @@ use gix_fsck::Connectivity; use gix_hash::ObjectId; use gix_hashtable::HashMap; use gix_object::Kind; -use gix_testtools::once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::hex_to_id; @@ -40,7 +40,7 @@ fn hex_to_objects<'a>(hex_ids: impl IntoIterator, kind: Kind) -> // Get a `&Vec &'static [ObjectId] { - static ALL_COMMITS: Lazy> = Lazy::new(|| { + static ALL_COMMITS: LazyLock> = LazyLock::new(|| { hex_to_ids([ "ebed23648b19484cb1f340c4ee04dda08479188a", "8ff6d0f8891c3cb22827be142cc64606121d47b3", diff --git a/gix-path/Cargo.toml b/gix-path/Cargo.toml index abb7d5615c6..9ef5caaa4ef 100644 --- a/gix-path/Cargo.toml +++ b/gix-path/Cargo.toml @@ -7,7 +7,7 @@ description = "A crate of the gitoxide project dealing paths and their conversio authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.65" +rust-version = "1.80" [lib] doctest = false @@ -16,7 +16,6 @@ doctest = false gix-trace = { version = "^0.1.8", path = "../gix-trace" } bstr = { version = "1.3.0", default-features = false, features = ["std"] } thiserror = "1.0.26" -once_cell = "1.17.1" [target.'cfg(not(target_family = "wasm"))'.dependencies] home = "0.5.5" diff --git a/gix-path/src/env/git/mod.rs b/gix-path/src/env/git/mod.rs index a24e26ecb47..9a020cfebf8 100644 --- a/gix-path/src/env/git/mod.rs +++ b/gix-path/src/env/git/mod.rs @@ -2,14 +2,14 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use bstr::{BStr, BString, ByteSlice}; -use once_cell::sync::Lazy; +use std::sync::LazyLock; /// Other places to find Git in. #[cfg(windows)] -pub(super) static ALTERNATIVE_LOCATIONS: Lazy> = - Lazy::new(|| locations_under_program_files(|key| std::env::var_os(key))); +pub(super) static ALTERNATIVE_LOCATIONS: LazyLock> = + LazyLock::new(|| locations_under_program_files(|key| std::env::var_os(key))); #[cfg(not(windows))] -pub(super) static ALTERNATIVE_LOCATIONS: Lazy> = Lazy::new(Vec::new); +pub(super) static ALTERNATIVE_LOCATIONS: LazyLock> = LazyLock::new(Vec::new); #[cfg(windows)] fn locations_under_program_files(var_os_func: F) -> Vec @@ -79,7 +79,7 @@ pub(super) static EXE_NAME: &str = "git"; /// Invoke the git executable to obtain the origin configuration, which is cached and returned. /// /// The git executable is the one found in PATH or an alternative location. -pub(super) static EXE_INFO: Lazy> = Lazy::new(|| { +pub(super) static EXE_INFO: LazyLock> = LazyLock::new(|| { let git_cmd = |executable: PathBuf| { let mut cmd = Command::new(executable); #[cfg(windows)] @@ -119,7 +119,7 @@ pub(super) static EXE_INFO: Lazy> = Lazy::new(|| { /// errors during execution. pub(super) fn install_config_path() -> Option<&'static BStr> { let _span = gix_trace::detail!("gix_path::git::install_config_path()"); - static PATH: Lazy> = Lazy::new(|| { + static PATH: LazyLock> = LazyLock::new(|| { // Shortcut: Specifically in Git for Windows 'Git Bash' shells, this variable is set. It // may let us deduce the installation directory, so we can save the `git` invocation. #[cfg(windows)] diff --git a/gix-path/src/env/mod.rs b/gix-path/src/env/mod.rs index 154a0d1ddfa..5834caf7d5f 100644 --- a/gix-path/src/env/mod.rs +++ b/gix-path/src/env/mod.rs @@ -2,7 +2,7 @@ use std::ffi::OsString; use std::path::{Path, PathBuf}; use bstr::{BString, ByteSlice}; -use once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::env::git::EXE_NAME; @@ -37,7 +37,7 @@ pub fn exe_invocation() -> &'static Path { if cfg!(windows) { /// The path to the Git executable as located in the `PATH` or in other locations that it's known to be installed to. /// It's `None` if environment variables couldn't be read or if no executable could be found. - static EXECUTABLE_PATH: Lazy> = Lazy::new(|| { + static EXECUTABLE_PATH: LazyLock> = LazyLock::new(|| { std::env::split_paths(&std::env::var_os("PATH")?) .chain(git::ALTERNATIVE_LOCATIONS.iter().map(Into::into)) .find_map(|prefix| { @@ -98,7 +98,7 @@ pub fn xdg_config(file: &str, env_var: &mut dyn FnMut(&str) -> Option) /// wasn't built with a well-known directory structure or environment. pub fn system_prefix() -> Option<&'static Path> { if cfg!(windows) { - static PREFIX: Lazy> = Lazy::new(|| { + static PREFIX: LazyLock> = LazyLock::new(|| { if let Some(root) = std::env::var_os("EXEPATH").map(PathBuf::from) { for candidate in ["mingw64", "mingw32"] { let candidate = root.join(candidate); diff --git a/gix-pathspec/Cargo.toml b/gix-pathspec/Cargo.toml index 494f1b76dcb..9874e363d15 100644 --- a/gix-pathspec/Cargo.toml +++ b/gix-pathspec/Cargo.toml @@ -24,5 +24,4 @@ thiserror = "1.0.26" [dev-dependencies] gix-testtools = { path = "../tests/tools" } -once_cell = "1.12.0" serial_test = "3.1.1" diff --git a/gix-pathspec/tests/parse/mod.rs b/gix-pathspec/tests/parse/mod.rs index 6ee363d6b5b..3c54fa1e72b 100644 --- a/gix-pathspec/tests/parse/mod.rs +++ b/gix-pathspec/tests/parse/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use bstr::{BStr, BString, ByteSlice}; use gix_attributes::State; use gix_pathspec::{MagicSignature, Pattern, SearchMode}; -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[test] fn baseline() { @@ -54,7 +54,7 @@ impl From for NormalizedPattern { } } -static BASELINE: Lazy> = Lazy::new(|| { +static BASELINE: LazyLock> = LazyLock::new(|| { let base = gix_testtools::scripted_fixture_read_only("parse_baseline.sh").unwrap(); (|| -> crate::Result<_> { diff --git a/gix-refspec/tests/matching/mod.rs b/gix-refspec/tests/matching/mod.rs index 31f9b51e9a8..388459da6fa 100644 --- a/gix-refspec/tests/matching/mod.rs +++ b/gix-refspec/tests/matching/mod.rs @@ -1,6 +1,6 @@ -use gix_testtools::once_cell::sync::Lazy; +use std::sync::LazyLock; -static BASELINE: Lazy = Lazy::new(|| baseline::parse().unwrap()); +static BASELINE: LazyLock = LazyLock::new(|| baseline::parse().unwrap()); pub mod baseline { use std::{borrow::Borrow, collections::HashMap}; @@ -12,7 +12,7 @@ pub mod baseline { parse::Operation, MatchGroup, }; - use gix_testtools::once_cell::sync::Lazy; + use std::sync::LazyLock; use crate::matching::BASELINE; @@ -34,7 +34,7 @@ pub mod baseline { } } - static INPUT: Lazy> = Lazy::new(|| parse_input().unwrap()); + static INPUT: LazyLock> = LazyLock::new(|| parse_input().unwrap()); pub type Baseline = HashMap, Result, BString>>; diff --git a/gix-tempfile/Cargo.toml b/gix-tempfile/Cargo.toml index 855174acd00..24c5b69af51 100644 --- a/gix-tempfile/Cargo.toml +++ b/gix-tempfile/Cargo.toml @@ -7,7 +7,7 @@ description = "A tempfile implementation with a global registry to assure cleanu authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*", "README.md"] -rust-version = "1.65" +rust-version = "1.80" [[example]] name = "delete-tempfiles-on-sigterm" @@ -32,7 +32,6 @@ test = true gix-fs = { version = "^0.11.2", path = "../gix-fs" } parking_lot = "0.12.1" dashmap = { version = "6.0.1", optional = true } -once_cell = { version = "1.8.0", default-features = false, features = ["race", "std"] } tempfile = "3.10.0" signal-hook = { version = "0.3.9", default-features = false, optional = true } diff --git a/gix-tempfile/src/lib.rs b/gix-tempfile/src/lib.rs index 9a5d52405b6..f87b3d6543d 100644 --- a/gix-tempfile/src/lib.rs +++ b/gix-tempfile/src/lib.rs @@ -41,7 +41,7 @@ use std::{ sync::atomic::AtomicUsize, }; -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[cfg(feature = "hp-hashmap")] type HashMap = dashmap::DashMap; @@ -112,7 +112,7 @@ use crate::handle::{Closed, Writable}; pub mod registry; static NEXT_MAP_INDEX: AtomicUsize = AtomicUsize::new(0); -static REGISTRY: Lazy>> = Lazy::new(|| { +static REGISTRY: LazyLock>> = LazyLock::new(|| { #[cfg(feature = "signals")] if signal::handler::MODE.load(std::sync::atomic::Ordering::SeqCst) != signal::handler::Mode::None as usize { for sig in signal_hook::consts::TERM_SIGNALS { diff --git a/gix-tempfile/src/signal.rs b/gix-tempfile/src/signal.rs index 2591dc517e8..312bcf441a9 100644 --- a/gix-tempfile/src/signal.rs +++ b/gix-tempfile/src/signal.rs @@ -1,4 +1,4 @@ -use once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::REGISTRY; @@ -12,7 +12,7 @@ use crate::REGISTRY; /// from a signal handler under the application's control. pub fn setup(mode: handler::Mode) { handler::MODE.store(mode as usize, std::sync::atomic::Ordering::SeqCst); - Lazy::force(®ISTRY); + LazyLock::force(®ISTRY); } /// diff --git a/gix-url/tests/baseline.rs b/gix-url/tests/baseline.rs index 99b0870549f..58bd2f7cf04 100644 --- a/gix-url/tests/baseline.rs +++ b/gix-url/tests/baseline.rs @@ -1,7 +1,7 @@ use std::any::Any; use bstr::ByteSlice; -use gix_testtools::once_cell::sync::Lazy; +use std::sync::LazyLock; /// To see all current failures run the following command or execute cargo-nextest directly with /// the below shown arguments. @@ -13,7 +13,7 @@ use gix_testtools::once_cell::sync::Lazy; fn run() { // ensure the baseline is evaluated before we disable the panic hook, otherwise we swallow // errors inside the baseline generation - Lazy::force(&baseline::URLS); + LazyLock::force(&baseline::URLS); let panic_hook = std::panic::take_hook(); std::panic::set_hook(Box::new(|_| {})); @@ -166,7 +166,7 @@ fn assert_urls_equal(expected: &baseline::GitDiagUrl<'_>, actual: &gix_url::Url) mod baseline { use bstr::{BStr, BString, ByteSlice}; - use gix_testtools::once_cell::sync::Lazy; + use std::sync::LazyLock; pub enum Kind { Unix, @@ -197,14 +197,14 @@ mod baseline { } } - static BASELINE: Lazy = Lazy::new(|| { + static BASELINE: LazyLock = LazyLock::new(|| { let base = gix_testtools::scripted_fixture_read_only("make_baseline.sh").unwrap(); std::fs::read(base.join(format!("git-baseline.{}", Kind::new().extension()))) .expect("fixture file exists") .into() }); - pub static URLS: Lazy)>> = Lazy::new(|| { + pub static URLS: LazyLock)>> = LazyLock::new(|| { let mut out = Vec::new(); let blocks = BASELINE diff --git a/gix-worktree-state/tests/Cargo.toml b/gix-worktree-state/tests/Cargo.toml index 9cabe4709dc..4486372002b 100644 --- a/gix-worktree-state/tests/Cargo.toml +++ b/gix-worktree-state/tests/Cargo.toml @@ -28,6 +28,5 @@ gix-features = { path = "../../gix-features" } gix-testtools = { path = "../../tests/tools" } gix-odb = { path = "../../gix-odb" } symlink = "0.1.0" -once_cell = "1.18.0" walkdir = "2.3.2" diff --git a/gix-worktree-state/tests/state/checkout.rs b/gix-worktree-state/tests/state/checkout.rs index c500e3bde5f..13ade120046 100644 --- a/gix-worktree-state/tests/state/checkout.rs +++ b/gix-worktree-state/tests/state/checkout.rs @@ -11,11 +11,11 @@ use gix_features::progress; use gix_object::{bstr::ByteSlice, Data}; use gix_testtools::tempfile::TempDir; use gix_worktree_state::checkout::Collision; -use once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::fixture_path; -static DRIVER: Lazy = Lazy::new(|| { +static DRIVER: LazyLock = LazyLock::new(|| { let mut cargo = std::process::Command::new(env!("CARGO")); let res = cargo .args(["build", "-p=gix-filter", "--example", "arrow"]) @@ -677,7 +677,7 @@ fn probe_gitoxide_dir() -> crate::Result { } fn opts_from_probe() -> gix_worktree_state::checkout::Options { - static CAPABILITIES: Lazy = Lazy::new(|| probe_gitoxide_dir().unwrap()); + static CAPABILITIES: LazyLock = LazyLock::new(|| probe_gitoxide_dir().unwrap()); gix_worktree_state::checkout::Options { fs: *CAPABILITIES, diff --git a/gix-worktree-stream/tests/stream.rs b/gix-worktree-stream/tests/stream.rs index a34e640a1a2..9ba4c1a1c4f 100644 --- a/gix-worktree-stream/tests/stream.rs +++ b/gix-worktree-stream/tests/stream.rs @@ -8,13 +8,12 @@ mod from_tree { convert::Infallible, io::{Error, ErrorKind, Read, Write}, path::PathBuf, - sync::Arc, + sync::{Arc, LazyLock}, }; use gix_attributes::glob::pattern::Case; use gix_hash::oid; use gix_object::{bstr::ByteSlice, tree::EntryKind, Data}; - use gix_testtools::once_cell::sync::Lazy; use gix_worktree::stack::state::attributes::Source; use crate::hex_to_id; @@ -277,7 +276,7 @@ mod from_tree { } } - static DRIVER: Lazy = Lazy::new(|| { + static DRIVER: LazyLock = LazyLock::new(|| { let mut cargo = std::process::Command::new(env!("CARGO")); let res = cargo .args(["build", "-p=gix-filter", "--example", "arrow"]) diff --git a/gix/Cargo.toml b/gix/Cargo.toml index dae44ad47ec..a0770614cd1 100644 --- a/gix/Cargo.toml +++ b/gix/Cargo.toml @@ -7,7 +7,7 @@ version = "0.64.0" authors = ["Sebastian Thiel "] edition = "2021" include = ["src/**/*", "LICENSE-*"] -rust-version = "1.65" +rust-version = "1.80" [lib] doctest = false @@ -360,7 +360,6 @@ gix-transport = { version = "^0.42.2", path = "../gix-transport", optional = tru # Just to get the progress-tree feature prodash = { workspace = true, optional = true, features = ["progress-tree"] } -once_cell = "1.14.0" signal-hook = { version = "0.3.9", default-features = false, optional = true } thiserror = "1.0.26" serde = { version = "1.0.114", optional = true, default-features = false, features = [ diff --git a/gix/src/interrupt.rs b/gix/src/interrupt.rs index 7df7f9536d3..8f4f33cb3a9 100644 --- a/gix/src/interrupt.rs +++ b/gix/src/interrupt.rs @@ -9,14 +9,17 @@ mod init { use std::{ io, - sync::atomic::{AtomicUsize, Ordering}, + sync::{ + atomic::{AtomicUsize, Ordering}, + LazyLock, + }, }; static DEREGISTER_COUNT: AtomicUsize = AtomicUsize::new(0); - static REGISTERED_HOOKS: once_cell::sync::Lazy>> = - once_cell::sync::Lazy::new(Default::default); - static DEFAULT_BEHAVIOUR_HOOKS: once_cell::sync::Lazy>> = - once_cell::sync::Lazy::new(Default::default); + static REGISTERED_HOOKS: LazyLock>> = + LazyLock::new(Default::default); + static DEFAULT_BEHAVIOUR_HOOKS: LazyLock>> = + LazyLock::new(Default::default); /// A type to help deregistering hooks registered with [`init_handler`](super::init_handler()); #[derive(Default)] diff --git a/gix/tests/repository/config/config_snapshot/credential_helpers.rs b/gix/tests/repository/config/config_snapshot/credential_helpers.rs index 81839a77f89..2cc01c8571c 100644 --- a/gix/tests/repository/config/config_snapshot/credential_helpers.rs +++ b/gix/tests/repository/config/config_snapshot/credential_helpers.rs @@ -6,7 +6,7 @@ mod baseline { use std::collections::HashMap; use gix_object::bstr::BString; - use gix_testtools::once_cell::sync::Lazy; + use std::sync::LazyLock; use crate::remote; @@ -16,7 +16,7 @@ mod baseline { pub helpers: Vec, } - static BASELINE: Lazy> = Lazy::new(|| { + static BASELINE: LazyLock> = LazyLock::new(|| { let base = remote::repo_path("credential-helpers"); (|| -> crate::Result<_> { diff --git a/gix/tests/revision/spec/from_bytes/util.rs b/gix/tests/revision/spec/from_bytes/util.rs index 0073eaf618a..454d3cad86f 100644 --- a/gix/tests/revision/spec/from_bytes/util.rs +++ b/gix/tests/revision/spec/from_bytes/util.rs @@ -4,10 +4,10 @@ use std::{collections::HashMap, path::PathBuf, str::FromStr}; use gix_object::{bstr, bstr::BStr}; use gix_ref::bstr::{BString, ByteSlice}; use gix_revision::spec::Kind; -use gix_testtools::once_cell::sync::Lazy; +use std::sync::LazyLock; const FIXTURE_NAME: &str = "make_rev_spec_parse_repos.sh"; -static BASELINE: Lazy>>> = Lazy::new(|| { +static BASELINE: LazyLock>>> = LazyLock::new(|| { fn kind_of(spec: &BStr) -> gix_revision::spec::Kind { if spec.starts_with(b"^") { gix_revision::spec::Kind::IncludeReachable diff --git a/src/shared.rs b/src/shared.rs index 8a51aa75993..0cac8ed8d78 100644 --- a/src/shared.rs +++ b/src/shared.rs @@ -327,7 +327,7 @@ mod clap { #[derive(Clone)] pub struct AsPathSpec; - static PATHSPEC_DEFAULTS: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { + static PATHSPEC_DEFAULTS: std::sync::LazyLock = std::sync::LazyLock::new(|| { gix::pathspec::Defaults::from_environment(&mut |n| std::env::var_os(n)).unwrap_or_default() }); diff --git a/tests/tools/Cargo.toml b/tests/tools/Cargo.toml index f0054284e3e..61de3b92c75 100644 --- a/tests/tools/Cargo.toml +++ b/tests/tools/Cargo.toml @@ -35,7 +35,6 @@ winnow = { version = "0.6.0", features = ["simd"] } fastrand = "2.0.0" bstr = { version = "1.5.0", default-features = false } crc = "3.0.0" -once_cell = "1.8.0" tempfile = "3.2.0" fs_extra = "1.2.0" parking_lot = { version = "0.12.0" } diff --git a/tests/tools/src/lib.rs b/tests/tools/src/lib.rs index 411d7c0b127..8c8c4bc379f 100644 --- a/tests/tools/src/lib.rs +++ b/tests/tools/src/lib.rs @@ -21,9 +21,8 @@ pub use bstr; use bstr::ByteSlice; use io_close::Close; pub use is_ci; -pub use once_cell; -use once_cell::sync::Lazy; use parking_lot::Mutex; +use std::sync::LazyLock; pub use tempfile; /// A result type to allow using the try operator `?` in unit tests. @@ -57,8 +56,8 @@ impl Drop for GitDaemon { } } -static SCRIPT_IDENTITY: Lazy>> = Lazy::new(|| Mutex::new(BTreeMap::new())); -static EXCLUDE_LUT: Lazy>> = Lazy::new(|| { +static SCRIPT_IDENTITY: LazyLock>> = LazyLock::new(|| Mutex::new(BTreeMap::new())); +static EXCLUDE_LUT: LazyLock>> = LazyLock::new(|| { let cache = (|| { let (repo_path, _) = gix_discover::upwards(Path::new(".")).ok()?; let (gix_dir, work_tree) = repo_path.into_repository_and_work_tree_directories(); @@ -86,7 +85,8 @@ static EXCLUDE_LUT: Lazy>> = Lazy::new(|| { Mutex::new(cache) }); /// The major, minor and patch level of the git version on the system. -pub static GIT_VERSION: Lazy<(u8, u8, u8)> = Lazy::new(|| parse_gix_version().expect("git version to be parsable")); +pub static GIT_VERSION: LazyLock<(u8, u8, u8)> = + LazyLock::new(|| parse_gix_version().expect("git version to be parsable")); /// Define how [`scripted_fixture_writable_with_args()`] uses produces the writable copy. pub enum Creation { @@ -180,7 +180,7 @@ pub fn run_git(working_dir: &Path, args: &[&str]) -> std::io::Result) -> std::io::Result { - static EXEC_PATH: Lazy = Lazy::new(|| { + static EXEC_PATH: LazyLock = LazyLock::new(|| { let path = std::process::Command::new("git") .arg("--exec-path") .stderr(std::process::Stdio::null())