Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Migrate wasi-threads to `wasmtime::error` (#12275)

Nick Fitzgeralddcdbed12de33
diff --git a/Cargo.lock b/Cargo.lock
index c762e0d0c5..c930fa36cb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5184,7 +5184,6 @@ dependencies = [
name = "wasmtime-wasi-threads"
version = "42.0.0"
dependencies = [
- "anyhow",
"log",
"rand 0.8.5",
"wasi-common",
diff --git a/crates/wasi-threads/Cargo.toml b/crates/wasi-threads/Cargo.toml
index 8ec1c96164..c2533c02e9 100644
--- a/crates/wasi-threads/Cargo.toml
+++ b/crates/wasi-threads/Cargo.toml
@@ -16,7 +16,6 @@ rust-version.workspace = true
workspace = true
[dependencies]
-anyhow = { workspace = true }
log = { workspace = true }
rand = "0.8"
wasi-common = { workspace = true, features = ["exit"]}
diff --git a/crates/wasi-threads/src/lib.rs b/crates/wasi-threads/src/lib.rs
index 043bea5e9c..ffaa8ab2e1 100644
--- a/crates/wasi-threads/src/lib.rs
+++ b/crates/wasi-threads/src/lib.rs
@@ -2,12 +2,13 @@
//!
//! [`wasi-threads`]: https://github.com/WebAssembly/wasi-threads
-use anyhow::{Result, anyhow};
use std::panic::{AssertUnwindSafe, catch_unwind};
use std::sync::Arc;
use std::sync::atomic::{AtomicI32, Ordering};
use std::thread;
-use wasmtime::{Caller, ExternType, InstancePre, Linker, Module, SharedMemory, Store};
+use wasmtime::{
+ Caller, ExternType, InstancePre, Linker, Module, Result, SharedMemory, Store, format_err,
+};
// This name is a function export designated by the wasi-threads specification:
// https://github.com/WebAssembly/wasi-threads/#detailed-design-discussion
@@ -141,7 +142,7 @@ pub fn add_to_linker<T: Clone + Send + 'static>(
store: &wasmtime::Store<T>,
module: &Module,
get_cx: impl Fn(&mut T) -> &WasiThreadsCtx<T> + Send + Sync + Copy + 'static,
-) -> anyhow::Result<()> {
+) -> wasmtime::Result<()> {
linker.func_wrap(
"wasi",
"thread-spawn",
@@ -170,7 +171,7 @@ pub fn add_to_linker<T: Clone + Send + 'static>(
let mem = SharedMemory::new(module.engine(), m.clone())?;
linker.define(store, import.module(), import.name(), mem.clone())?;
} else {
- return Err(anyhow!(
+ return Err(format_err!(
"memory was not shared; a `wasi-threads` must import \
a shared memory as \"memory\""
));