diff --git a/Cargo.lock b/Cargo.lock index 367360ea649..d6b70770eec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -327,9 +327,9 @@ dependencies = [ "filetime", "glob", "hex-literal", - "lazy_static", "libc", "nix", + "once_cell", "phf", "phf_codegen", "pretty_assertions", @@ -2525,7 +2525,6 @@ dependencies = [ "chrono", "clap 3.1.18", "glob", - "lazy_static", "lscolors", "number_prefix", "once_cell", @@ -3110,7 +3109,6 @@ dependencies = [ "dns-lookup", "dunce", "itertools", - "lazy_static", "libc", "nix", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 4ba105014c2..48aacf6b548 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -261,11 +261,11 @@ uudoc = [ "zip" ] [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } clap_complete = "3.1" +once_cell = "1.13.0" phf = "0.10.1" -lazy_static = { version="1.3" } +selinux = { version="0.2", optional = true } textwrap = { version="0.15", features=["terminal_size"] } uucore = { version=">=0.0.11", package="uucore", path="src/uucore" } -selinux = { version="0.2", optional = true } zip = { version = "0.6.0", optional=true, default_features=false, features=["deflate"] } # * uutils uu_test = { optional=true, version="0.0.14", package="uu_test", path="src/uu/test" } diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index f5e46175037..bdf97fd1bd1 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -28,9 +28,6 @@ once_cell = "1.13.0" atty = "0.2" selinux = { version="0.2", optional = true } -[target.'cfg(unix)'.dependencies] -lazy_static = "1.4.0" - [[bin]] name = "ls" path = "src/main.rs" diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index cd400ec7c5a..cab36ceb390 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -9,9 +9,6 @@ #[macro_use] extern crate uucore; -#[cfg(unix)] -#[macro_use] -extern crate lazy_static; use clap::{crate_version, Arg, Command}; use glob::Pattern; @@ -2251,6 +2248,8 @@ fn get_inode(metadata: &Metadata) -> String { // Currently getpwuid is `linux` target only. If it's broken out into // a posix-compliant attribute this can be updated... #[cfg(unix)] +use once_cell::sync::Lazy; +#[cfg(unix)] use std::sync::Mutex; #[cfg(unix)] use uucore::entries; @@ -2258,9 +2257,7 @@ use uucore::quoting_style; #[cfg(unix)] fn cached_uid2usr(uid: u32) -> String { - lazy_static! { - static ref UID_CACHE: Mutex> = Mutex::new(HashMap::new()); - } + static UID_CACHE: Lazy>> = Lazy::new(|| Mutex::new(HashMap::new())); let mut uid_cache = UID_CACHE.lock().unwrap(); uid_cache @@ -2280,9 +2277,7 @@ fn display_uname(metadata: &Metadata, config: &Config) -> String { #[cfg(all(unix, not(target_os = "redox")))] fn cached_gid2grp(gid: u32) -> String { - lazy_static! { - static ref GID_CACHE: Mutex> = Mutex::new(HashMap::new()); - } + static GID_CACHE: Lazy>> = Lazy::new(|| Mutex::new(HashMap::new())); let mut gid_cache = GID_CACHE.lock().unwrap(); gid_cache diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 5d86b67a20d..42a71d6f1a7 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -41,7 +41,7 @@ nix = { version = "0.24.1", optional = true, default-features = false, features [dev-dependencies] clap = "3.1" -lazy_static = "1.3" +once_cell = "1.13" [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "winerror"] } diff --git a/src/uucore/src/lib/mods/backup_control.rs b/src/uucore/src/lib/mods/backup_control.rs index f2da374b6cb..a5c9baa611e 100644 --- a/src/uucore/src/lib/mods/backup_control.rs +++ b/src/uucore/src/lib/mods/backup_control.rs @@ -447,7 +447,7 @@ mod tests { use std::env; // Required to instantiate mutex in shared context use clap::Command; - use lazy_static::lazy_static; + use once_cell::sync::Lazy; use std::sync::Mutex; // The mutex is required here as by default all tests are run as separate @@ -456,9 +456,7 @@ mod tests { // occur if no precautions are taken. Thus we have all tests that rely on // environment variables lock this empty mutex to ensure they don't access // it concurrently. - lazy_static! { - static ref TEST_MUTEX: Mutex<()> = Mutex::new(()); - } + static TEST_MUTEX: Lazy> = Lazy::new(|| Mutex::new(())); // Environment variable for "VERSION_CONTROL" static ENV_VERSION_CONTROL: &str = "VERSION_CONTROL"; diff --git a/tests/by-util/test_chmod.rs b/tests/by-util/test_chmod.rs index 8f6b7fb52a9..8588bd9e3c9 100644 --- a/tests/by-util/test_chmod.rs +++ b/tests/by-util/test_chmod.rs @@ -2,6 +2,7 @@ use crate::common::util::*; use std::fs::{metadata, set_permissions, OpenOptions, Permissions}; use std::os::unix::fs::{OpenOptionsExt, PermissionsExt}; use std::sync::Mutex; +use once_cell::sync::Lazy; extern crate libc; use uucore::mode::strip_minus_from_mode; @@ -11,9 +12,7 @@ use self::libc::umask; static TEST_FILE: &str = "file"; static REFERENCE_FILE: &str = "reference"; static REFERENCE_PERMS: u32 = 0o247; -lazy_static! { - static ref UMASK_MUTEX: Mutex<()> = Mutex::new(()); -} +static UMASK_MUTEX: Lazy> = Lazy::new(|| Mutex::new(())); struct TestCase { args: Vec<&'static str>, diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index c0d54a7cd96..1f3ef0d1685 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -19,14 +19,14 @@ use std::path::Path; #[cfg(not(windows))] use std::path::PathBuf; #[cfg(not(windows))] +use once_cell::sync::Lazy; +#[cfg(not(windows))] use std::sync::Mutex; use std::thread::sleep; use std::time::Duration; #[cfg(not(windows))] -lazy_static! { - static ref UMASK_MUTEX: Mutex<()> = Mutex::new(()); -} +static UMASK_MUTEX: Lazy> = Lazy::new(|| Mutex::new(())); const LONG_ARGS: &[&str] = &[ "-l", diff --git a/tests/tests.rs b/tests/tests.rs index 3c6487f45de..51c6f6b11a6 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1,11 +1,6 @@ #[macro_use] mod common; -#[allow(unused_imports)] -#[cfg(unix)] -#[macro_use] -extern crate lazy_static; - #[cfg(unix)] extern crate rust_users;