chore: Remove explicit usages of once_cell in favor of std (#22407)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-12-25 01:33:26 +01:00 committed by GitHub
parent 45c714110e
commit 1a9f0a647a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 19 additions and 23 deletions

3
Cargo.lock generated
View file

@ -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]]

View file

@ -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"

View file

@ -25,7 +25,6 @@ anyhow.workspace = true
clap.workspace = true
collections.workspace = true
ipc-channel = "0.19"
once_cell.workspace = true
parking_lot.workspace = true
paths.workspace = true
release_channel.workspace = true

View file

@ -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);

View file

@ -27,7 +27,6 @@ futures.workspace = true
gpui.workspace = true
http_client.workspace = true
log.workspace = true
once_cell.workspace = true
paths.workspace = true
parking_lot.workspace = true
postage.workspace = true

View file

@ -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(|| {

View file

@ -10,4 +10,3 @@ workspace = true
[dependencies]
gpui.workspace = true
once_cell.workspace = true

View file

@ -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),
});