Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
chore: Remove explicit usages of once_cell in favor of std (#22407)
Piotr Osiewicz1a9f0a647a70
diff --git a/Cargo.lock b/Cargo.lockindex 714116d7165..9431840f36f 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2484,7 +2484,6 @@ dependencies = ["exec","fork","ipc-channel",- "once_cell","parking_lot","paths","plist",@@ -2511,7 +2510,6 @@ dependencies = ["gpui","http_client","log",- "once_cell","parking_lot","paths","postage",@@ -10266,7 +10264,6 @@ name = "release_channel"version = "0.1.0"dependencies = ["gpui",- "once_cell",][[package]]diff --git a/Cargo.toml b/Cargo.tomlindex a888d868cf9..779ebb1b35d 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -408,7 +408,6 @@ nanoid = "0.4"nbformat = { version = "0.9.0" }nix = "0.29"num-format = "0.4.4"-once_cell = "1.19.0"ordered-float = "2.1.1"palette = { version = "0.7.5", default-features = false, features = ["std"] }parking_lot = "0.12.1"diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.tomlindex fedd6738ed1..170647873ad 100644--- a/crates/cli/Cargo.toml+++ b/crates/cli/Cargo.toml@@ -25,7 +25,6 @@ anyhow.workspace = trueclap.workspace = truecollections.workspace = trueipc-channel = "0.19"-once_cell.workspace = trueparking_lot.workspace = truepaths.workspace = truerelease_channel.workspace = truediff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rsindex 1f0aa459e05..3dbfa0e737a 100644--- a/crates/cli/src/main.rs+++ b/crates/cli/src/main.rs@@ -277,6 +277,7 @@ mod linux {os::unix::net::{SocketAddr, UnixDatagram},path::{Path, PathBuf},process::{self, ExitStatus},+ sync::LazyLock,thread,time::Duration,};@@ -284,12 +285,11 @@ mod linux {use anyhow::anyhow;use cli::FORCE_CLI_MODE_ENV_VAR_NAME;use fork::Fork;- use once_cell::sync::Lazy;use crate::{Detect, InstalledApp};- static RELEASE_CHANNEL: Lazy<String> =- Lazy::new(|| include_str!("../../zed/RELEASE_CHANNEL").trim().to_string());+ static RELEASE_CHANNEL: LazyLock<String> =+ LazyLock::new(|| include_str!("../../zed/RELEASE_CHANNEL").trim().to_string());struct App(PathBuf);diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.tomlindex c68caa0108b..debf2ea8247 100644--- a/crates/client/Cargo.toml+++ b/crates/client/Cargo.toml@@ -27,7 +27,6 @@ futures.workspace = truegpui.workspace = truehttp_client.workspace = truelog.workspace = true-once_cell.workspace = truepaths.workspace = trueparking_lot.workspace = truepostage.workspace = truediff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rsindex 54f3cd642b9..96e539e167d 100644--- a/crates/client/src/telemetry.rs+++ b/crates/client/src/telemetry.rs@@ -8,7 +8,6 @@ use futures::channel::mpsc;use futures::{Future, StreamExt};use gpui::{AppContext, BackgroundExecutor, Task};use http_client::{self, AsyncBody, HttpClient, HttpClientWithUrl, Method, Request};-use once_cell::sync::Lazy;use parking_lot::Mutex;use release_channel::ReleaseChannel;use settings::{Settings, SettingsStore};@@ -16,7 +15,12 @@ use sha2::{Digest, Sha256};use std::fs::File;use std::io::Write;use std::time::Instant;-use std::{env, mem, path::PathBuf, sync::Arc, time::Duration};+use std::{+ env, mem,+ path::PathBuf,+ sync::{Arc, LazyLock},+ time::Duration,+};use telemetry_events::{AppEvent, AssistantEvent, CallEvent, EditEvent, Event, EventRequestBody, EventWrapper,InlineCompletionEvent,@@ -84,7 +88,7 @@ const FLUSH_INTERVAL: Duration = Duration::from_secs(1);#[cfg(not(debug_assertions))]const FLUSH_INTERVAL: Duration = Duration::from_secs(60 * 5);-static ZED_CLIENT_CHECKSUM_SEED: Lazy<Option<Vec<u8>>> = Lazy::new(|| {+static ZED_CLIENT_CHECKSUM_SEED: LazyLock<Option<Vec<u8>>> = LazyLock::new(|| {option_env!("ZED_CLIENT_CHECKSUM_SEED").map(|s| s.as_bytes().into()).or_else(|| {diff --git a/crates/release_channel/Cargo.toml b/crates/release_channel/Cargo.tomlindex cf664ceff1c..7c121946748 100644--- a/crates/release_channel/Cargo.toml+++ b/crates/release_channel/Cargo.toml@@ -10,4 +10,3 @@ workspace = true[dependencies]gpui.workspace = true-once_cell.workspace = truediff --git a/crates/release_channel/src/lib.rs b/crates/release_channel/src/lib.rsindex 602c4f4b5fe..a41c4de2260 100644--- a/crates/release_channel/src/lib.rs+++ b/crates/release_channel/src/lib.rs@@ -2,24 +2,23 @@#![deny(missing_docs)]-use std::{env, str::FromStr};+use std::{env, str::FromStr, sync::LazyLock};use gpui::{AppContext, Global, SemanticVersion};-use once_cell::sync::Lazy;/// stable | dev | nightly | preview-pub static RELEASE_CHANNEL_NAME: Lazy<String> = if cfg!(debug_assertions) {- Lazy::new(|| {+pub static RELEASE_CHANNEL_NAME: LazyLock<String> = LazyLock::new(|| {+ if cfg!(debug_assertions) {env::var("ZED_RELEASE_CHANNEL").unwrap_or_else(|_| include_str!("../../zed/RELEASE_CHANNEL").trim().to_string())- })-} else {- Lazy::new(|| include_str!("../../zed/RELEASE_CHANNEL").trim().to_string())-};+ } else {+ include_str!("../../zed/RELEASE_CHANNEL").trim().to_string()+ }+});#[doc(hidden)]-pub static RELEASE_CHANNEL: Lazy<ReleaseChannel> =- Lazy::new(|| match ReleaseChannel::from_str(&RELEASE_CHANNEL_NAME) {+pub static RELEASE_CHANNEL: LazyLock<ReleaseChannel> =+ LazyLock::new(|| match ReleaseChannel::from_str(&RELEASE_CHANNEL_NAME) {Ok(channel) => channel,_ => panic!("invalid release channel {}", *RELEASE_CHANNEL_NAME),});