Skip to content

Commit d5209e1

Browse files
TheRedApricotrami3l
authored andcommitted
Remove once_cell dependency
1 parent 03b7c56 commit d5209e1

File tree

12 files changed

+74
-50
lines changed

12 files changed

+74
-50
lines changed

Cargo.lock

Lines changed: 45 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ git-testament = "0.2"
5555
home = "0.5.4"
5656
itertools = "0.13"
5757
libc = "0.2"
58-
once_cell.workspace = true
5958
opener = "0.7.0"
6059
# `openssl` is used by `curl` or `reqwest` backend although it isn't imported by rustup: this
6160
# allows controlling the vendoring status without exposing the presence of the download crate.
@@ -124,7 +123,6 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
124123
trycmd = "0.15.0"
125124

126125
[build-dependencies]
127-
once_cell.workspace = true
128126
platforms.workspace = true
129127
regex = "1"
130128

@@ -134,7 +132,6 @@ members = ["download"]
134132
[workspace.dependencies]
135133
anyhow = "1.0.69"
136134
fs_at = "0.2.1"
137-
once_cell = "1.18.0"
138135
opentelemetry = "0.24"
139136
opentelemetry-otlp = "0.17"
140137
opentelemetry_sdk = { version = "0.24", features = ["rt-tokio"] }

download/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ license = "MIT OR Apache-2.0"
88
default = ["reqwest-backend", "reqwest-rustls-tls", "reqwest-native-tls"]
99
curl-backend = ["curl"]
1010
reqwest-backend = ["reqwest", "env_proxy"]
11-
reqwest-native-tls = ["reqwest/native-tls", "dep:once_cell"]
11+
reqwest-native-tls = ["reqwest/native-tls"]
1212
reqwest-rustls-tls = [
1313
"reqwest/rustls-tls-manual-roots-no-provider",
1414
"dep:rustls",
1515
"dep:rustls-platform-verifier",
16-
"dep:once_cell",
1716
]
1817

1918
[dependencies]
2019
anyhow.workspace = true
2120
curl = { version = "0.4.44", optional = true }
2221
env_proxy = { version = "0.4.1", optional = true }
23-
once_cell = { workspace = true, optional = true }
2422
reqwest = { version = "0.12", default-features = false, features = ["blocking", "gzip", "socks", "stream"], optional = true }
2523
rustls = { version = "0.23", optional = true, default-features = false, features = ["logging", "ring", "tls12"] }
2624
rustls-platform-verifier = { version = "0.3", optional = true }

download/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,11 @@ pub mod reqwest_be {
296296
use std::io;
297297
#[cfg(feature = "reqwest-rustls-tls")]
298298
use std::sync::Arc;
299+
#[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]
300+
use std::sync::LazyLock;
299301
use std::time::Duration;
300302

301303
use anyhow::{anyhow, Context, Result};
302-
#[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]
303-
use once_cell::sync::Lazy;
304304
use reqwest::{header, Client, ClientBuilder, Proxy, Response};
305305
#[cfg(feature = "reqwest-rustls-tls")]
306306
use rustls::crypto::ring;
@@ -354,7 +354,7 @@ pub mod reqwest_be {
354354
}
355355

356356
#[cfg(feature = "reqwest-rustls-tls")]
357-
static CLIENT_RUSTLS_TLS: Lazy<Client> = Lazy::new(|| {
357+
static CLIENT_RUSTLS_TLS: LazyLock<Client> = LazyLock::new(|| {
358358
let catcher = || {
359359
client_generic()
360360
.use_preconfigured_tls(
@@ -377,7 +377,7 @@ pub mod reqwest_be {
377377
});
378378

379379
#[cfg(feature = "reqwest-native-tls")]
380-
static CLIENT_DEFAULT_TLS: Lazy<Client> = Lazy::new(|| {
380+
static CLIENT_DEFAULT_TLS: LazyLock<Client> = LazyLock::new(|| {
381381
let catcher = || {
382382
client_generic()
383383
.user_agent(super::REQWEST_DEFAULT_TLS_USER_AGENT)

download/tests/read-proxy-env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ use std::env::{remove_var, set_var};
44
use std::error::Error;
55
use std::net::TcpListener;
66
use std::sync::atomic::{AtomicUsize, Ordering};
7+
use std::sync::LazyLock;
78
use std::thread;
89
use std::time::Duration;
910

1011
use env_proxy::for_url;
11-
use once_cell::sync::Lazy;
1212
use reqwest::{Client, Proxy};
1313
use tokio::sync::Mutex;
1414
use url::Url;
1515

16-
static SERIALISE_TESTS: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
16+
static SERIALISE_TESTS: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(()));
1717

1818
fn scrub_env() {
1919
remove_var("http_proxy");

src/cli/common.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ use std::fs;
77
use std::io::ErrorKind;
88
use std::io::{BufRead, Write};
99
use std::path::{Path, PathBuf};
10-
use std::sync::{Arc, Mutex};
10+
use std::sync::{Arc, LazyLock, Mutex};
1111
use std::{cmp, env};
1212

1313
use anyhow::{anyhow, Context, Result};
1414
use git_testament::{git_testament, render_testament};
15-
use once_cell::sync::Lazy;
1615
use tracing::{debug, error, info, trace, warn};
1716

1817
use super::self_update;
@@ -529,7 +528,7 @@ pub(crate) fn version() -> &'static str {
529528
// Because we trust our `stable` branch given the careful release
530529
// process, we mark it trusted here so that our version numbers look
531530
// right when built from CI before the tag is pushed
532-
static RENDERED: Lazy<String> = Lazy::new(|| render_testament!(TESTAMENT, "stable"));
531+
static RENDERED: LazyLock<String> = LazyLock::new(|| render_testament!(TESTAMENT, "stable"));
533532
&RENDERED
534533
}
535534

src/cli/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use std::io;
55
use std::path::PathBuf;
6+
use std::sync::LazyLock;
67

7-
use once_cell::sync::Lazy;
88
use regex::Regex;
99
use strsim::damerau_levenshtein;
1010
use thiserror::Error as ThisError;
@@ -24,7 +24,7 @@ pub enum CLIError {
2424
fn maybe_suggest_toolchain(bad_name: &str) -> String {
2525
let bad_name = &bad_name.to_ascii_lowercase();
2626
static VALID_CHANNELS: &[&str] = &["stable", "beta", "nightly"];
27-
static NUMBERED: Lazy<Regex> = Lazy::new(|| Regex::new(r"^[0-9]+\.[0-9]+$").unwrap());
27+
static NUMBERED: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"^[0-9]+\.[0-9]+$").unwrap());
2828
if NUMBERED.is_match(bad_name) {
2929
return format!(". Toolchain numbers tend to have three parts, e.g. {bad_name}.0");
3030
}

src/cli/self_update.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,11 +1046,12 @@ fn get_new_rustup_version(path: &Path) -> Option<String> {
10461046
}
10471047

10481048
fn parse_new_rustup_version(version: String) -> String {
1049-
use once_cell::sync::Lazy;
1049+
use std::sync::LazyLock;
1050+
10501051
use regex::Regex;
10511052

1052-
static RE: Lazy<Regex> =
1053-
Lazy::new(|| Regex::new(r"[0-9]+.[0-9]+.[0-9]+[0-9a-zA-Z-]*").unwrap());
1053+
static RE: LazyLock<Regex> =
1054+
LazyLock::new(|| Regex::new(r"[0-9]+.[0-9]+.[0-9]+[0-9a-zA-Z-]*").unwrap());
10541055

10551056
let capture = RE.captures(&version);
10561057
let matched_version = match capture {

src/dist/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//! Installation from a Rust distribution server
22
3-
use std::{collections::HashSet, env, fmt, io::Write, ops::Deref, path::Path, str::FromStr};
3+
use std::{
4+
collections::HashSet, env, fmt, io::Write, ops::Deref, path::Path, str::FromStr, sync::LazyLock,
5+
};
46

57
use anyhow::{anyhow, bail, Context, Result};
68
use chrono::NaiveDate;
79
use clap::{builder::PossibleValue, ValueEnum};
810
use itertools::Itertools;
9-
use once_cell::sync::Lazy;
1011
use regex::Regex;
1112
use serde::{Deserialize, Serialize};
1213
use thiserror::Error as ThisError;
@@ -272,7 +273,7 @@ impl FromStr for ParsedToolchainDesc {
272273
fn from_str(desc: &str) -> Result<Self> {
273274
// Note this regex gives you a guaranteed match of the channel (1)
274275
// and an optional match of the date (2) and target (3)
275-
static TOOLCHAIN_CHANNEL_RE: Lazy<Regex> = Lazy::new(|| {
276+
static TOOLCHAIN_CHANNEL_RE: LazyLock<Regex> = LazyLock::new(|| {
276277
Regex::new(&format!(
277278
r"^({})(?:-([0-9]{{4}}-[0-9]{{2}}-[0-9]{{2}}))?(?:-(.+))?$",
278279
// The channel patterns we support

src/dist/triple.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use once_cell::sync::Lazy;
1+
use std::sync::LazyLock;
2+
23
use regex::Regex;
34

45
pub mod known;
@@ -24,7 +25,7 @@ impl PartialTargetTriple {
2425
// we can count on all triple components being
2526
// delineated by it.
2627
let name = format!("-{name}");
27-
static RE: Lazy<Regex> = Lazy::new(|| {
28+
static RE: LazyLock<Regex> = LazyLock::new(|| {
2829
Regex::new(&format!(
2930
r"^(?:-({}))?(?:-({}))?(?:-({}))?$",
3031
known::LIST_ARCHS.join("|"),

0 commit comments

Comments
 (0)