Skip to content

Commit 335ec81

Browse files
committed
Replace once_cell with standard library OnceLock and LazyLock
1 parent 7d479c7 commit 335ec81

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

BUCK

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ rust_library(
7373
deps = [
7474
"//third-party:cc",
7575
"//third-party:codespan-reporting",
76-
"//third-party:once_cell",
7776
"//third-party:proc-macro2",
7877
"//third-party:quote",
7978
"//third-party:scratch",

BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ rust_library(
6969
deps = [
7070
"@crates.io//:cc",
7171
"@crates.io//:codespan-reporting",
72-
"@crates.io//:once_cell",
7372
"@crates.io//:proc-macro2",
7473
"@crates.io//:quote",
7574
"@crates.io//:scratch",

gen/build/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ experimental-async-fn = []
2121
[dependencies]
2222
cc = "1.0.83"
2323
codespan-reporting = "0.11.1"
24-
once_cell = "1.18"
2524
proc-macro2 = { version = "1.0.74", default-features = false, features = ["span-locations"] }
2625
quote = { version = "1.0.35", default-features = false }
2726
scratch = "1.0.5"

gen/build/src/cargo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::gen::{CfgEvaluator, CfgResult};
2-
use once_cell::sync::OnceCell;
32
use std::borrow::Borrow;
43
use std::cmp::Ordering;
54
use std::collections::{BTreeMap as Map, BTreeSet as Set};
65
use std::env;
6+
use std::sync::OnceLock;
77

8-
static ENV: OnceCell<CargoEnv> = OnceCell::new();
8+
static ENV: OnceLock<CargoEnv> = OnceLock::new();
99

1010
struct CargoEnv {
1111
features: Set<Name>,

gen/build/src/cfg.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,11 @@ mod r#impl {
344344
use crate::intern::{intern, InternedString};
345345
use crate::syntax::map::UnorderedMap as Map;
346346
use crate::vec::{self, InternedVec as _};
347-
use once_cell::sync::Lazy;
348347
use std::cell::RefCell;
349348
use std::fmt::{self, Debug};
350349
use std::marker::PhantomData;
351350
use std::ops::{Deref, DerefMut};
352-
use std::sync::{PoisonError, RwLock};
351+
use std::sync::{LazyLock, PoisonError, RwLock};
353352

354353
struct CurrentCfg {
355354
include_prefix: InternedString,
@@ -378,7 +377,8 @@ mod r#impl {
378377
}
379378
}
380379

381-
static CURRENT: Lazy<RwLock<CurrentCfg>> = Lazy::new(|| RwLock::new(CurrentCfg::default()));
380+
static CURRENT: LazyLock<RwLock<CurrentCfg>> =
381+
LazyLock::new(|| RwLock::new(CurrentCfg::default()));
382382

383383
thread_local! {
384384
// FIXME: If https://github.com/rust-lang/rust/issues/77425 is resolved,

gen/build/src/intern.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::syntax::set::UnorderedSet as Set;
2-
use once_cell::sync::OnceCell;
3-
use std::sync::{Mutex, PoisonError};
2+
use std::sync::{Mutex, OnceLock, PoisonError};
43

54
#[derive(Copy, Clone, Default)]
65
pub(crate) struct InternedString(&'static str);
@@ -12,7 +11,7 @@ impl InternedString {
1211
}
1312

1413
pub(crate) fn intern(s: &str) -> InternedString {
15-
static INTERN: OnceCell<Mutex<Set<&'static str>>> = OnceCell::new();
14+
static INTERN: OnceLock<Mutex<Set<&'static str>>> = OnceLock::new();
1615

1716
let mut set = INTERN
1817
.get_or_init(|| Mutex::new(Set::new()))

0 commit comments

Comments
 (0)