Skip to content

Drop once_cell #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.74.0"
msrv = "1.80.0"
6 changes: 3 additions & 3 deletions etc/msrv-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions gix-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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 }

Expand Down
1 change: 0 additions & 1 deletion gix-credentials/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gix-credentials/tests/program/from_custom_definition.rs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
1 change: 0 additions & 1 deletion gix-date/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions gix-date/tests/time/baseline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use gix_date::{
SecondsSinceUnixEpoch,
};
use gix_testtools::Result;
use once_cell::sync::Lazy;
use std::sync::LazyLock;

struct Sample {
format_name: Option<String>,
exit_code: usize,
seconds: SecondsSinceUnixEpoch,
}

static BASELINE: Lazy<HashMap<String, Sample>> = Lazy::new(|| {
static BASELINE: LazyLock<HashMap<String, Sample>> = LazyLock::new(|| {
(|| -> Result<_> {
let base = gix_testtools::scripted_fixture_read_only("generate_git_date_baseline.sh")?;
let mut map = HashMap::new();
Expand Down
4 changes: 2 additions & 2 deletions gix-fsck/tests/connectivity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -40,7 +40,7 @@ fn hex_to_objects<'a>(hex_ids: impl IntoIterator<Item = &'a str>, kind: Kind) ->

// Get a `&Vec<ObjectID` for each commit in the test fixture repository
fn all_commits() -> &'static [ObjectId] {
static ALL_COMMITS: Lazy<Vec<ObjectId>> = Lazy::new(|| {
static ALL_COMMITS: LazyLock<Vec<ObjectId>> = LazyLock::new(|| {
hex_to_ids([
"ebed23648b19484cb1f340c4ee04dda08479188a",
"8ff6d0f8891c3cb22827be142cc64606121d47b3",
Expand Down
3 changes: 1 addition & 2 deletions gix-path/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "A crate of the gitoxide project dealing paths and their conversio
authors = ["Sebastian Thiel <sebastian.thiel@icloud.com>"]
edition = "2021"
include = ["src/**/*", "LICENSE-*"]
rust-version = "1.65"
rust-version = "1.80"

[lib]
doctest = false
Expand All @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions gix-path/src/env/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<PathBuf>> =
Lazy::new(|| locations_under_program_files(|key| std::env::var_os(key)));
pub(super) static ALTERNATIVE_LOCATIONS: LazyLock<Vec<PathBuf>> =
LazyLock::new(|| locations_under_program_files(|key| std::env::var_os(key)));
#[cfg(not(windows))]
pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<PathBuf>> = Lazy::new(Vec::new);
pub(super) static ALTERNATIVE_LOCATIONS: LazyLock<Vec<PathBuf>> = LazyLock::new(Vec::new);

#[cfg(windows)]
fn locations_under_program_files<F>(var_os_func: F) -> Vec<PathBuf>
Expand Down Expand Up @@ -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<Option<BString>> = Lazy::new(|| {
pub(super) static EXE_INFO: LazyLock<Option<BString>> = LazyLock::new(|| {
let git_cmd = |executable: PathBuf| {
let mut cmd = Command::new(executable);
#[cfg(windows)]
Expand Down Expand Up @@ -119,7 +119,7 @@ pub(super) static EXE_INFO: Lazy<Option<BString>> = 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<Option<BString>> = Lazy::new(|| {
static PATH: LazyLock<Option<BString>> = 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)]
Expand Down
6 changes: 3 additions & 3 deletions gix-path/src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<Option<PathBuf>> = Lazy::new(|| {
static EXECUTABLE_PATH: LazyLock<Option<PathBuf>> = LazyLock::new(|| {
std::env::split_paths(&std::env::var_os("PATH")?)
.chain(git::ALTERNATIVE_LOCATIONS.iter().map(Into::into))
.find_map(|prefix| {
Expand Down Expand Up @@ -98,7 +98,7 @@ pub fn xdg_config(file: &str, env_var: &mut dyn FnMut(&str) -> Option<OsString>)
/// wasn't built with a well-known directory structure or environment.
pub fn system_prefix() -> Option<&'static Path> {
if cfg!(windows) {
static PREFIX: Lazy<Option<PathBuf>> = Lazy::new(|| {
static PREFIX: LazyLock<Option<PathBuf>> = LazyLock::new(|| {
if let Some(root) = std::env::var_os("EXEPATH").map(PathBuf::from) {
for candidate in ["mingw64", "mingw32"] {
let candidate = root.join(candidate);
Expand Down
1 change: 0 additions & 1 deletion gix-pathspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions gix-pathspec/tests/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -54,7 +54,7 @@ impl From<Pattern> for NormalizedPattern {
}
}

static BASELINE: Lazy<HashMap<BString, usize>> = Lazy::new(|| {
static BASELINE: LazyLock<HashMap<BString, usize>> = LazyLock::new(|| {
let base = gix_testtools::scripted_fixture_read_only("parse_baseline.sh").unwrap();

(|| -> crate::Result<_> {
Expand Down
8 changes: 4 additions & 4 deletions gix-refspec/tests/matching/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gix_testtools::once_cell::sync::Lazy;
use std::sync::LazyLock;

static BASELINE: Lazy<baseline::Baseline> = Lazy::new(|| baseline::parse().unwrap());
static BASELINE: LazyLock<baseline::Baseline> = LazyLock::new(|| baseline::parse().unwrap());

pub mod baseline {
use std::{borrow::Borrow, collections::HashMap};
Expand All @@ -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;

Expand All @@ -34,7 +34,7 @@ pub mod baseline {
}
}

static INPUT: Lazy<Vec<Ref>> = Lazy::new(|| parse_input().unwrap());
static INPUT: LazyLock<Vec<Ref>> = LazyLock::new(|| parse_input().unwrap());

pub type Baseline = HashMap<Vec<BString>, Result<Vec<Mapping>, BString>>;

Expand Down
3 changes: 1 addition & 2 deletions gix-tempfile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "A tempfile implementation with a global registry to assure cleanu
authors = ["Sebastian Thiel <sebastian.thiel@icloud.com>"]
edition = "2021"
include = ["src/**/*", "LICENSE-*", "README.md"]
rust-version = "1.65"
rust-version = "1.80"

[[example]]
name = "delete-tempfiles-on-sigterm"
Expand All @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions gix-tempfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::{
sync::atomic::AtomicUsize,
};

use once_cell::sync::Lazy;
use std::sync::LazyLock;

#[cfg(feature = "hp-hashmap")]
type HashMap<K, V> = dashmap::DashMap<K, V>;
Expand Down Expand Up @@ -112,7 +112,7 @@ use crate::handle::{Closed, Writable};
pub mod registry;

static NEXT_MAP_INDEX: AtomicUsize = AtomicUsize::new(0);
static REGISTRY: Lazy<HashMap<usize, Option<ForksafeTempfile>>> = Lazy::new(|| {
static REGISTRY: LazyLock<HashMap<usize, Option<ForksafeTempfile>>> = 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 {
Expand Down
4 changes: 2 additions & 2 deletions gix-tempfile/src/signal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use once_cell::sync::Lazy;
use std::sync::LazyLock;

use crate::REGISTRY;

Expand All @@ -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(&REGISTRY);
LazyLock::force(&REGISTRY);
}

///
Expand Down
Loading
Loading