diff --git a/Cargo.lock b/Cargo.lock index 4717e16e90..2a4fb4ba39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,16 +404,16 @@ dependencies = [ [[package]] name = "clap" -version = "3.1.15" +version = "3.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85a35a599b11c089a7f49105658d089b8f2cf0882993c17daf6de15285c2c35d" +checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", "indexmap", - "lazy_static", + "once_cell", "strsim", "termcolor", "textwrap 0.15.0", @@ -421,9 +421,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.1.7" +version = "3.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1" +checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" dependencies = [ "heck", "proc-macro-error", @@ -434,9 +434,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.0" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" dependencies = [ "os_str_bytes", ] @@ -688,7 +688,7 @@ dependencies = [ name = "cranelift-serde" version = "0.87.0" dependencies = [ - "clap 3.1.15", + "clap 3.2.8", "cranelift-codegen", "cranelift-reader", "serde_json", @@ -701,7 +701,7 @@ dependencies = [ "anyhow", "capstone", "cfg-if", - "clap 3.1.15", + "clap 3.2.8", "cranelift", "cranelift-codegen", "cranelift-entity", @@ -814,26 +814,26 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" dependencies = [ "autocfg 1.1.0", "cfg-if", "crossbeam-utils", - "lazy_static", "memoffset", + "once_cell", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" dependencies = [ "cfg-if", - "lazy_static", + "once_cell", ] [[package]] @@ -1467,7 +1467,7 @@ dependencies = [ name = "islec" version = "0.1.0" dependencies = [ - "clap 3.1.15", + "clap 3.2.8", "cranelift-isle", "env_logger 0.9.0", "miette", @@ -2945,11 +2945,11 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.26" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" +checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" dependencies = [ - "lazy_static", + "once_cell", "valuable", ] @@ -3101,7 +3101,7 @@ dependencies = [ "io-extras", "io-lifetimes", "is-terminal", - "lazy_static", + "once_cell", "rustix", "system-interface", "tempfile", @@ -3164,7 +3164,6 @@ dependencies = [ "cap-tempfile", "io-extras", "io-lifetimes", - "lazy_static", "rustix", "tempfile", "tokio", @@ -3268,8 +3267,8 @@ dependencies = [ name = "wasm-spec-interpreter" version = "0.1.0" dependencies = [ - "lazy_static", "ocaml-interop", + "once_cell", "wat", ] @@ -3326,7 +3325,6 @@ dependencies = [ "bincode", "cfg-if", "indexmap", - "lazy_static", "libc", "log", "object", @@ -3402,9 +3400,9 @@ dependencies = [ "directories-next", "file-per-thread-logger", "filetime", - "lazy_static", "log", "more-asserts", + "once_cell", "pretty_env_logger", "rustix", "serde", @@ -3421,13 +3419,12 @@ version = "0.40.0" dependencies = [ "anyhow", "async-trait", - "clap 3.1.15", + "clap 3.2.8", "component-macro-test", "criterion", "env_logger 0.9.0", "filecheck", "humantime 2.1.0", - "lazy_static", "libc", "listenfd", "memchr", @@ -3461,7 +3458,7 @@ name = "wasmtime-cli-flags" version = "0.40.0" dependencies = [ "anyhow", - "clap 3.1.15", + "clap 3.2.8", "file-per-thread-logger", "pretty_env_logger", "rayon", @@ -3596,8 +3593,8 @@ dependencies = [ name = "wasmtime-jit-debug" version = "0.40.0" dependencies = [ - "lazy_static", "object", + "once_cell", "rustix", ] diff --git a/Cargo.toml b/Cargo.toml index 74e73f1954..c1fd9c4595 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,12 +30,12 @@ wasmtime-wast = { path = "crates/wast", version = "=0.40.0" } wasmtime-wasi = { path = "crates/wasi", version = "0.40.0" } wasmtime-wasi-crypto = { path = "crates/wasi-crypto", version = "0.40.0", optional = true } wasmtime-wasi-nn = { path = "crates/wasi-nn", version = "0.40.0", optional = true } -clap = { version = "3.1.12", features = ["color", "suggestions", "derive"] } +clap = { version = "3.2.0", features = ["color", "suggestions", "derive"] } anyhow = "1.0.19" target-lexicon = { version = "0.12.0", default-features = false } libc = "0.2.60" humantime = "2.0.0" -lazy_static = "1.4.0" +once_cell = "1.12" listenfd = "1.0.0" [target.'cfg(unix)'.dependencies] diff --git a/cranelift/Cargo.toml b/cranelift/Cargo.toml index 9f15c8796b..318b4dad0d 100644 --- a/cranelift/Cargo.toml +++ b/cranelift/Cargo.toml @@ -41,7 +41,7 @@ indicatif = "0.13.0" thiserror = "1.0.15" walkdir = "2.2" anyhow = "1.0.32" -clap = { version = "3.1.12", features = ["derive"] } +clap = { version = "3.2.0", features = ["derive"] } [features] default = ["disas", "wasm", "cranelift-codegen/all-arch", "souper-harvest"] diff --git a/cranelift/isle/islec/Cargo.toml b/cranelift/isle/islec/Cargo.toml index ce35735b4c..d85615e6c8 100644 --- a/cranelift/isle/islec/Cargo.toml +++ b/cranelift/isle/islec/Cargo.toml @@ -10,4 +10,4 @@ publish = false cranelift-isle = { version = "*", path = "../isle/", features = ["miette-errors", "logging"] } env_logger = { version = "0.9", default-features = false } miette = { version = "4.7.0", features = ["fancy"] } -clap = { version = "3.1.12", features = ["derive"] } +clap = { version = "3.2.0", features = ["derive"] } diff --git a/cranelift/serde/Cargo.toml b/cranelift/serde/Cargo.toml index f51d421748..c0ac9fc6f1 100644 --- a/cranelift/serde/Cargo.toml +++ b/cranelift/serde/Cargo.toml @@ -14,7 +14,7 @@ name = "clif-json" path = "src/clif-json.rs" [dependencies] -clap = { version = "3.1.12", features = ["derive"] } +clap = { version = "3.2.0", features = ["derive"] } serde_json = "1.0.26" cranelift-codegen = { path = "../codegen", version = "0.87.0", features = ["enable-serde"] } cranelift-reader = { path = "../reader", version = "0.87.0" } diff --git a/crates/cache/Cargo.toml b/crates/cache/Cargo.toml index efcb4ac276..a57c97f6cb 100644 --- a/crates/cache/Cargo.toml +++ b/crates/cache/Cargo.toml @@ -31,7 +31,7 @@ rustix = { version = "0.35.6", features = ["process"] } [dev-dependencies] filetime = "0.2.7" -lazy_static = "1.3.0" +once_cell = "1.12.0" more-asserts = "0.2.1" pretty_env_logger = "0.4.0" tempfile = "3" diff --git a/crates/cache/src/worker/tests/system_time_stub.rs b/crates/cache/src/worker/tests/system_time_stub.rs index 5e457d63fc..92c18e2058 100644 --- a/crates/cache/src/worker/tests/system_time_stub.rs +++ b/crates/cache/src/worker/tests/system_time_stub.rs @@ -1,9 +1,7 @@ -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::time::{Duration, SystemTime, SystemTimeError}; -lazy_static! { - pub static ref NOW: SystemTime = SystemTime::now(); // no need for RefCell and set_now() for now -} +pub static NOW: Lazy = Lazy::new(SystemTime::now); #[derive(PartialOrd, PartialEq, Ord, Eq)] pub struct SystemTimeStub(SystemTime); diff --git a/crates/cli-flags/Cargo.toml b/crates/cli-flags/Cargo.toml index dbfbe4a8aa..863471ce2f 100644 --- a/crates/cli-flags/Cargo.toml +++ b/crates/cli-flags/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] anyhow = "1.0.19" -clap = { version = "3.1.12", features = ["color", "suggestions", "derive"] } +clap = { version = "3.2.0", features = ["color", "suggestions", "derive"] } file-per-thread-logger = "0.1.1" pretty_env_logger = "0.4.0" rayon = "1.5.0" diff --git a/crates/fuzzing/wasm-spec-interpreter/Cargo.toml b/crates/fuzzing/wasm-spec-interpreter/Cargo.toml index e9e3b746bd..ebd6ba3eaf 100644 --- a/crates/fuzzing/wasm-spec-interpreter/Cargo.toml +++ b/crates/fuzzing/wasm-spec-interpreter/Cargo.toml @@ -13,10 +13,10 @@ license = "Apache-2.0 WITH LLVM-exception" # `build-libinterpret` feature set by this crate's parent). [dependencies] ocaml-interop = { version = "0.8", optional = true } -lazy_static = { version = "1.4", optional = true } +once_cell = { version = "1.12.0", optional = true } [dev-dependencies] wat = "1.0" [features] -build-libinterpret = ["ocaml-interop", "lazy_static"] +build-libinterpret = ["ocaml-interop", "once_cell"] diff --git a/crates/fuzzing/wasm-spec-interpreter/src/with_library.rs b/crates/fuzzing/wasm-spec-interpreter/src/with_library.rs index 81806f61b3..2242f08b5d 100644 --- a/crates/fuzzing/wasm-spec-interpreter/src/with_library.rs +++ b/crates/fuzzing/wasm-spec-interpreter/src/with_library.rs @@ -7,13 +7,11 @@ //! assert_eq!(results, &[Value::I32(43)]); //! ``` use crate::Value; -use lazy_static::lazy_static; use ocaml_interop::{OCamlRuntime, ToOCaml}; +use once_cell::sync::Lazy; use std::sync::Mutex; -lazy_static! { - static ref INTERPRET: Mutex<()> = Mutex::new(()); -} +static INTERPRET: Lazy> = Lazy::new(|| Mutex::new(())); /// Interpret the first function in the passed WebAssembly module (in Wasm form, /// currently, not WAT), optionally with the given parameters. If no parameters diff --git a/crates/jit-debug/Cargo.toml b/crates/jit-debug/Cargo.toml index a28d108a5a..d0a55e6c04 100644 --- a/crates/jit-debug/Cargo.toml +++ b/crates/jit-debug/Cargo.toml @@ -11,7 +11,7 @@ readme = "README.md" edition = "2021" [dependencies] -lazy_static = {version = "1.3.0", optional = true } +once_cell = {version = "1.12.0", optional = true } object = { version = "0.28.0", default-features = false, features = ["std", "read_core"], optional = true } [target.'cfg(target_os = "linux")'.dependencies] @@ -21,5 +21,5 @@ rustix = { version = "0.35.6", features = ["mm", "param", "time"], optional = tr maintenance = { status = "actively-developed" } [features] -gdb_jit_int = ["lazy_static"] +gdb_jit_int = ["once_cell"] perf_jitdump = ["rustix", "object"] diff --git a/crates/jit-debug/src/gdb_jit_int.rs b/crates/jit-debug/src/gdb_jit_int.rs index 3a0f58d9cc..e887cddb0d 100644 --- a/crates/jit-debug/src/gdb_jit_int.rs +++ b/crates/jit-debug/src/gdb_jit_int.rs @@ -2,7 +2,7 @@ //! the __jit_debug_register_code() and __jit_debug_descriptor to register //! or unregister generated object images with debuggers. -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::pin::Pin; use std::ptr; use std::sync::Mutex; @@ -32,15 +32,13 @@ extern "C" { fn __jit_debug_register_code(); } -lazy_static! { - // The process controls access to the __jit_debug_descriptor by itself -- - // the GDB/LLDB accesses this structure and its data at the process startup - // and when paused in __jit_debug_register_code. - // - // The GDB_REGISTRATION lock is needed for GdbJitImageRegistration to protect - // access to the __jit_debug_descriptor within this process. - pub static ref GDB_REGISTRATION: Mutex<()> = Mutex::new(Default::default()); -} +/// The process controls access to the __jit_debug_descriptor by itself -- +/// the GDB/LLDB accesses this structure and its data at the process startup +/// and when paused in __jit_debug_register_code. +/// +/// The GDB_REGISTRATION lock is needed for GdbJitImageRegistration to protect +/// access to the __jit_debug_descriptor within this process. +static GDB_REGISTRATION: Lazy> = Lazy::new(|| Mutex::new(Default::default())); /// Registeration for JIT image pub struct GdbJitImageRegistration { diff --git a/crates/test-programs/wasi-tests/Cargo.lock b/crates/test-programs/wasi-tests/Cargo.lock index dc4aa117a9..232f949bd1 100644 --- a/crates/test-programs/wasi-tests/Cargo.lock +++ b/crates/test-programs/wasi-tests/Cargo.lock @@ -1,10 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +version = 3 [[package]] name = "libc" @@ -18,6 +14,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" +[[package]] +name = "once_cell" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -28,8 +30,8 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" name = "wasi-tests" version = "0.19.0" dependencies = [ - "lazy_static", "libc", "more-asserts", + "once_cell", "wasi", ] diff --git a/crates/test-programs/wasi-tests/Cargo.toml b/crates/test-programs/wasi-tests/Cargo.toml index 772d398fef..af4c4311d1 100644 --- a/crates/test-programs/wasi-tests/Cargo.toml +++ b/crates/test-programs/wasi-tests/Cargo.toml @@ -10,7 +10,7 @@ publish = false libc = "0.2.65" wasi = "0.10.2" more-asserts = "0.2.1" -lazy_static = "1.4" +once_cell = "1.12.0" # This crate is built with the wasm32-wasi target, so it's separate # from the main Wasmtime build, so use this directive to exclude it diff --git a/crates/test-programs/wasi-tests/src/lib.rs b/crates/test-programs/wasi-tests/src/lib.rs index ee2ec88488..821e7f2417 100644 --- a/crates/test-programs/wasi-tests/src/lib.rs +++ b/crates/test-programs/wasi-tests/src/lib.rs @@ -1,9 +1,8 @@ use more_asserts::assert_gt; pub mod config; +use once_cell::sync::Lazy; -lazy_static::lazy_static! { - pub static ref TESTCONFIG: config::TestConfig = config::TestConfig::from_env(); -} +pub static TESTCONFIG: Lazy = Lazy::new(config::TestConfig::from_env); // The `wasi` crate version 0.9.0 and beyond, doesn't // seem to define these constants, so we do it ourselves. diff --git a/crates/wasi-common/cap-std-sync/Cargo.toml b/crates/wasi-common/cap-std-sync/Cargo.toml index 1f667b5569..d0a192c9fb 100644 --- a/crates/wasi-common/cap-std-sync/Cargo.toml +++ b/crates/wasi-common/cap-std-sync/Cargo.toml @@ -29,7 +29,7 @@ is-terminal = "0.3.0" rustix = { version = "0.35.6", features = ["fs"] } [target.'cfg(windows)'.dependencies] -lazy_static = "1.4" +once_cell = "1.12.0" io-extras = "0.15.0" [target.'cfg(windows)'.dependencies.windows-sys] diff --git a/crates/wasi-common/cap-std-sync/src/sched/windows.rs b/crates/wasi-common/cap-std-sync/src/sched/windows.rs index c3f2d06810..e903e6bf34 100644 --- a/crates/wasi-common/cap-std-sync/src/sched/windows.rs +++ b/crates/wasi-common/cap-std-sync/src/sched/windows.rs @@ -9,6 +9,7 @@ // taken the time to improve it. See bug #2880. use anyhow::Context; +use once_cell::sync::Lazy; use std::ops::Deref; use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender, TryRecvError}; use std::sync::Mutex; @@ -145,9 +146,7 @@ struct StdinPoll { notify_rx: Receiver, } -lazy_static::lazy_static! { - static ref STDIN_POLL: Mutex = StdinPoll::new(); -} +static STDIN_POLL: Lazy> = Lazy::new(StdinPoll::new); impl StdinPoll { pub fn new() -> Mutex { diff --git a/crates/wasi-common/tokio/Cargo.toml b/crates/wasi-common/tokio/Cargo.toml index 14224a4ec1..b7a9968948 100644 --- a/crates/wasi-common/tokio/Cargo.toml +++ b/crates/wasi-common/tokio/Cargo.toml @@ -23,7 +23,6 @@ io-lifetimes = { version = "0.7.0", default-features = false } rustix = { version = "0.35.6", features = ["fs"] } [target.'cfg(windows)'.dependencies] -lazy_static = "1.4" io-extras = "0.15.0" [dev-dependencies] diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index 733878d5a8..1c50e309ac 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -34,11 +34,10 @@ bincode = "1.2.1" indexmap = "1.6" paste = "1.0.3" psm = "0.1.11" -lazy_static = "1.4" +once_cell = "1.12.0" rayon = { version = "1.0", optional = true } object = { version = "0.28", default-features = false, features = ['read_core', 'elf'] } async-trait = { version = "0.1.51", optional = true } -once_cell = "1.12" [target.'cfg(target_os = "windows")'.dependencies.windows-sys] version = "0.36.0" diff --git a/crates/wasmtime/src/module/registry.rs b/crates/wasmtime/src/module/registry.rs index 7062ba98ee..732df96141 100644 --- a/crates/wasmtime/src/module/registry.rs +++ b/crates/wasmtime/src/module/registry.rs @@ -3,6 +3,7 @@ #[cfg(feature = "component-model")] use crate::component::Component; use crate::{FrameInfo, Module}; +use once_cell::sync::Lazy; use std::{ collections::BTreeMap, sync::{Arc, RwLock}, @@ -201,9 +202,7 @@ impl ModuleRegistry { // it is also automatically registered with the singleton global module // registry. When a `ModuleRegistry` is destroyed then all of its entries // are removed from the global module registry. -lazy_static::lazy_static! { - static ref GLOBAL_MODULES: RwLock = Default::default(); -} +static GLOBAL_MODULES: Lazy> = Lazy::new(Default::default); type GlobalModuleRegistry = BTreeMap; diff --git a/src/commands/compile.rs b/src/commands/compile.rs index 08c3b06fb1..3cc96e803e 100644 --- a/src/commands/compile.rs +++ b/src/commands/compile.rs @@ -2,36 +2,35 @@ use anyhow::{bail, Context, Result}; use clap::Parser; +use once_cell::sync::Lazy; use std::fs; use std::path::PathBuf; use target_lexicon::Triple; use wasmtime::Engine; use wasmtime_cli_flags::CommonOptions; -lazy_static::lazy_static! { - static ref AFTER_HELP: String = { - format!( - "By default, no CPU features or presets will be enabled for the compilation.\n\ - \n\ - {}\ - \n\ - Usage examples:\n\ - \n\ - Compiling a WebAssembly module for the current platform:\n\ - \n \ - wasmtime compile example.wasm - \n\ - Specifying the output file:\n\ - \n \ - wasmtime compile -o output.cwasm input.wasm\n\ - \n\ - Compiling for a specific platform (Linux) and CPU preset (Skylake):\n\ - \n \ - wasmtime compile --target x86_64-unknown-linux --cranelift-enable skylake foo.wasm\n", - crate::FLAG_EXPLANATIONS.as_str() - ) - }; -} +static AFTER_HELP: Lazy = Lazy::new(|| { + format!( + "By default, no CPU features or presets will be enabled for the compilation.\n\ + \n\ + {}\ + \n\ + Usage examples:\n\ + \n\ + Compiling a WebAssembly module for the current platform:\n\ + \n \ + wasmtime compile example.wasm + \n\ + Specifying the output file:\n\ + \n \ + wasmtime compile -o output.cwasm input.wasm\n\ + \n\ + Compiling for a specific platform (Linux) and CPU preset (Skylake):\n\ + \n \ + wasmtime compile --target x86_64-unknown-linux --cranelift-enable skylake foo.wasm\n", + crate::FLAG_EXPLANATIONS.as_str() + ) +}); /// Compiles a WebAssembly module. #[derive(Parser)] diff --git a/src/commands/run.rs b/src/commands/run.rs index 7dc398bb8c..8185bf7e00 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -2,6 +2,7 @@ use anyhow::{anyhow, bail, Context as _, Result}; use clap::Parser; +use once_cell::sync::Lazy; use std::fs::File; use std::io::Read; use std::thread; @@ -65,11 +66,7 @@ fn parse_preloads(s: &str) -> Result<(String, PathBuf)> { Ok((parts[0].into(), parts[1].into())) } -lazy_static::lazy_static! { - static ref AFTER_HELP: String = { - crate::FLAG_EXPLANATIONS.to_string() - }; -} +static AFTER_HELP: Lazy = Lazy::new(|| crate::FLAG_EXPLANATIONS.to_string()); /// Runs a WebAssembly module #[derive(Parser)] diff --git a/src/commands/wast.rs b/src/commands/wast.rs index a7305ecd6c..53cb37cde5 100644 --- a/src/commands/wast.rs +++ b/src/commands/wast.rs @@ -2,16 +2,13 @@ use anyhow::{Context as _, Result}; use clap::Parser; +use once_cell::sync::Lazy; use std::path::PathBuf; use wasmtime::{Engine, Store}; use wasmtime_cli_flags::CommonOptions; use wasmtime_wast::WastContext; -lazy_static::lazy_static! { - static ref AFTER_HELP: String = { - crate::FLAG_EXPLANATIONS.to_string() - }; -} +static AFTER_HELP: Lazy = Lazy::new(|| crate::FLAG_EXPLANATIONS.to_string()); /// Runs a WebAssembly test script file #[derive(Parser)] diff --git a/src/lib.rs b/src/lib.rs index 39c3c360b4..fbe2ceb746 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,36 +23,41 @@ ) )] +use once_cell::sync::Lazy; use wasmtime_cli_flags::{SUPPORTED_WASI_MODULES, SUPPORTED_WASM_FEATURES}; -lazy_static::lazy_static! { - static ref FLAG_EXPLANATIONS: String = { - use std::fmt::Write; +static FLAG_EXPLANATIONS: Lazy = Lazy::new(|| { + use std::fmt::Write; - let mut s = String::new(); + let mut s = String::new(); - // Explain --wasm-features. - writeln!(&mut s, "Supported values for `--wasm-features`:").unwrap(); - writeln!(&mut s).unwrap(); - let max = SUPPORTED_WASM_FEATURES.iter().max_by_key(|(name, _)| name.len()).unwrap(); - for (name, desc) in SUPPORTED_WASM_FEATURES.iter() { - writeln!(&mut s, "{:width$} {}", name, desc, width = max.0.len() + 2).unwrap(); - } - writeln!(&mut s).unwrap(); + // Explain --wasm-features. + writeln!(&mut s, "Supported values for `--wasm-features`:").unwrap(); + writeln!(&mut s).unwrap(); + let max = SUPPORTED_WASM_FEATURES + .iter() + .max_by_key(|(name, _)| name.len()) + .unwrap(); + for (name, desc) in SUPPORTED_WASM_FEATURES.iter() { + writeln!(&mut s, "{:width$} {}", name, desc, width = max.0.len() + 2).unwrap(); + } + writeln!(&mut s).unwrap(); - // Explain --wasi-modules. - writeln!(&mut s, "Supported values for `--wasi-modules`:").unwrap(); - writeln!(&mut s).unwrap(); - let max = SUPPORTED_WASI_MODULES.iter().max_by_key(|(name, _)| name.len()).unwrap(); - for (name, desc) in SUPPORTED_WASI_MODULES.iter() { - writeln!(&mut s, "{:width$} {}", name, desc, width = max.0.len() + 2).unwrap(); - } + // Explain --wasi-modules. + writeln!(&mut s, "Supported values for `--wasi-modules`:").unwrap(); + writeln!(&mut s).unwrap(); + let max = SUPPORTED_WASI_MODULES + .iter() + .max_by_key(|(name, _)| name.len()) + .unwrap(); + for (name, desc) in SUPPORTED_WASI_MODULES.iter() { + writeln!(&mut s, "{:width$} {}", name, desc, width = max.0.len() + 2).unwrap(); + } - writeln!(&mut s).unwrap(); - writeln!(&mut s, "Features prefixed with '-' will be disabled.").unwrap(); + writeln!(&mut s).unwrap(); + writeln!(&mut s, "Features prefixed with '-' will be disabled.").unwrap(); - s - }; -} + s +}); pub mod commands; diff --git a/tests/all/wast.rs b/tests/all/wast.rs index ecc5c34312..3a34dee980 100644 --- a/tests/all/wast.rs +++ b/tests/all/wast.rs @@ -1,3 +1,4 @@ +use once_cell::sync::Lazy; use std::path::Path; use std::sync::{Condvar, Mutex}; use wasmtime::{ @@ -118,9 +119,7 @@ fn feature_found(path: &Path, name: &str) -> bool { fn lock_pooling() -> impl Drop { const MAX_CONCURRENT_POOLING: u32 = 8; - lazy_static::lazy_static! { - static ref ACTIVE: MyState = MyState::default(); - } + static ACTIVE: Lazy = Lazy::new(MyState::default); #[derive(Default)] struct MyState {