Skip to content
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

feat(once_cell): remove dependency on once_cell #1181

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [1.70.0, stable, beta, nightly]
rust: [1.80.0, stable, beta, nightly]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "A modern replacement for ls"
authors = ["Christina Sørensen <[email protected]>"]
categories = ["command-line-utilities"]
edition = "2021"
rust-version = "1.70.0"
rust-version = "1.80.0"
exclude = [
"/devtools/*",
"/Justfile",
Expand Down Expand Up @@ -87,7 +87,6 @@ natord = "1.0"
path-clean = "1.0.1"
number_prefix = "0.4"
palette = { version = "0.7.6", default-features = false, features = ["std"] }
once_cell = "1.20.1"
percent-encoding = "2.3.1"
phf = { version = "0.11.2", features = ["macros"] }
plist = { version = "1.7.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2024 Christina Sørensen
# SPDX-License-Identifier: EUPL-1.2
[toolchain]
channel = "1.70"
channel = "1.80"
components = [
"rustfmt",
"rustc",
Expand Down
7 changes: 3 additions & 4 deletions src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use chrono::prelude::*;

use log::*;
#[cfg(unix)]
use once_cell::sync::Lazy;
use std::sync::LazyLock;

use crate::fs::dir::Dir;
use crate::fs::feature::xattr;
Expand All @@ -40,11 +40,10 @@ use super::mounts::MountedFs;
// Maps (device_id, inode) => (size_in_bytes, size_in_blocks)
// Mutex::new is const but HashMap::new is not const requiring us to use lazy
// initialization.
// TODO: Replace with std::sync::LazyLock when it is stable.
#[allow(clippy::type_complexity)]
#[cfg(unix)]
static DIRECTORY_SIZE_CACHE: Lazy<Mutex<HashMap<(u64, u64), (u64, u64)>>> =
Lazy::new(|| Mutex::new(HashMap::new()));
static DIRECTORY_SIZE_CACHE: LazyLock<Mutex<HashMap<(u64, u64), (u64, u64)>>> =
LazyLock::new(|| Mutex::new(HashMap::new()));

/// A **File** is a wrapper around one of Rust’s `PathBuf` values, along with
/// associated data about the file.
Expand Down
4 changes: 2 additions & 2 deletions src/output/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::sync::{Mutex, MutexGuard};
use chrono::prelude::*;

use log::*;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
#[cfg(unix)]
use uzers::UsersCache;

Expand Down Expand Up @@ -398,7 +398,7 @@ impl Environment {
}
}

static ENVIRONMENT: Lazy<Environment> = Lazy::new(Environment::load_all);
static ENVIRONMENT: LazyLock<Environment> = LazyLock::new(Environment::load_all);

pub struct Table<'a> {
columns: Vec<Column>,
Expand Down
10 changes: 5 additions & 5 deletions src/output/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use chrono::prelude::*;
use core::cmp::max;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
use std::time::Duration;
use unicode_width::UnicodeWidthStr;

Expand Down Expand Up @@ -140,12 +140,12 @@ fn custom(time: &DateTime<FixedOffset>, non_recent_fmt: &str, recent_fmt: Option
}
}

static CURRENT_YEAR: Lazy<i32> = Lazy::new(|| Local::now().year());
static CURRENT_YEAR: LazyLock<i32> = LazyLock::new(|| Local::now().year());

static LOCALE: Lazy<locale::Time> =
Lazy::new(|| locale::Time::load_user_locale().unwrap_or_else(|_| locale::Time::english()));
static LOCALE: LazyLock<locale::Time> =
LazyLock::new(|| locale::Time::load_user_locale().unwrap_or_else(|_| locale::Time::english()));

static MAX_MONTH_WIDTH: Lazy<usize> = Lazy::new(|| {
static MAX_MONTH_WIDTH: LazyLock<usize> = LazyLock::new(|| {
// Some locales use a three-character wide month name (Jan to Dec);
// others vary between three to four (1月 to 12月, juil.). We check each month width
// to detect the longest and set the output format accordingly.
Expand Down
3 changes: 2 additions & 1 deletion tests/gen/long_time_style_custom_non_recent_empty_nix.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
thread 'main' panicked at 'Custom timestamp format is empty, please supply a chrono format string after the plus sign.', src/options/view.rs:357:21
thread 'main' panicked at src/options/view.rs:357:21:
Custom timestamp format is empty, please supply a chrono format string after the plus sign.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3 changes: 2 additions & 1 deletion tests/gen/long_time_style_custom_non_recent_none_nix.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
thread 'main' panicked at 'Custom timestamp format is empty, please supply a chrono format string after the plus sign.', src/options/view.rs:355:47
thread 'main' panicked at src/options/view.rs:355:47:
Custom timestamp format is empty, please supply a chrono format string after the plus sign.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3 changes: 2 additions & 1 deletion tests/gen/long_time_style_custom_recent_empty_nix.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
thread 'main' panicked at 'Custom timestamp format for recent files is empty, please supply a chrono format string at the second line.', src/options/view.rs:371:25
thread 'main' panicked at src/options/view.rs:371:25:
Custom timestamp format for recent files is empty, please supply a chrono format string at the second line.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Loading