Skip to content

Commit dcdbed1

Browse files
authored
Migrate wasi-threads to wasmtime::error (#12275)
1 parent 189cc0b commit dcdbed1

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/wasi-threads/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ rust-version.workspace = true
1616
workspace = true
1717

1818
[dependencies]
19-
anyhow = { workspace = true }
2019
log = { workspace = true }
2120
rand = "0.8"
2221
wasi-common = { workspace = true, features = ["exit"]}

crates/wasi-threads/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
//!
33
//! [`wasi-threads`]: https://github.com/WebAssembly/wasi-threads
44
5-
use anyhow::{Result, anyhow};
65
use std::panic::{AssertUnwindSafe, catch_unwind};
76
use std::sync::Arc;
87
use std::sync::atomic::{AtomicI32, Ordering};
98
use std::thread;
10-
use wasmtime::{Caller, ExternType, InstancePre, Linker, Module, SharedMemory, Store};
9+
use wasmtime::{
10+
Caller, ExternType, InstancePre, Linker, Module, Result, SharedMemory, Store, format_err,
11+
};
1112

1213
// This name is a function export designated by the wasi-threads specification:
1314
// https://github.com/WebAssembly/wasi-threads/#detailed-design-discussion
@@ -141,7 +142,7 @@ pub fn add_to_linker<T: Clone + Send + 'static>(
141142
store: &wasmtime::Store<T>,
142143
module: &Module,
143144
get_cx: impl Fn(&mut T) -> &WasiThreadsCtx<T> + Send + Sync + Copy + 'static,
144-
) -> anyhow::Result<()> {
145+
) -> wasmtime::Result<()> {
145146
linker.func_wrap(
146147
"wasi",
147148
"thread-spawn",
@@ -170,7 +171,7 @@ pub fn add_to_linker<T: Clone + Send + 'static>(
170171
let mem = SharedMemory::new(module.engine(), m.clone())?;
171172
linker.define(store, import.module(), import.name(), mem.clone())?;
172173
} else {
173-
return Err(anyhow!(
174+
return Err(format_err!(
174175
"memory was not shared; a `wasi-threads` must import \
175176
a shared memory as \"memory\""
176177
));

0 commit comments

Comments
 (0)