From b7a7cc9120d5304b548d3b8dbc7c4256aefbe3a7 Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Sun, 11 Aug 2024 17:37:42 +1000 Subject: [PATCH] Remove `once_cell` (#2463) - **Fix** - **Fix** - **Fix** - **Fix** - **Fix** - **Fix** --- Cargo.lock | 7 ---- cmd/pen/Cargo.toml | 1 - cmd/pen/src/application_configuration.rs | 34 +++++++++---------- cmd/pen/src/compile_configuration.rs | 7 ++-- cmd/pen/src/documentation_configuration.rs | 6 ++-- cmd/pen/src/test_configuration.rs | 6 ++-- lib/app/Cargo.toml | 1 - lib/app/src/common/package_id_calculator.rs | 4 +-- lib/ast-hir/Cargo.toml | 1 - lib/ast-hir/src/string.rs | 7 ++-- lib/hir-mir/Cargo.toml | 1 - lib/hir-mir/src/compile_configuration.rs | 21 ++++++------ lib/hir-mir/src/list_type_configuration.rs | 6 ++-- lib/hir-mir/src/map_type_configuration.rs | 12 +++---- lib/hir-mir/src/number_type_configuration.rs | 6 ++-- lib/hir-mir/src/string_type_configuration.rs | 6 ++-- lib/hir/Cargo.toml | 1 - lib/mir-fmm/Cargo.toml | 1 - lib/mir-fmm/src/closure/drop.rs | 6 ++-- lib/mir-fmm/src/closure/metadata.rs | 15 ++++---- lib/mir-fmm/src/closure/sync.rs | 6 ++-- lib/mir-fmm/src/configuration.rs | 4 +-- lib/mir-fmm/src/entry_function.rs | 6 ++-- lib/mir-fmm/src/reference_count.rs | 6 ++-- lib/mir-fmm/src/reference_count/pointer.rs | 4 +-- lib/mir-fmm/src/type_.rs | 8 ++--- lib/mir-fmm/src/yield_.rs | 4 +-- lib/mir/Cargo.toml | 1 - packages/os-sync/ffi/application/Cargo.toml | 1 - .../os-sync/ffi/application/src/utilities.rs | 5 ++- packages/os/ffi/application/Cargo.toml | 1 - packages/os/ffi/application/src/utilities.rs | 5 ++- packages/os/ffi/library/Cargo.toml | 1 - packages/os/ffi/library/src/stdio.rs | 9 +++-- 34 files changed, 95 insertions(+), 115 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19acc80235..d866b2661a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,7 +109,6 @@ dependencies = [ "interface", "mir", "mir-fmm", - "once_cell", "parse", "petgraph", "regex", @@ -137,7 +136,6 @@ dependencies = [ "hir", "interface", "itertools", - "once_cell", "position", "pretty_assertions", "regex", @@ -550,7 +548,6 @@ name = "hir" version = "0.1.0" dependencies = [ "fnv", - "once_cell", "petgraph", "plist", "position", @@ -568,7 +565,6 @@ dependencies = [ "interface", "itertools", "mir", - "once_cell", "position", "pretty_assertions", "test-info", @@ -816,7 +812,6 @@ version = "0.1.0" dependencies = [ "fnv", "hamt", - "once_cell", "plist", "pretty_assertions", ] @@ -831,7 +826,6 @@ dependencies = [ "fnv", "insta", "mir", - "once_cell", "plist", "tempfile", ] @@ -944,7 +938,6 @@ dependencies = [ "clap", "indoc", "infra", - "once_cell", "url", ] diff --git a/cmd/pen/Cargo.toml b/cmd/pen/Cargo.toml index 8fa78d0471..d814aba7d9 100644 --- a/cmd/pen/Cargo.toml +++ b/cmd/pen/Cargo.toml @@ -9,5 +9,4 @@ clap = { version = "4", features = ["cargo"] } app = { path = "../../lib/app" } indoc = "2" infra = { path = "../../lib/infra" } -once_cell = "1" url = "2" diff --git a/cmd/pen/src/application_configuration.rs b/cmd/pen/src/application_configuration.rs index 50f8c6d1b6..7c9eb78b13 100644 --- a/cmd/pen/src/application_configuration.rs +++ b/cmd/pen/src/application_configuration.rs @@ -1,18 +1,18 @@ -use once_cell::sync::Lazy; -use std::sync::Arc; +use std::sync::{Arc, LazyLock}; -pub static APPLICATION_CONFIGURATION: Lazy> = Lazy::new(|| { - app::ApplicationConfiguration { - application_filename: "app".into(), - main_module_basename: "main".into(), - context_module_basename: "Context".into(), - main_module: app::MainModuleConfiguration { - source_main_function_name: "main".into(), - object_main_function_name: "_pen_main".into(), - main_context_type_name: "context".into(), - system_context_type_name: "Context".into(), - new_system_context_function_name: "UnsafeNew".into(), - }, - } - .into() -}); +pub static APPLICATION_CONFIGURATION: LazyLock> = + LazyLock::new(|| { + app::ApplicationConfiguration { + application_filename: "app".into(), + main_module_basename: "main".into(), + context_module_basename: "Context".into(), + main_module: app::MainModuleConfiguration { + source_main_function_name: "main".into(), + object_main_function_name: "_pen_main".into(), + main_context_type_name: "context".into(), + system_context_type_name: "Context".into(), + new_system_context_function_name: "UnsafeNew".into(), + }, + } + .into() + }); diff --git a/cmd/pen/src/compile_configuration.rs b/cmd/pen/src/compile_configuration.rs index 87e1ee539c..86a711348b 100644 --- a/cmd/pen/src/compile_configuration.rs +++ b/cmd/pen/src/compile_configuration.rs @@ -1,5 +1,4 @@ -use once_cell::sync::Lazy; -use std::sync::Arc; +use std::sync::{Arc, LazyLock}; pub const CROSS_COMPILE_TARGETS: &[&str] = &[ "i686-unknown-linux-musl", @@ -8,8 +7,8 @@ pub const CROSS_COMPILE_TARGETS: &[&str] = &[ "wasm32-wasi", ]; -pub static COMPILE_CONFIGURATION: Lazy> = - Lazy::new(|| { +pub static COMPILE_CONFIGURATION: LazyLock> = + LazyLock::new(|| { app::module_compiler::CompileConfiguration { fmm: app::module_compiler::FmmConfiguration { allocate_function_name: "_pen_malloc".into(), diff --git a/cmd/pen/src/documentation_configuration.rs b/cmd/pen/src/documentation_configuration.rs index 68d9736db7..e31b8c7c80 100644 --- a/cmd/pen/src/documentation_configuration.rs +++ b/cmd/pen/src/documentation_configuration.rs @@ -1,9 +1,9 @@ use crate::application_configuration::APPLICATION_CONFIGURATION; use app::package_documentation_generator::DocumentationConfiguration; -use once_cell::sync::Lazy; +use std::sync::LazyLock; -pub static DOCUMENTATION_CONFIGURATION: Lazy = - Lazy::new(|| DocumentationConfiguration { +pub static DOCUMENTATION_CONFIGURATION: LazyLock = + LazyLock::new(|| DocumentationConfiguration { language: "pen".into(), private_names: [APPLICATION_CONFIGURATION .main_module diff --git a/cmd/pen/src/test_configuration.rs b/cmd/pen/src/test_configuration.rs index a129de0d42..3a7bafc206 100644 --- a/cmd/pen/src/test_configuration.rs +++ b/cmd/pen/src/test_configuration.rs @@ -1,7 +1,7 @@ -use once_cell::sync::Lazy; +use std::sync::LazyLock; -pub static TEST_CONFIGURATION: Lazy = - Lazy::new(|| app::TestConfiguration { +pub static TEST_CONFIGURATION: LazyLock = + LazyLock::new(|| app::TestConfiguration { test_module_configuration: app::TestModuleConfiguration { test_function_prefix: "_pen_test_".into(), }, diff --git a/lib/app/Cargo.toml b/lib/app/Cargo.toml index be461e4e67..5d6286f2a5 100644 --- a/lib/app/Cargo.toml +++ b/lib/app/Cargo.toml @@ -18,7 +18,6 @@ hir_mir = { path = "../hir-mir" } interface = { path = "../interface" } mir = { path = "../mir" } mir-fmm = { path = "../mir-fmm" } -once_cell = "1" parse = { path = "../parse" } petgraph = "0.6" regex = "1" diff --git a/lib/app/src/common/package_id_calculator.rs b/lib/app/src/common/package_id_calculator.rs index d90cb91ce3..7243678d44 100644 --- a/lib/app/src/common/package_id_calculator.rs +++ b/lib/app/src/common/package_id_calculator.rs @@ -1,9 +1,9 @@ -use once_cell::sync::Lazy; use regex::Regex; +use std::sync::LazyLock; const REPLACEMENT_STRING: &str = "_"; -static REPLACEMENT_REGEX: Lazy = Lazy::new(|| Regex::new(r"[.:/]+").unwrap()); +static REPLACEMENT_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"[.:/]+").unwrap()); pub fn calculate(url: &url::Url) -> String { REPLACEMENT_REGEX diff --git a/lib/ast-hir/Cargo.toml b/lib/ast-hir/Cargo.toml index 327f16a4e7..47c56d23b0 100644 --- a/lib/ast-hir/Cargo.toml +++ b/lib/ast-hir/Cargo.toml @@ -10,7 +10,6 @@ fnv = "1" hir = { path = "../hir" } interface = { path = "../interface" } itertools = "0.13" -once_cell = "1" position = { path = "../position" } regex = "1" diff --git a/lib/ast-hir/src/string.rs b/lib/ast-hir/src/string.rs index 84f0f54c47..24ebad3bf6 100644 --- a/lib/ast-hir/src/string.rs +++ b/lib/ast-hir/src/string.rs @@ -1,9 +1,8 @@ -use once_cell::sync::Lazy; use regex::bytes::{Captures, Regex}; -use std::str; +use std::{str, sync::LazyLock}; -static HEX_CHARACTER_REGEX: Lazy = - Lazy::new(|| Regex::new(r"\\x([0-9a-fA-F][0-9a-fA-F])").unwrap()); +static HEX_CHARACTER_REGEX: LazyLock = + LazyLock::new(|| Regex::new(r"\\x([0-9a-fA-F][0-9a-fA-F])").unwrap()); pub fn compile(string: &str) -> Vec { HEX_CHARACTER_REGEX diff --git a/lib/hir-mir/Cargo.toml b/lib/hir-mir/Cargo.toml index e2ba3d57b4..ce1c342737 100644 --- a/lib/hir-mir/Cargo.toml +++ b/lib/hir-mir/Cargo.toml @@ -15,5 +15,4 @@ test-info = { path = "../test-info" } [dev-dependencies] insta = "1" -once_cell = "1" pretty_assertions = "1" diff --git a/lib/hir-mir/src/compile_configuration.rs b/lib/hir-mir/src/compile_configuration.rs index c34eb81dc2..9a9ce85703 100644 --- a/lib/hir-mir/src/compile_configuration.rs +++ b/lib/hir-mir/src/compile_configuration.rs @@ -11,7 +11,7 @@ use super::{ }; use crate::number_type_configuration::NumberTypeConfiguration; #[cfg(test)] -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[derive(Clone, Debug)] pub struct CompileConfiguration { @@ -25,12 +25,13 @@ pub struct CompileConfiguration { } #[cfg(test)] -pub static COMPILE_CONFIGURATION: Lazy = Lazy::new(|| CompileConfiguration { - list_type: LIST_TYPE_CONFIGURATION.clone(), - map_type: MAP_TYPE_CONFIGURATION.clone(), - number_type: NUMBER_TYPE_CONFIGURATION.clone(), - string_type: STRING_TYPE_CONFIGURATION.clone(), - debug_function_name: "debug".into(), - race_function_name: "race".into(), - spawn_function_name: "spawn".into(), -}); +pub static COMPILE_CONFIGURATION: LazyLock = + LazyLock::new(|| CompileConfiguration { + list_type: LIST_TYPE_CONFIGURATION.clone(), + map_type: MAP_TYPE_CONFIGURATION.clone(), + number_type: NUMBER_TYPE_CONFIGURATION.clone(), + string_type: STRING_TYPE_CONFIGURATION.clone(), + debug_function_name: "debug".into(), + race_function_name: "race".into(), + spawn_function_name: "spawn".into(), + }); diff --git a/lib/hir-mir/src/list_type_configuration.rs b/lib/hir-mir/src/list_type_configuration.rs index 8f9af19e30..c455284d58 100644 --- a/lib/hir-mir/src/list_type_configuration.rs +++ b/lib/hir-mir/src/list_type_configuration.rs @@ -1,9 +1,9 @@ #[cfg(test)] -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[cfg(test)] -pub static LIST_TYPE_CONFIGURATION: Lazy = - Lazy::new(|| ListTypeConfiguration { +pub static LIST_TYPE_CONFIGURATION: LazyLock = + LazyLock::new(|| ListTypeConfiguration { empty_function_name: "emptyList".into(), concatenate_function_name: "concatenateLists".into(), equal_function_name: "equalLists".into(), diff --git a/lib/hir-mir/src/map_type_configuration.rs b/lib/hir-mir/src/map_type_configuration.rs index 93cc727d6e..512b70fbff 100644 --- a/lib/hir-mir/src/map_type_configuration.rs +++ b/lib/hir-mir/src/map_type_configuration.rs @@ -1,9 +1,9 @@ #[cfg(test)] -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[cfg(test)] -pub static MAP_TYPE_CONFIGURATION: Lazy = - Lazy::new(|| MapTypeConfiguration { +pub static MAP_TYPE_CONFIGURATION: LazyLock = + LazyLock::new(|| MapTypeConfiguration { context_function_name: "newMapContext".into(), context_type_name: "mapContext".into(), delete_function_name: "deleteMap".into(), @@ -22,7 +22,7 @@ pub static MAP_TYPE_CONFIGURATION: Lazy = }); #[cfg(test)] -pub static HASH_CONFIGURATION: Lazy = Lazy::new(|| HashConfiguration { +pub static HASH_CONFIGURATION: LazyLock = LazyLock::new(|| HashConfiguration { combine_function_name: "combineHashes".into(), number_hash_function_name: "hashNumber".into(), string_hash_function_name: "hashString".into(), @@ -31,8 +31,8 @@ pub static HASH_CONFIGURATION: Lazy = Lazy::new(|| HashConfig }); #[cfg(test)] -pub static MAP_TYPE_ITERATION_CONFIGURATION: Lazy = - Lazy::new(|| MapTypeIterationConfiguration { +pub static MAP_TYPE_ITERATION_CONFIGURATION: LazyLock = + LazyLock::new(|| MapTypeIterationConfiguration { iterator_type_name: "mapIterator".into(), iterate_function_name: "iterateMap".into(), key_function_name: "mapIteratorKey".into(), diff --git a/lib/hir-mir/src/number_type_configuration.rs b/lib/hir-mir/src/number_type_configuration.rs index 7cb12fc8b4..cdb9bbd689 100644 --- a/lib/hir-mir/src/number_type_configuration.rs +++ b/lib/hir-mir/src/number_type_configuration.rs @@ -1,9 +1,9 @@ #[cfg(test)] -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[cfg(test)] -pub static NUMBER_TYPE_CONFIGURATION: Lazy = - Lazy::new(|| NumberTypeConfiguration { +pub static NUMBER_TYPE_CONFIGURATION: LazyLock = + LazyLock::new(|| NumberTypeConfiguration { debug_function_name: "debugNumber".into(), }); diff --git a/lib/hir-mir/src/string_type_configuration.rs b/lib/hir-mir/src/string_type_configuration.rs index 5c01c58109..1c7e3e29f4 100644 --- a/lib/hir-mir/src/string_type_configuration.rs +++ b/lib/hir-mir/src/string_type_configuration.rs @@ -1,9 +1,9 @@ #[cfg(test)] -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[cfg(test)] -pub static STRING_TYPE_CONFIGURATION: Lazy = - Lazy::new(|| StringTypeConfiguration { +pub static STRING_TYPE_CONFIGURATION: LazyLock = + LazyLock::new(|| StringTypeConfiguration { equal_function_name: "_equalStrings".into(), }); diff --git a/lib/hir/Cargo.toml b/lib/hir/Cargo.toml index 8e07f31d0b..6157ab0707 100644 --- a/lib/hir/Cargo.toml +++ b/lib/hir/Cargo.toml @@ -12,5 +12,4 @@ position = { path = "../position" } serde = { version = "1", features = ["derive", "rc"] } [dev-dependencies] -once_cell = "1" pretty_assertions = "1" diff --git a/lib/mir-fmm/Cargo.toml b/lib/mir-fmm/Cargo.toml index 68aa9fe035..c5d1417219 100644 --- a/lib/mir-fmm/Cargo.toml +++ b/lib/mir-fmm/Cargo.toml @@ -10,7 +10,6 @@ edition = "2021" fmm = { git = "https://github.com/raviqqe/fmm", branch = "main" } fnv = "1" mir = { path = "../mir" } -once_cell = "1" plist = { git = "https://github.com/raviqqe/plist-rs", branch = "main" } [dev-dependencies] diff --git a/lib/mir-fmm/src/closure/drop.rs b/lib/mir-fmm/src/closure/drop.rs index 85e0374635..c3df683580 100644 --- a/lib/mir-fmm/src/closure/drop.rs +++ b/lib/mir-fmm/src/closure/drop.rs @@ -3,11 +3,11 @@ use crate::{ reference_count::{self, REFERENCE_COUNT_FUNCTION_DEFINITION_OPTIONS}, type_, CompileError, }; -use once_cell::sync::Lazy; +use std::sync::LazyLock; thread_local! { - static DUMMY_FUNCTION_TYPE: Lazy = - Lazy::new(|| mir::types::Function::new(vec![], mir::types::Type::None)); + static DUMMY_FUNCTION_TYPE: LazyLock = + LazyLock::new(|| mir::types::Function::new(vec![], mir::types::Type::None)); } pub fn compile( diff --git a/lib/mir-fmm/src/closure/metadata.rs b/lib/mir-fmm/src/closure/metadata.rs index 0194afd43c..69cd96abd8 100644 --- a/lib/mir-fmm/src/closure/metadata.rs +++ b/lib/mir-fmm/src/closure/metadata.rs @@ -1,13 +1,14 @@ use super::{drop, sync}; use crate::{context::Context, CompileError}; -use once_cell::sync::Lazy; +use std::sync::LazyLock; -static VARIABLE_DEFINITION_OPTIONS: Lazy = Lazy::new(|| { - fmm::ir::VariableDefinitionOptions::new() - .set_address_named(false) - .set_linkage(fmm::ir::Linkage::Internal) - .set_mutable(false) -}); +static VARIABLE_DEFINITION_OPTIONS: LazyLock = + LazyLock::new(|| { + fmm::ir::VariableDefinitionOptions::new() + .set_address_named(false) + .set_linkage(fmm::ir::Linkage::Internal) + .set_mutable(false) + }); // We do not need to compile closure metadata for thunks in the middle of // evaluation because of the following reasons. diff --git a/lib/mir-fmm/src/closure/sync.rs b/lib/mir-fmm/src/closure/sync.rs index bf04e6bfcf..5da35f13ec 100644 --- a/lib/mir-fmm/src/closure/sync.rs +++ b/lib/mir-fmm/src/closure/sync.rs @@ -3,11 +3,11 @@ use crate::{ reference_count::{self, REFERENCE_COUNT_FUNCTION_DEFINITION_OPTIONS}, type_, CompileError, }; -use once_cell::sync::Lazy; +use std::sync::LazyLock; thread_local! { - static DUMMY_FUNCTION_TYPE: Lazy = - Lazy::new(|| mir::types::Function::new(vec![], mir::types::Type::None)); + static DUMMY_FUNCTION_TYPE: LazyLock = + LazyLock::new(|| mir::types::Function::new(vec![], mir::types::Type::None)); } pub fn compile( diff --git a/lib/mir-fmm/src/configuration.rs b/lib/mir-fmm/src/configuration.rs index c1a39fbbe5..133d6db5eb 100644 --- a/lib/mir-fmm/src/configuration.rs +++ b/lib/mir-fmm/src/configuration.rs @@ -1,8 +1,8 @@ #[cfg(test)] -use once_cell::sync::Lazy; +use std::sync::LazyLock; #[cfg(test)] -pub static CONFIGURATION: Lazy = Lazy::new(|| Configuration { +pub static CONFIGURATION: LazyLock = LazyLock::new(|| Configuration { yield_function_name: "mir_yield".into(), }); diff --git a/lib/mir-fmm/src/entry_function.rs b/lib/mir-fmm/src/entry_function.rs index 7b701f0954..1ddf8bbe37 100644 --- a/lib/mir-fmm/src/entry_function.rs +++ b/lib/mir-fmm/src/entry_function.rs @@ -2,12 +2,12 @@ use super::error::CompileError; use crate::{ closure, context::Context, expression, reference_count, type_, yield_::yield_function_type, }; -use once_cell::sync::Lazy; +use std::sync::LazyLock; const CLOSURE_NAME: &str = "_closure"; -static ENTRY_FUNCTION_DEFINITION_OPTIONS: Lazy = - Lazy::new(|| { +static ENTRY_FUNCTION_DEFINITION_OPTIONS: LazyLock = + LazyLock::new(|| { fmm::ir::FunctionDefinitionOptions::new() .set_address_named(false) .set_calling_convention(fmm::types::CallingConvention::Source) diff --git a/lib/mir-fmm/src/reference_count.rs b/lib/mir-fmm/src/reference_count.rs index ad37813386..bf00963f6c 100644 --- a/lib/mir-fmm/src/reference_count.rs +++ b/lib/mir-fmm/src/reference_count.rs @@ -9,11 +9,11 @@ pub mod string; pub mod variant; pub use expression::*; -use once_cell::sync::Lazy; +use std::sync::LazyLock; -pub(super) static REFERENCE_COUNT_FUNCTION_DEFINITION_OPTIONS: Lazy< +pub(super) static REFERENCE_COUNT_FUNCTION_DEFINITION_OPTIONS: LazyLock< fmm::ir::FunctionDefinitionOptions, -> = Lazy::new(|| { +> = LazyLock::new(|| { fmm::ir::FunctionDefinitionOptions::new() .set_address_named(false) .set_calling_convention(fmm::types::CallingConvention::Target) diff --git a/lib/mir-fmm/src/reference_count/pointer.rs b/lib/mir-fmm/src/reference_count/pointer.rs index f5f2c44122..218962dfea 100644 --- a/lib/mir-fmm/src/reference_count/pointer.rs +++ b/lib/mir-fmm/src/reference_count/pointer.rs @@ -1,6 +1,6 @@ use super::{super::error::CompileError, block, count, heap}; use crate::{context::Context, reference_count::REFERENCE_COUNT_FUNCTION_DEFINITION_OPTIONS}; -use once_cell::unsync::Lazy; +use std::cell::LazyCell; // Reference counts are negative for synchronized memory blocks and otherwise // positive. References to static memory blocks are tagged. @@ -8,7 +8,7 @@ use once_cell::unsync::Lazy; const CLONE_FUNCTION_NAME: &str = "mir:clone:pointer"; thread_local! { - static CLONE_FUNCTION_VARIABLE: Lazy = Lazy::new(|| { + static CLONE_FUNCTION_VARIABLE: LazyCell = LazyCell::new(|| { fmm::build::variable( CLONE_FUNCTION_NAME, fmm::types::Function::new( diff --git a/lib/mir-fmm/src/type_.rs b/lib/mir-fmm/src/type_.rs index 7f40dd29fe..4afe94c1a8 100644 --- a/lib/mir-fmm/src/type_.rs +++ b/lib/mir-fmm/src/type_.rs @@ -2,7 +2,7 @@ pub mod foreign; pub mod variant; use crate::context::Context; -use once_cell::unsync::Lazy; +use std::cell::LazyCell; pub const FUNCTION_ARGUMENT_OFFSET: usize = 1; @@ -39,7 +39,7 @@ pub fn compile_none() -> fmm::types::Type { pub fn compile_string() -> fmm::types::Pointer { thread_local! { - static TYPE: Lazy = Lazy::new(|| { + static TYPE: LazyCell = LazyCell::new(|| { fmm::types::Pointer::new(fmm::types::Record::new(vec![ fmm::types::Primitive::PointerInteger.into(), // The first byte of a string @@ -53,7 +53,7 @@ pub fn compile_string() -> fmm::types::Pointer { fn compile_variant() -> fmm::types::Record { thread_local! { - static TYPE: Lazy = Lazy::new(|| { + static TYPE: LazyCell = LazyCell::new(|| { fmm::types::Record::new(vec![ compile_variant_tag().into(), compile_variant_payload().into(), @@ -66,7 +66,7 @@ fn compile_variant() -> fmm::types::Record { pub fn compile_variant_tag() -> fmm::types::Pointer { thread_local! { - static TYPE: Lazy = Lazy::new(|| { + static TYPE: LazyCell = LazyCell::new(|| { let payload = fmm::types::Type::from(compile_variant_payload()); fmm::types::Pointer::new(fmm::types::Record::new(vec![ diff --git a/lib/mir-fmm/src/yield_.rs b/lib/mir-fmm/src/yield_.rs index fa30518245..81f1b35082 100644 --- a/lib/mir-fmm/src/yield_.rs +++ b/lib/mir-fmm/src/yield_.rs @@ -1,8 +1,8 @@ use crate::context::Context; -use once_cell::unsync::Lazy; +use std::cell::LazyCell; thread_local! { - static YIELD_FUNCTION_TYPE: Lazy = Lazy::new(|| { + static YIELD_FUNCTION_TYPE: LazyCell = LazyCell::new(|| { fmm::types::Function::new( vec![], fmm::types::void_type(), diff --git a/lib/mir/Cargo.toml b/lib/mir/Cargo.toml index e2ce33c75e..9eb028ee36 100644 --- a/lib/mir/Cargo.toml +++ b/lib/mir/Cargo.toml @@ -13,4 +13,3 @@ plist = { git = "https://github.com/raviqqe/plist-rs", branch = "main" } [dev-dependencies] pretty_assertions = "1.4" -once_cell = "1" diff --git a/packages/os-sync/ffi/application/Cargo.toml b/packages/os-sync/ffi/application/Cargo.toml index ddee7f3ade..2582f9cac8 100644 --- a/packages/os-sync/ffi/application/Cargo.toml +++ b/packages/os-sync/ffi/application/Cargo.toml @@ -6,4 +6,3 @@ edition = "2021" [dependencies] ffi = { package = "pen-ffi", version = "*" } -once_cell = "1" diff --git a/packages/os-sync/ffi/application/src/utilities.rs b/packages/os-sync/ffi/application/src/utilities.rs index a4c9b97972..78340f973c 100644 --- a/packages/os-sync/ffi/application/src/utilities.rs +++ b/packages/os-sync/ffi/application/src/utilities.rs @@ -1,7 +1,6 @@ -use once_cell::sync::Lazy; -use std::env; +use std::{env, sync::LazyLock}; -static OS_DEBUG: Lazy = Lazy::new(|| env::var("PEN_OS_DEBUG").is_ok()); +static OS_DEBUG: LazyLock = LazyLock::new(|| env::var("PEN_OS_DEBUG").is_ok()); pub fn is_os_debug() -> bool { *OS_DEBUG diff --git a/packages/os/ffi/application/Cargo.toml b/packages/os/ffi/application/Cargo.toml index bdf6389abd..485398119a 100644 --- a/packages/os/ffi/application/Cargo.toml +++ b/packages/os/ffi/application/Cargo.toml @@ -8,5 +8,4 @@ edition = "2021" async-stream = "0.3" ffi = { package = "pen-ffi", version = "*", features = ["runtime"] } futures = "0.3" -once_cell = "1" tokio = { "version" = "1", features = ["full"] } diff --git a/packages/os/ffi/application/src/utilities.rs b/packages/os/ffi/application/src/utilities.rs index a4c9b97972..78340f973c 100644 --- a/packages/os/ffi/application/src/utilities.rs +++ b/packages/os/ffi/application/src/utilities.rs @@ -1,7 +1,6 @@ -use once_cell::sync::Lazy; -use std::env; +use std::{env, sync::LazyLock}; -static OS_DEBUG: Lazy = Lazy::new(|| env::var("PEN_OS_DEBUG").is_ok()); +static OS_DEBUG: LazyLock = LazyLock::new(|| env::var("PEN_OS_DEBUG").is_ok()); pub fn is_os_debug() -> bool { *OS_DEBUG diff --git a/packages/os/ffi/library/Cargo.toml b/packages/os/ffi/library/Cargo.toml index f4fcf5a2c1..46533d63e3 100644 --- a/packages/os/ffi/library/Cargo.toml +++ b/packages/os/ffi/library/Cargo.toml @@ -10,5 +10,4 @@ crate-type = ["staticlib"] [dependencies] ffi = { package = "pen-ffi", version = "*", features = ["runtime", "std"] } futures = "0.3" -once_cell = "1" tokio = { version = "1", features = ["full"] } diff --git a/packages/os/ffi/library/src/stdio.rs b/packages/os/ffi/library/src/stdio.rs index 6d521564a2..985d05ef4e 100644 --- a/packages/os/ffi/library/src/stdio.rs +++ b/packages/os/ffi/library/src/stdio.rs @@ -1,16 +1,15 @@ use crate::utilities; use core::ops::DerefMut; -use once_cell::sync::Lazy; -use std::error::Error; +use std::{error::Error, sync::LazyLock}; use tokio::{ io::{stderr, stdin, stdout, AsyncWriteExt, Stderr, Stdin, Stdout}, sync::Mutex, }; // Use single buffers for standard I/O. -static STDIN: Lazy> = Lazy::new(|| Mutex::new(stdin())); -static STDOUT: Lazy> = Lazy::new(|| Mutex::new(stdout())); -static STDERR: Lazy> = Lazy::new(|| Mutex::new(stderr())); +static STDIN: LazyLock> = LazyLock::new(|| Mutex::new(stdin())); +static STDOUT: LazyLock> = LazyLock::new(|| Mutex::new(stdout())); +static STDERR: LazyLock> = LazyLock::new(|| Mutex::new(stderr())); #[ffi::bindgen] async fn _pen_os_read_stdin() -> Result> {