Skip to content

Commit b79a96a

Browse files
authored
Leverage Rust 1.79, 1.80 (#9498)
This commit is a follow-up to #9496 to leverage various APIs that the workspace now has access to. For example most dependencies on the `once_cell` crate are now removed in favor of the types stabilized in the standard library: `LazyLock` and `LazyCell`. One dependency remains in the `wasmtime` crate due to the `get_or_try_init` not being stable yet. Some additional helper methods on raw pointer slices are also available for removing a few minor `unsafe` blocks.
1 parent a40776c commit b79a96a

File tree

32 files changed

+46
-73
lines changed

32 files changed

+46
-73
lines changed

Cargo.lock

Lines changed: 0 additions & 9 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ clap = { workspace = true }
6161
clap_complete = { workspace = true, optional = true }
6262
anyhow = { workspace = true, features = ['std'] }
6363
target-lexicon = { workspace = true }
64-
once_cell = { workspace = true }
6564
listenfd = { version = "1.0.0", optional = true }
6665
wat = { workspace = true, optional = true }
6766
serde = { workspace = true }
@@ -299,7 +298,6 @@ clap = { version = "4.5.17", default-features = false, features = ["std", "deriv
299298
clap_complete = "4.4.7"
300299
hashbrown = { version = "0.14", default-features = false }
301300
capstone = "0.12.0"
302-
once_cell = { version = "1.12.0", default-features = false }
303301
smallvec = { version = "1.6.1", features = ["union"] }
304302
tracing = "0.1.26"
305303
bitflags = "2.0"

benches/instantiation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Result;
22
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
3-
use once_cell::unsync::Lazy;
3+
use std::cell::LazyCell;
44
use std::path::Path;
55
use std::process::Command;
66
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};
@@ -35,7 +35,7 @@ fn bench_sequential(c: &mut Criterion, path: &Path) {
3535
benchmark_name(&strategy),
3636
path.file_name().unwrap().to_str().unwrap(),
3737
);
38-
let state = Lazy::new(|| {
38+
let state = LazyCell::new(|| {
3939
let mut config = Config::default();
4040
config.allocation_strategy(strategy.clone());
4141

@@ -70,7 +70,7 @@ fn bench_parallel(c: &mut Criterion, path: &Path) {
7070
let mut group = c.benchmark_group("parallel");
7171

7272
for strategy in strategies() {
73-
let state = Lazy::new(|| {
73+
let state = LazyCell::new(|| {
7474
let mut config = Config::default();
7575
config.allocation_strategy(strategy.clone());
7676

@@ -153,7 +153,7 @@ fn bench_deserialize_module(c: &mut Criterion, path: &Path) {
153153

154154
let name = path.file_name().unwrap().to_str().unwrap();
155155
let tmpfile = tempfile::NamedTempFile::new().unwrap();
156-
let state = Lazy::new(|| {
156+
let state = LazyCell::new(|| {
157157
let engine = Engine::default();
158158
let module = Module::from_file(&engine, path).expect("failed to load WASI example module");
159159
let bytes = module.serialize().unwrap();

cranelift/fuzzgen/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ workspace = true
1717
cranelift = { workspace = true }
1818
cranelift-native = { workspace = true }
1919

20-
anyhow = { workspace = true }
20+
anyhow = { workspace = true, features = ['std'] }
2121
arbitrary = { workspace = true }
22-
once_cell = { workspace = true }
2322
target-lexicon = { workspace = true, features = ["std"] }

cranelift/fuzzgen/src/function_generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ use cranelift::prelude::{
1919
EntityRef, ExtFuncData, FloatCC, InstBuilder, IntCC, JumpTableData, MemFlags, StackSlotData,
2020
StackSlotKind,
2121
};
22-
use once_cell::sync::Lazy;
2322
use std::collections::HashMap;
2423
use std::ops::RangeInclusive;
2524
use std::str::FromStr;
25+
use std::sync::LazyLock;
2626
use target_lexicon::{Architecture, Triple};
2727

2828
type BlockSignature = Vec<Type>;
@@ -789,7 +789,7 @@ fn valid_for_target(triple: &Triple, op: Opcode, args: &[Type], rets: &[Type]) -
789789

790790
type OpcodeSignature = (Opcode, Vec<Type>, Vec<Type>);
791791

792-
static OPCODE_SIGNATURES: Lazy<Vec<OpcodeSignature>> = Lazy::new(|| {
792+
static OPCODE_SIGNATURES: LazyLock<Vec<OpcodeSignature>> = LazyLock::new(|| {
793793
let types = &[
794794
I8, I16, I32, I64, I128, // Scalar Integers
795795
F32, F64, // Scalar Floats

crates/c-api/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ doctest = false
2222
[dependencies]
2323
env_logger = { workspace = true, optional = true }
2424
anyhow = { workspace = true }
25-
once_cell = { workspace = true }
2625
wasmtime = { workspace = true, features = ['runtime', 'gc', 'std'] }
2726
wasmtime-c-api-macros = { workspace = true }
2827
log = { workspace = true }

crates/c-api/src/trap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{wasm_frame_vec_t, wasm_instance_t, wasm_name_t, wasm_store_t};
22
use anyhow::{anyhow, Error};
3-
use once_cell::unsync::OnceCell;
3+
use std::cell::OnceCell;
44
use wasmtime::{Trap, WasmBacktrace};
55

66
#[repr(C)]

crates/c-api/src/types/export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{wasm_externtype_t, wasm_name_t, CExternType};
2-
use once_cell::unsync::OnceCell;
2+
use std::cell::OnceCell;
33

44
#[repr(C)]
55
#[derive(Clone)]

crates/c-api/src/types/func.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{wasm_externtype_t, wasm_valtype_t, wasm_valtype_vec_t, CExternType};
2-
use once_cell::unsync::OnceCell;
2+
use std::cell::OnceCell;
33
use std::{
44
mem,
55
sync::{Arc, Mutex},

crates/c-api/src/types/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{wasm_externtype_t, wasm_valtype_t, CExternType};
2-
use once_cell::unsync::OnceCell;
2+
use std::cell::OnceCell;
33
use wasmtime::GlobalType;
44

55
pub type wasm_mutability_t = u8;

0 commit comments

Comments
 (0)