Skip to content

Commit 9040397

Browse files
David Tolnaymeta-codesync[bot]
authored andcommitted
once_cell -> std::sync in fbcode/buck2
Summary: Most of `once_cell` is now in `std`: `OnceCell`/`OnceLock` (Rust 1.70) and `LazyCell`/`LazyLock` (Rust 1.80). The `race` module and fallible `get_or_try_init` have no stable std equivalent yet. Reviewed By: diliop Differential Revision: D109642549 fbshipit-source-id: 7554e52c246d9f3e59708270bd333945efb7eb90
1 parent 3959a9a commit 9040397

94 files changed

Lines changed: 215 additions & 230 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ notify = "8.2.0"
371371
num-bigint = { version = "0.4.6", features = ["rand", "serde"] }
372372
num_enum = "0.7.6"
373373
object = { version = "0.36.7", features = ["read", "write"] }
374-
once_cell = "1.21.4"
375374
os_str_bytes = { version = "6.6.1", features = ["conversions"] }
376375
pagable = { path = "pagable", features = ["tokio"] }
377376
pagable_storage = { path = "pagable_storage", features = ["tokio"] }

app/buck2_action_impl/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ rust_library(
2727
"fbsource//third-party/rust:hex",
2828
"fbsource//third-party/rust:http",
2929
"fbsource//third-party/rust:itertools",
30-
"fbsource//third-party/rust:once_cell",
3130
"fbsource//third-party/rust:parking_lot",
3231
"fbsource//third-party/rust:serde_json",
3332
"fbsource//third-party/rust:sha1",

app/buck2_action_impl/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ hex.workspace = true
4141
host_sharing.workspace = true
4242
http.workspace = true
4343
itertools.workspace = true
44-
once_cell.workspace = true
4544
pagable.workspace = true
4645
parking_lot.workspace = true
4746
remote_execution.workspace = true

app/buck2_action_impl/src/actions/impls/run/dep_files.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use std::borrow::Cow;
1212
use std::sync::Arc;
13+
use std::sync::LazyLock;
1314

1415
use allocative::Allocative;
1516
use async_trait::async_trait;
@@ -82,7 +83,6 @@ use buck2_hash::StdBuckHashSet;
8283
use derive_more::Display;
8384
use dupe::Dupe;
8485
use futures::StreamExt;
85-
use once_cell::sync::Lazy;
8686
use pagable::Pagable;
8787
use parking_lot::MappedMutexGuard;
8888
use parking_lot::Mutex;
@@ -93,7 +93,8 @@ use tracing::instrument;
9393
use crate::actions::impls::run::RunActionKey;
9494

9595
#[allocative::root]
96-
static DEP_FILES: Lazy<BuckDashMap<RunActionKey, Arc<DepFileState>>> = Lazy::new(BuckDashMap::new);
96+
static DEP_FILES: LazyLock<BuckDashMap<RunActionKey, Arc<DepFileState>>> =
97+
LazyLock::new(BuckDashMap::new);
9798

9899
/// When this is set, we retain directories after fingerprinting, so that we can output them later
99100
/// for debugging via `buck2 audit dep-files`.

app/buck2_build_api/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ rust_library(
3636
"fbsource//third-party/rust:itertools",
3737
"fbsource//third-party/rust:linkme",
3838
"fbsource//third-party/rust:multimap",
39-
"fbsource//third-party/rust:once_cell",
4039
"fbsource//third-party/rust:ref-cast",
4140
"fbsource//third-party/rust:regex",
4241
"fbsource//third-party/rust:serde",

app/buck2_build_api/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ inventory.workspace = true
5353
itertools.workspace = true
5454
linkme.workspace = true
5555
multimap.workspace = true
56-
once_cell.workspace = true
5756
pagable.workspace = true
5857
ref-cast.workspace = true
5958
regex.workspace = true

app/buck2_build_api/src/interpreter/rule_defs/cmd_args/command_line_arg_like_type.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
* above-listed licenses.
99
*/
1010

11-
use once_cell::sync::Lazy;
11+
use std::sync::LazyLock;
12+
1213
use starlark::typing::Ty;
1314

1415
pub struct CommandLineArgLikeImpl {
@@ -41,7 +42,7 @@ pub use command_line_arg_like_impl;
4142
pub static COMMAND_LINE_ARG_LIKE_IMPLS: [CommandLineArgLikeImpl] = [..];
4243

4344
pub(crate) fn command_line_arg_like_ty() -> &'static Ty {
44-
static TY: Lazy<Ty> = Lazy::new(|| {
45+
static TY: LazyLock<Ty> = LazyLock::new(|| {
4546
assert!(!COMMAND_LINE_ARG_LIKE_IMPLS.is_empty());
4647
let ty = Ty::unions(
4748
COMMAND_LINE_ARG_LIKE_IMPLS

app/buck2_bxl/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ rust_library(
2121
"fbsource//third-party/rust:futures",
2222
"fbsource//third-party/rust:itertools",
2323
"fbsource//third-party/rust:num-bigint",
24-
"fbsource//third-party/rust:once_cell",
2524
"fbsource//third-party/rust:serde",
2625
"fbsource//third-party/rust:serde_json",
2726
"fbsource//third-party/rust:tokio",

app/buck2_bxl/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ futures.workspace = true
4646
gazebo.workspace = true
4747
itertools.workspace = true
4848
num-bigint.workspace = true
49-
once_cell.workspace = true
5049
pagable.workspace = true
5150
serde.workspace = true
5251
serde_json.workspace = true

app/buck2_bxl/src/bxl/eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use std::future::Future;
1212
use std::sync::Arc;
13+
use std::sync::LazyLock;
1314

1415
use allocative::Allocative;
1516
use buck2_build_api::bxl::result::BxlResult;
@@ -47,7 +48,6 @@ use dice::DiceTransaction;
4748
use dice_futures::cancellation::CancellationObserver;
4849
use dupe::Dupe;
4950
use itertools::Itertools;
50-
use once_cell::sync::Lazy;
5151
use starlark::eval::Evaluator;
5252
use starlark::values::OwnedFrozenValueTyped;
5353
use starlark::values::UnpackValue;
@@ -69,7 +69,7 @@ use crate::bxl::starlark_defs::context::starlark_async::BxlDiceComputations;
6969
use crate::bxl::starlark_defs::eval_extra::BxlEvalExtra;
7070
use crate::bxl::starlark_defs::functions::BxlErrorWithoutStacktrace;
7171

72-
pub(crate) static LIMITED_EXECUTOR: Lazy<Arc<LimitedExecutor>> = Lazy::new(|| {
72+
pub(crate) static LIMITED_EXECUTOR: LazyLock<Arc<LimitedExecutor>> = LazyLock::new(|| {
7373
Arc::new(LimitedExecutor::new(500)) // Default working thread of tokio is 512 threads. We set it to 500 for here to leave some room for other things.
7474
});
7575

0 commit comments

Comments
 (0)