A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Migrate the Wasmtime CLI to `wasmtime::error` (#12295)
Nick Fitzgerald94740588d3ba
diff --git a/Cargo.lock b/Cargo.lockindex c852ee9b83..2d7f813f70 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4623,7 +4623,6 @@ dependencies = [name = "wasmtime-cli"version = "42.0.0"dependencies = [- "anyhow","async-trait","bstr","bytes",diff --git a/Cargo.toml b/Cargo.tomlindex cc88ee4189..956c8fcd67 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -62,7 +62,6 @@ wasmtime-unwinder = { workspace = true }wasmtime-wizer = { workspace = true, optional = true, features = ['clap', 'wasmtime'] }clap = { workspace = true }clap_complete = { workspace = true, optional = true }-anyhow = { workspace = true, features = ['std'] }target-lexicon = { workspace = true }listenfd = { version = "1.0.0", optional = true }wat = { workspace = true, optional = true }@@ -139,9 +138,6 @@ windows-sys = { workspace = true, features = ["Win32_System_Memory"] }[target.'cfg(unix)'.dev-dependencies]rustix = { workspace = true, features = ["param"] }-[build-dependencies]-anyhow = { workspace = true, features = ['std'] }-[profile.release.build-override]opt-level = 0diff --git a/benches/instantiation.rs b/benches/instantiation.rsindex 836923816d..324e966749 100644--- a/benches/instantiation.rs+++ b/benches/instantiation.rs@@ -1,4 +1,3 @@-use anyhow::Result;use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};use std::cell::LazyCell;use std::path::Path;diff --git a/benches/trap.rs b/benches/trap.rsindex a006c871b9..3eb0f793de 100644--- a/benches/trap.rs+++ b/benches/trap.rs@@ -1,4 +1,3 @@-use anyhow::Result;use criterion::*;use wasmtime::*;diff --git a/examples/component/main.rs b/examples/component/main.rsindex eabdbafe7d..6ffa44da1d 100644--- a/examples/component/main.rs+++ b/examples/component/main.rs@@ -1,9 +1,8 @@-use anyhow::Context;use std::{fs, path::Path};-use wasmtime::{Config, Engine, Result, Store,component::{Component, HasSelf, Linker, bindgen},+ error::Context as _,};// Generate bindings of the guest and host components.diff --git a/examples/epochs.rs b/examples/epochs.rsindex 47d72d7b3c..a0ef024bfb 100644--- a/examples/epochs.rs+++ b/examples/epochs.rs@@ -3,8 +3,8 @@//! an example of setup for asynchronous usage, see//! `tests/all/epoch_interruption.rs`-use anyhow::Error;use std::sync::Arc;+use wasmtime::Error;use wasmtime::{Config, Engine, Instance, Module, Store};fn main() -> Result<(), Error> {diff --git a/examples/fast_instantiation.rs b/examples/fast_instantiation.rsindex 0ebf780521..516aea15af 100644--- a/examples/fast_instantiation.rs+++ b/examples/fast_instantiation.rs@@ -1,6 +1,6 @@//! Tuning Wasmtime for fast instantiation.-use anyhow::anyhow;+use wasmtime::format_err;use wasmtime::{Config, Engine, InstanceAllocationStrategy, Linker, Module, PoolingAllocationConfig, Result,Store,@@ -85,7 +85,7 @@ fn main() -> Result<()> {// Wait for the threads to finish.for h in handles.into_iter() {- h.join().map_err(|_| anyhow!("thread panicked!"))??;+ h.join().map_err(|_| format_err!("thread panicked!"))??;}Ok(())diff --git a/examples/memory.rs b/examples/memory.rsindex 59f1f6fd2f..ef187c724f 100644--- a/examples/memory.rs+++ b/examples/memory.rs@@ -18,7 +18,7 @@ fn main() -> Result<()> {// load_fn up our exports from the instancelet memory = instance.get_memory(&mut store, "memory")- .ok_or(anyhow::format_err!("failed to find `memory` export"))?;+ .ok_or(wasmtime::format_err!("failed to find `memory` export"))?;let size = instance.get_typed_func::<(), i32>(&mut store, "size")?;let load_fn = instance.get_typed_func::<i32, i32>(&mut store, "load")?;let store_fn = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store")?;diff --git a/examples/mpk.rs b/examples/mpk.rsindex 7db5ab5b79..249cda4d97 100644--- a/examples/mpk.rs+++ b/examples/mpk.rs@@ -31,11 +31,11 @@//! $ sysctl vm.max_map_count=$LARGER_LIMIT//! ```-use anyhow::anyhow;use bytesize::ByteSize;use clap::Parser;use log::{info, warn};use std::str::FromStr;+use wasmtime::format_err;use wasmtime::*;fn main() -> Result<()> {@@ -84,7 +84,7 @@ struct Args {/// Parse a human-readable byte size--e.g., "512 MiB"--into the correct number/// of bytes.fn parse_byte_size(value: &str) -> Result<u64> {- let size = ByteSize::from_str(value).map_err(|e| anyhow!(e))?;+ let size = ByteSize::from_str(value).map_err(|e| format_err!(e))?;Ok(size.as_u64())}@@ -239,15 +239,15 @@ fn num_bytes_mapped() -> Result<usize> {let range = line.split_whitespace().next()- .ok_or(anyhow!("parse failure: expected whitespace"))?;+ .ok_or(format_err!("parse failure: expected whitespace"))?;let mut addresses = range.split("-");- let start = addresses- .next()- .ok_or(anyhow!("parse failure: expected dash-separated address"))?;+ let start = addresses.next().ok_or(format_err!(+ "parse failure: expected dash-separated address"+ ))?;let start = usize::from_str_radix(start, 16)?;- let end = addresses- .next()- .ok_or(anyhow!("parse failure: expected dash-separated address"))?;+ let end = addresses.next().ok_or(format_err!(+ "parse failure: expected dash-separated address"+ ))?;let end = usize::from_str_radix(end, 16)?;total += end - start;@@ -257,5 +257,5 @@ fn num_bytes_mapped() -> Result<usize> {#[cfg(not(target_os = "linux"))]fn num_bytes_mapped() -> Result<usize> {- anyhow::bail!("this example can only read virtual memory maps on Linux")+ wasmtime::bail!("this example can only read virtual memory maps on Linux")}diff --git a/examples/multi.rs b/examples/multi.rsindex 57ec84c9f5..1dbe7765bc 100644--- a/examples/multi.rs+++ b/examples/multi.rs@@ -7,7 +7,7 @@// You can execute this example with `cargo run --example multi`-use anyhow::Result;+use wasmtime::Result;fn main() -> Result<()> {use wasmtime::*;diff --git a/examples/multimemory.rs b/examples/multimemory.rsindex 7964c8c445..a8763792aa 100644--- a/examples/multimemory.rs+++ b/examples/multimemory.rs@@ -23,14 +23,14 @@ fn main() -> Result<()> {let memory0 = instance.get_memory(&mut store, "memory0")- .ok_or(anyhow::format_err!("failed to find `memory0` export"))?;+ .ok_or(wasmtime::format_err!("failed to find `memory0` export"))?;let size0 = instance.get_typed_func::<(), i32>(&mut store, "size0")?;let load0 = instance.get_typed_func::<i32, i32>(&mut store, "load0")?;let store0 = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store0")?;let memory1 = instance.get_memory(&mut store, "memory1")- .ok_or(anyhow::format_err!("failed to find `memory1` export"))?;+ .ok_or(wasmtime::format_err!("failed to find `memory1` export"))?;let size1 = instance.get_typed_func::<(), i32>(&mut store, "size1")?;let load1 = instance.get_typed_func::<i32, i32>(&mut store, "load1")?;let store1 = instance.get_typed_func::<(i32, i32), ()>(&mut store, "store1")?;diff --git a/examples/tokio/main.rs b/examples/tokio/main.rsindex fa36624c84..91866d3afa 100644--- a/examples/tokio/main.rs+++ b/examples/tokio/main.rs@@ -1,6 +1,6 @@-use anyhow::Error;use std::sync::Arc;use tokio::time::Duration;+use wasmtime::Error;use wasmtime::{Config, Engine, Linker, Module, Store};use wasmtime_wasi::{WasiCtx, p1::WasiP1Ctx};diff --git a/examples/wasip1-async/main.rs b/examples/wasip1-async/main.rsindex 4be30ec1c2..516379f6e4 100644--- a/examples/wasip1-async/main.rs+++ b/examples/wasip1-async/main.rs@@ -7,7 +7,7 @@ You can execute this example with:cargo run --example wasip1-async*/-use anyhow::Result;+use wasmtime::Result;use wasmtime::{Config, Engine, Linker, Module, Store};use wasmtime_wasi::WasiCtx;use wasmtime_wasi::p1::{self, WasiP1Ctx};diff --git a/examples/wasip2/main.rs b/examples/wasip2/main.rsindex 06739b0103..878e31c8f7 100644--- a/examples/wasip2/main.rs+++ b/examples/wasip2/main.rs@@ -83,5 +83,5 @@ fn main() -> Result<()> {let (result,) = typed.call(&mut store, ())?;// Required, see documentation of TypedFunc::calltyped.post_return(&mut store)?;- result.map_err(|_| anyhow::anyhow!("error"))+ result.map_err(|_| wasmtime::format_err!("error"))}diff --git a/src/bin/wasmtime.rs b/src/bin/wasmtime.rsindex 40e3443140..fa501a72cf 100644--- a/src/bin/wasmtime.rs+++ b/src/bin/wasmtime.rs@@ -3,8 +3,8 @@//! Primarily used to run WebAssembly modules.//! See `wasmtime --help` for usage.-use anyhow::Result;use clap::Parser;+use wasmtime::Result;/// Wasmtime WebAssembly Runtime#[derive(Parser)]diff --git a/src/commands/compile.rs b/src/commands/compile.rsindex 8599006373..c6c1ad0f03 100644--- a/src/commands/compile.rs+++ b/src/commands/compile.rs@@ -1,10 +1,9 @@//! The module that implements the `wasmtime compile` command.-use anyhow::{Context, Result, bail};use clap::Parser;use std::fs;use std::path::PathBuf;-use wasmtime::{CodeBuilder, CodeHint, Engine};+use wasmtime::{CodeBuilder, CodeHint, Engine, Result, bail, error::Context as _};use wasmtime_cli_flags::CommonOptions;const AFTER_HELP: &str =diff --git a/src/commands/config.rs b/src/commands/config.rsindex d53b8f9a12..538d94a93f 100644--- a/src/commands/config.rs+++ b/src/commands/config.rs@@ -1,7 +1,7 @@//! The module that implements the `wasmtime config` command.-use anyhow::Result;use clap::{Parser, Subcommand};+use wasmtime::Result;const CONFIG_NEW_AFTER_HELP: &str ="If no file path is specified, the system configuration file path will be used.";diff --git a/src/commands/explore.rs b/src/commands/explore.rsindex f0cf2f155e..29aaf73dca 100644--- a/src/commands/explore.rs+++ b/src/commands/explore.rs@@ -1,10 +1,9 @@//! The module that implements the `wasmtime explore` command.-use anyhow::{Context, Result};use clap::Parser;use std::{borrow::Cow, path::PathBuf};use tempfile::tempdir;-use wasmtime::Strategy;+use wasmtime::{Result, Strategy, error::Context as _};use wasmtime_cli_flags::CommonOptions;/// Explore the compilation of a WebAssembly module to native code.diff --git a/src/commands/objdump.rs b/src/commands/objdump.rsindex b439cb2da5..f85e513340 100644--- a/src/commands/objdump.rs+++ b/src/commands/objdump.rs@@ -1,6 +1,5 @@//! Implementation of the `wasmtime objdump` CLI command.-use anyhow::{Context, Result, bail};use capstone::InsnGroupType::{CS_GRP_JUMP, CS_GRP_RET};use clap::Parser;use cranelift_codegen::isa::lookup_by_name;@@ -14,7 +13,7 @@ use std::io::{IsTerminal, Read, Write};use std::iter::{self, Peekable};use std::path::{Path, PathBuf};use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};-use wasmtime::Engine;+use wasmtime::{Engine, Result, bail, error::Context as _};use wasmtime_environ::{FilePos, FrameInstPos, FrameStackShape, FrameStateSlot, FrameTable, FrameTableDescriptorIndex,StackMap, Trap, obj,diff --git a/src/commands/run.rs b/src/commands/run.rsindex 13989e76ea..377a34e47c 100644--- a/src/commands/run.rs+++ b/src/commands/run.rs@@ -6,14 +6,16 @@)]use crate::common::{Profile, RunCommon, RunTarget};-use anyhow::{Context as _, Error, Result, anyhow, bail};use clap::Parser;use std::ffi::OsString;use std::path::{Path, PathBuf};use std::sync::{Arc, Mutex};use std::thread;use wasi_common::sync::{Dir, TcpListener, WasiCtxBuilder, ambient_authority};-use wasmtime::{Engine, Func, Module, Store, StoreLimits, Val, ValType};+use wasmtime::{+ Engine, Error, Func, Module, Result, Store, StoreLimits, Val, ValType, bail,+ error::Context as _, format_err,+};use wasmtime_wasi::{WasiCtxView, WasiView};#[cfg(feature = "wasi-config")]@@ -284,7 +286,7 @@ impl RunCommand {// Load the main wasm module.let instance = match result.unwrap_or_else(|elapsed| {- Err(anyhow::Error::from(wasmtime::Trap::Interrupt))+ Err(wasmtime::Error::from(wasmtime::Trap::Interrupt)).with_context(|| format!("timed out after {elapsed}"))}) {Ok(instance) => instance,@@ -333,7 +335,7 @@ impl RunCommand {};result.push(arg.to_str()- .ok_or_else(|| anyhow!("failed to convert {arg:?} to utf-8"))?+ .ok_or_else(|| format_err!("failed to convert {arg:?} to utf-8"))?.to_string(),);}@@ -456,7 +458,7 @@ impl RunCommand {let profiler = Arc::try_unwrap(store.data_mut().guest_profiler.take().unwrap()).expect("profiling doesn't support threads yet");if let Err(e) = std::fs::File::create(&path)- .map_err(anyhow::Error::new)+ .map_err(wasmtime::Error::new).and_then(|output| profiler.finish(std::io::BufWriter::new(output))){eprintln!("failed writing profile at {path}: {e:#}");@@ -530,7 +532,7 @@ impl RunCommand {Some(instance.get_func(&mut *store, name)- .ok_or_else(|| anyhow!("no func export named `{name}` found"))?,+ .ok_or_else(|| format_err!("no func export named `{name}` found"))?,)} else {instance@@ -623,7 +625,7 @@ impl RunCommand {.run_concurrent(async |store| {let task = func.call_concurrent(store, ¶ms, &mut results).await?;task.block(store).await;- anyhow::Ok(())+ wasmtime::error::Ok(())}).await??;}@@ -758,7 +760,7 @@ impl RunCommand {};let val = val.to_str()- .ok_or_else(|| anyhow!("argument is not valid utf-8: {val:?}"))?;+ .ok_or_else(|| format_err!("argument is not valid utf-8: {val:?}"))?;values.push(match ty {// Supports both decimal and hexadecimal notation (with 0x prefix)ValType::I32 => Val::I32(if val.starts_with("0x") || val.starts_with("0X") {@@ -1106,7 +1108,7 @@ impl RunCommand {None => match std::env::var_os(key) {Some(val) => val.into_string()- .map_err(|_| anyhow!("environment variable `{key}` not valid utf-8"))?,+ .map_err(|_| format_err!("environment variable `{key}` not valid utf-8"))?,None => {// leave the env var un-set in the guestcontinue;@@ -1311,7 +1313,7 @@ fn ctx_set_listenfd(mut num_fd: usize, builder: &mut WasiCtxBuilder) -> Result<u#[cfg(feature = "coredump")]fn write_core_dump(store: &mut Store<Host>,- err: &anyhow::Error,+ err: &wasmtime::Error,name: &str,path: &str,) -> Result<()> {diff --git a/src/commands/serve.rs b/src/commands/serve.rsindex e97a1769ad..7510efbe3a 100644--- a/src/commands/serve.rs+++ b/src/commands/serve.rs@@ -1,5 +1,4 @@use crate::common::{Profile, RunCommon, RunTarget};-use anyhow::{Context as _, Result, bail};use bytes::Bytes;use clap::Parser;use futures::future::FutureExt;@@ -21,7 +20,9 @@ use std::{use tokio::io::{self, AsyncWrite};use tokio::sync::Notify;use wasmtime::component::{Component, Linker, ResourceTable};-use wasmtime::{Engine, Store, StoreContextMut, StoreLimits, UpdateDeadline};+use wasmtime::{+ Engine, Result, Store, StoreContextMut, StoreLimits, UpdateDeadline, bail, error::Context as _,+};use wasmtime_cli_flags::opt::WasmtimeOptionValue;use wasmtime_wasi::p2::{StreamError, StreamResult};use wasmtime_wasi::{WasiCtx, WasiCtxBuilder, WasiCtxView, WasiView};@@ -639,7 +640,7 @@ impl HandlerState for HostHandlerState {self.max_instance_concurrent_reuse_count}- fn handle_worker_error(&self, error: anyhow::Error) {+ fn handle_worker_error(&self, error: wasmtime::Error) {eprintln!("worker error: {error}");}}@@ -808,7 +809,7 @@ fn setup_guest_profiler(let profiler = Arc::try_unwrap(store.data_mut().guest_profiler.take().unwrap()).expect("profiling doesn't support threads yet");if let Err(e) = std::fs::File::create(&path)- .map_err(anyhow::Error::new)+ .map_err(wasmtime::Error::new).and_then(|output| profiler.finish(std::io::BufWriter::new(output))){eprintln!("failed writing profile at {path}: {e:#}");@@ -827,7 +828,7 @@ type Request = hyper::Request<hyper::body::Incoming>;async fn handle_request(handler: ProxyHandler<HostHandlerState>,req: Request,-) -> Result<hyper::Response<UnsyncBoxBody<Bytes, anyhow::Error>>> {+) -> Result<hyper::Response<UnsyncBoxBody<Bytes, wasmtime::Error>>> {use tokio::sync::oneshot;let req_id = handler.next_req_id();@@ -842,13 +843,13 @@ async fn handle_request(// `WasiHttpView::new_response_outparam` expects a specific kind of sender// that uses `p2::http::types::ErrorCode`, and we don't want to have to// convert from the p3 `ErrorCode` to the p2 one, only to convert again to- // `anyhow::Error`.+ // `wasmtime::Error`.type P2Response = Result<hyper::Response<wasmtime_wasi_http::body::HyperOutgoingBody>,p2::http::types::ErrorCode,>;- type P3Response = hyper::Response<UnsyncBoxBody<Bytes, anyhow::Error>>;+ type P3Response = hyper::Response<UnsyncBoxBody<Bytes, wasmtime::Error>>;enum Sender {P2(oneshot::Sender<P2Response>),@@ -888,7 +889,7 @@ async fn handle_request(.data_mut().new_incoming_request(p2::http::types::Scheme::Http, req)?;let out = store.data_mut().new_response_outparam(tx)?;- anyhow::Ok((req, out))+ wasmtime::error::Ok((req, out))})?;proxy@@ -930,7 +931,7 @@ async fn handle_request(Receiver::P2(rx) => rx.await.context("guest never invoked `response-outparam::set` method")?- .map_err(|e| anyhow::Error::from(e))?+ .map_err(|e| wasmtime::Error::from(e))?.map(|body| body.map_err(|e| e.into()).boxed_unsync()),Receiver::P3(rx) => rx.await?,})diff --git a/src/commands/settings.rs b/src/commands/settings.rsindex 1cb7d3c996..56ba7d1b2f 100644--- a/src/commands/settings.rs+++ b/src/commands/settings.rs@@ -1,10 +1,10 @@//! The module that implements the `wasmtime settings` command.-use anyhow::{Result, anyhow};use clap::Parser;use serde::{Serialize, ser::SerializeMap};use std::collections::BTreeMap;use std::str::FromStr;+use wasmtime::{Result, format_err};use wasmtime_environ::{CompilerBuilder, FlagValue, Setting, SettingKind, Tunables};/// Displays available Cranelift settings for a target.@@ -109,7 +109,7 @@ impl SettingsCommand {// Gather settings from the cranelift compiler builderlet mut builder = wasmtime_cranelift::builder(None)?;let tunables = if let Some(target) = &self.target {- let target = target_lexicon::Triple::from_str(target).map_err(|e| anyhow!(e))?;+ let target = target_lexicon::Triple::from_str(target).map_err(|e| format_err!(e))?;let tunables = Tunables::default_for_target(&target)?;builder.target(target)?;tunablesdiff --git a/src/commands/wast.rs b/src/commands/wast.rsindex 00329ce9d5..4f60a47eab 100644--- a/src/commands/wast.rs+++ b/src/commands/wast.rs@@ -1,9 +1,8 @@//! The module that implements the `wasmtime wast` command.-use anyhow::{Context as _, Result};use clap::Parser;use std::path::PathBuf;-use wasmtime::Engine;+use wasmtime::{Engine, Result, error::Context as _};use wasmtime_cli_flags::CommonOptions;use wasmtime_wast::{SpectestConfig, WastContext};diff --git a/src/commands/wizer.rs b/src/commands/wizer.rsindex 0664ee314b..4fa36eae54 100644--- a/src/commands/wizer.rs+++ b/src/commands/wizer.rs@@ -1,10 +1,9 @@use crate::commands::run::{CliInstance, Preloads, RunCommand};use crate::common::{RunCommon, RunTarget};-use anyhow::{Context, Result};use std::fs;use std::io::{self, Read, Write};use std::path::PathBuf;-use wasmtime::Module;+use wasmtime::{Module, Result, error::Context as _};use wasmtime_wizer::Wizer;#[derive(clap::Parser)]diff --git a/src/common.rs b/src/common.rsindex 6975caf4c2..6f51c0f3e6 100644--- a/src/common.rs+++ b/src/common.rs@@ -1,10 +1,12 @@//! Common functionality shared between command implementations.-use anyhow::{Context, Result, anyhow, bail};use clap::Parser;use std::net::TcpListener;use std::{fs::File, path::Path, time::Duration};-use wasmtime::{Engine, Module, Precompiled, StoreLimits, StoreLimitsBuilder};+use wasmtime::{+ Engine, Module, Precompiled, Result, StoreLimits, StoreLimitsBuilder, bail,+ error::Context as _, format_err,+};use wasmtime_cli_flags::{CommonOptions, opt::WasmtimeOptionValue};use wasmtime_wasi::WasiCtxBuilder;@@ -285,7 +287,7 @@ impl RunCommon {None => match std::env::var_os(key) {Some(val) => val.into_string()- .map_err(|_| anyhow!("environment variable `{key}` not valid utf-8"))?,+ .map_err(|_| format_err!("environment variable `{key}` not valid utf-8"))?,None => {// leave the env var un-set in the guestcontinue;diff --git a/tests/all/async_functions.rs b/tests/all/async_functions.rsindex 06a657fd1e..9f5c836a19 100644--- a/tests/all/async_functions.rs+++ b/tests/all/async_functions.rs@@ -1,4 +1,3 @@-use anyhow::{anyhow, bail};use std::future::Future;use std::pin::Pin;use std::sync::{Arc, Mutex};@@ -516,7 +515,7 @@ async fn resume_separate_thread() {let func = Func::wrap_async(&mut store, |_, _: ()| {Box::new(async {tokio::task::yield_now().await;- Err::<(), _>(anyhow!("test"))+ Err::<(), _>(format_err!("test"))})});let result = Instance::new_async(&mut store, &module, &[func.into()]).await;@@ -879,7 +878,7 @@ async fn non_stacky_async_activations() -> Result<()> {.await?;capture_stack(&stacks, &store2);- anyhow::Ok(())+ wasmtime::error::Ok(())}}) as _).awaitdiff --git a/tests/all/call_hook.rs b/tests/all/call_hook.rsindex 5626cea609..c2ddb23275 100644--- a/tests/all/call_hook.rs+++ b/tests/all/call_hook.rs@@ -1,9 +1,9 @@#![cfg(not(miri))]-use anyhow::bail;use std::future::Future;use std::pin::Pin;use std::task::{self, Poll};+use wasmtime::bail;use wasmtime::*;// Crate a synchronous Func, call it directly:diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rsindex 79d76cd38a..81e65a4ef7 100644--- a/tests/all/cli_tests.rs+++ b/tests/all/cli_tests.rs@@ -1,11 +1,11 @@#![cfg(not(miri))]-use anyhow::{Result, bail};use std::fs::File;use std::io::Write;use std::path::Path;use std::process::{Command, ExitStatus, Output, Stdio};use tempfile::{NamedTempFile, TempDir};+use wasmtime::{Result, bail};// Run the wasmtime CLI with the provided args and return the `Output`.// If the `stdin` is `Some`, opens the file and redirects to the child's stdin.@@ -448,7 +448,7 @@ fn hello_wasi_snapshot0_from_stdin() -> Result<()> {String::from_utf8_lossy(&output.stderr));}- Ok::<_, anyhow::Error>(String::from_utf8(output.stdout).unwrap())+ Ok::<_, wasmtime::Error>(String::from_utf8(output.stdout).unwrap())}?;assert_eq!(stdout, "Hello, world!\n");}@@ -1104,7 +1104,6 @@ fn increase_stack_size() -> Result<()> {mod test_programs {use super::{get_wasmtime_command, run_wasmtime};- use anyhow::{Context, Result, bail};use http_body_util::BodyExt;use hyper::header::HeaderValue;use std::io::{self, BufRead, BufReader, Read, Write};@@ -1114,6 +1113,7 @@ mod test_programs {use std::thread::{self, JoinHandle};use test_programs_artifacts::*;use tokio::net::TcpStream;+ use wasmtime::{Result, bail, error::Context as _};macro_rules! assert_test_exists {($name:ident) => {@@ -2410,7 +2410,7 @@ start a print 1234conn_task.await??;- anyhow::Ok(())+ wasmtime::error::Ok(())}})}@@ -2506,7 +2506,7 @@ start a print 1234conn_task.await??;- anyhow::Ok(())+ wasmtime::error::Ok(())}})}diff --git a/tests/all/component_model.rs b/tests/all/component_model.rsindex 87d85aaf01..4761f50c19 100644--- a/tests/all/component_model.rs+++ b/tests/all/component_model.rs@@ -1,6 +1,6 @@-use anyhow::Result;use std::fmt::Write;use std::iter;+use wasmtime::Result;use wasmtime::component::Component;use wasmtime_component_util::REALLOC_AND_FREE;use wasmtime_test_util::component::{TypedFuncExt, async_engine, engine};diff --git a/tests/all/component_model/aot.rs b/tests/all/component_model/aot.rsindex d94dc1380a..43db793943 100644--- a/tests/all/component_model/aot.rs+++ b/tests/all/component_model/aot.rs@@ -1,4 +1,4 @@-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::types::ComponentItem;use wasmtime::component::{Component, Linker, Type};use wasmtime::{Engine, Module, Precompiled, Store};diff --git a/tests/all/component_model/async.rs b/tests/all/component_model/async.rsindex 075938e429..766038b840 100644--- a/tests/all/component_model/async.rs+++ b/tests/all/component_model/async.rs@@ -1,7 +1,7 @@use crate::async_functions::{PollOnce, execute_across_threads};-use anyhow::Result;use std::pin::Pin;use std::task::{Context, Poll};+use wasmtime::Result;use wasmtime::{AsContextMut, Config, component::*};use wasmtime::{Engine, Store, StoreContextMut, Trap};use wasmtime_component_util::REALLOC_AND_FREE;@@ -161,7 +161,7 @@ async fn resume_separate_thread() -> Result<()> {store.set_fuel(u64::MAX).unwrap();store.fuel_async_yield_interval(Some(1)).unwrap();linker.instantiate_async(&mut store, &component).await?;- Ok::<_, anyhow::Error>(())+ Ok::<_, wasmtime::Error>(())}).await?;Ok(())@@ -217,7 +217,7 @@ async fn poll_through_wasm_activation() -> Result<()> {let instance = linker.instantiate_async(&mut store, &component).await?;let func = instance.get_typed_func::<(Vec<u8>,), ()>(&mut store, "run")?;func.call_async(&mut store, (vec![1, 2, 3],)).await?;- Ok::<_, anyhow::Error>(())+ Ok::<_, wasmtime::Error>(())}};@@ -242,7 +242,7 @@ async fn poll_through_wasm_activation() -> Result<()> {while poll_once.call_async(&mut store, ()).await? != 1 {// loop around to call again}- Ok::<_, anyhow::Error>(())+ Ok::<_, wasmtime::Error>(())}).await?;Ok(())@@ -308,7 +308,7 @@ async fn drop_resource_async() -> Result<()> {let resource = Resource::new_own(100);f.call_async(&mut store, (resource,)).await?;f.post_return_async(&mut store).await?;- Ok::<_, anyhow::Error>(())+ Ok::<_, wasmtime::Error>(())}).await?;diff --git a/tests/all/component_model/async_dynamic.rs b/tests/all/component_model/async_dynamic.rsindex 34713255d1..d761342abc 100644--- a/tests/all/component_model/async_dynamic.rs+++ b/tests/all/component_model/async_dynamic.rs@@ -6,7 +6,7 @@ fn simple_type_conversions() {let engine = Engine::default();let mut store = Store::new(&engine, ());- let f = FutureReader::new(&mut store, async { anyhow::Ok(10_u32) });+ let f = FutureReader::new(&mut store, async { wasmtime::error::Ok(10_u32) });let f = f.try_into_future_any(&mut store).unwrap();assert!(f.clone().try_into_future_reader::<()>().is_err());assert!(f.clone().try_into_future_reader::<u64>().is_err());@@ -143,7 +143,7 @@ fn simple_type_assertions() -> Result<()> {Ok(())};- let f = FutureReader::new(&mut store, async { anyhow::Ok(10_u32) });+ let f = FutureReader::new(&mut store, async { wasmtime::error::Ok(10_u32) });roundtrip(&mut store, f)?;let (f,) = mk_f_t.call(&mut store, ())?;diff --git a/tests/all/component_model/bindgen.rs b/tests/all/component_model/bindgen.rsindex b49a4f9591..bef8840eb4 100644--- a/tests/all/component_model/bindgen.rs+++ b/tests/all/component_model/bindgen.rs@@ -1,7 +1,7 @@#![cfg(not(miri))]use super::engine;-use anyhow::Result;+use wasmtime::Result;use wasmtime::{Config, Engine, Store,component::{Component, Linker},diff --git a/tests/all/component_model/bindgen/ownership.rs b/tests/all/component_model/bindgen/ownership.rsindex df1df46d7d..e3f9f2cfd0 100644--- a/tests/all/component_model/bindgen/ownership.rs+++ b/tests/all/component_model/bindgen/ownership.rs@@ -1,5 +1,5 @@use super::{super::REALLOC_AND_FREE, engine};-use anyhow::Result;+use wasmtime::Result;use wasmtime::{Store,component::{Component, Linker},diff --git a/tests/all/component_model/bindgen/results.rs b/tests/all/component_model/bindgen/results.rsindex 2ad46d7a4a..9252e4e005 100644--- a/tests/all/component_model/bindgen/results.rs+++ b/tests/all/component_model/bindgen/results.rs@@ -1,8 +1,8 @@use super::{super::REALLOC_AND_FREE, engine};-use anyhow::{Error, anyhow};use wasmtime::{- Store,+ Error, Store,component::{Component, Linker},+ format_err,};mod empty_error {@@ -71,7 +71,7 @@ mod empty_error {} else if a == 1.0 {Ok(Err(()))} else {- Err(anyhow!("empty_error: trap"))+ Err(format_err!("empty_error: trap"))}}}@@ -186,7 +186,7 @@ mod string_error {} else if a == 1.0 {Ok(Err("string_error: error".to_owned()))} else {- Err(anyhow!("string_error: trap"))+ Err(format_err!("string_error: trap"))}}}@@ -350,7 +350,7 @@ mod enum_error {struct MyImports {}impl imports::Host for MyImports {- fn convert_e1(&mut self, err: TrappableE1) -> anyhow::Result<imports::E1> {+ fn convert_e1(&mut self, err: TrappableE1) -> wasmtime::Result<imports::E1> {match err {TrappableE1::Normal(e) => Ok(e),TrappableE1::MyTrap(e) => Err(e.into()),@@ -433,7 +433,7 @@ mod record_error {pub enum TrappableE2 {Normal(imports::E2),- Trap(anyhow::Error),+ Trap(wasmtime::Error),}impl From<imports::E2> for TrappableE2 {@@ -513,7 +513,7 @@ mod record_error {struct MyImports {}impl imports::Host for MyImports {- fn convert_e2(&mut self, err: TrappableE2) -> anyhow::Result<imports::E2> {+ fn convert_e2(&mut self, err: TrappableE2) -> wasmtime::Result<imports::E2> {match err {TrappableE2::Normal(e) => Ok(e),TrappableE2::Trap(e) => Err(e),@@ -528,7 +528,7 @@ mod record_error {col: 1312,})?} else {- Err(TrappableE2::Trap(anyhow!("record_error: trap")))+ Err(TrappableE2::Trap(format_err!("record_error: trap")))}}}@@ -606,7 +606,7 @@ mod variant_error {pub enum TrappableE3 {Normal(imports::E3),- Trap(anyhow::Error),+ Trap(wasmtime::Error),}impl From<imports::E3> for TrappableE3 {@@ -709,7 +709,7 @@ mod variant_error {struct MyImports {}impl imports::Host for MyImports {- fn convert_e3(&mut self, err: TrappableE3) -> anyhow::Result<imports::E3> {+ fn convert_e3(&mut self, err: TrappableE3) -> wasmtime::Result<imports::E3> {match err {TrappableE3::Normal(e) => Ok(e),TrappableE3::Trap(e) => Err(e),@@ -724,7 +724,7 @@ mod variant_error {col: 1312,}))?} else {- Err(TrappableE3::Trap(anyhow!("variant_error: trap")))+ Err(TrappableE3::Trap(format_err!("variant_error: trap")))}}}@@ -803,7 +803,7 @@ mod multiple_interfaces_error {pub enum TrappableE1 {Normal(types::E1),- Trap(anyhow::Error),+ Trap(wasmtime::Error),}impl From<types::E1> for TrappableE1 {@@ -896,7 +896,7 @@ mod multiple_interfaces_error {// their throw site.impl From<MyTrap> for TrappableE1 {fn from(t: MyTrap) -> TrappableE1 {- TrappableE1::Trap(anyhow!(t))+ TrappableE1::Trap(format_err!(t))}}@@ -904,7 +904,7 @@ mod multiple_interfaces_error {struct MyImports {}impl types::Host for MyImports {- fn convert_e1(&mut self, err: TrappableE1) -> anyhow::Result<imports::E1> {+ fn convert_e1(&mut self, err: TrappableE1) -> wasmtime::Result<imports::E1> {match err {TrappableE1::Normal(e) => Ok(e),TrappableE1::Trap(e) => Err(e),@@ -1051,7 +1051,7 @@ mod with_remapping {} else if a == 1.0 {Ok(Err(()))} else {- Err(anyhow!("empty_error: trap"))+ Err(format_err!("empty_error: trap"))}}}diff --git a/tests/all/component_model/call_hook.rs b/tests/all/component_model/call_hook.rsindex b6593dad00..d71fe42159 100644--- a/tests/all/component_model/call_hook.rs+++ b/tests/all/component_model/call_hook.rs@@ -2,12 +2,11 @@use super::REALLOC_AND_FREE;use crate::call_hook::{Context, State, sync_call_hook};-use anyhow::{Result, bail};use std::future::Future;use std::pin::Pin;use std::task::{self, Poll};use wasmtime::component::*;-use wasmtime::{CallHook, CallHookHandler, Config, Engine, Store, StoreContextMut};+use wasmtime::{CallHook, CallHookHandler, Config, Engine, Result, Store, StoreContextMut, bail};// Crate a synchronous Func, call it directly:#[test]@@ -320,7 +319,7 @@ fn trapping() -> Result<()> {let component = Component::new(&engine, wat)?;- let run = |action: i32, again: bool| -> (State, Option<anyhow::Error>) {+ let run = |action: i32, again: bool| -> (State, Option<wasmtime::Error>) {let mut store = Store::new(&engine, State::default());store.call_hook(sync_call_hook);let inst = linkerdiff --git a/tests/all/component_model/dynamic.rs b/tests/all/component_model/dynamic.rsindex 8ca9cd273c..17be5371f9 100644--- a/tests/all/component_model/dynamic.rs+++ b/tests/all/component_model/dynamic.rs@@ -1,7 +1,7 @@#![cfg(not(miri))]use super::{Param, Type, make_echo_component, make_echo_component_with_params};-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::types::{self, Case, ComponentItem, Field};use wasmtime::component::{Component, Linker, ResourceType, Val};use wasmtime::{Module, Store};diff --git a/tests/all/component_model/func.rs b/tests/all/component_model/func.rsindex 3e3d6f964e..d0e8dc924f 100644--- a/tests/all/component_model/func.rs+++ b/tests/all/component_model/func.rs@@ -1,8 +1,8 @@#![cfg(not(miri))]use super::{REALLOC_AND_FREE, TypedFuncExt};-use anyhow::Result;use std::sync::Arc;+use wasmtime::Result;use wasmtime::component::*;use wasmtime::{Config, Engine, Store, StoreContextMut, Trap};@@ -924,7 +924,7 @@ async fn async_reentrance() -> Result<()> {let message = "cannot enter component instance";match store.run_concurrent(async move |accessor| {- anyhow::Ok(func.call_concurrent(accessor, (42,)).await?.0)+ wasmtime::error::Ok(func.call_concurrent(accessor, (42,)).await?.0)}).await{@@ -1137,7 +1137,7 @@ async fn task_return_trap(component: &str, substring: &str) -> Result<()> {let func = instance.get_typed_func::<(), ()>(&mut store, "foo")?;match store.run_concurrent(async move |accessor| {- anyhow::Ok(func.call_concurrent(accessor, ()).await?.0)+ wasmtime::error::Ok(func.call_concurrent(accessor, ()).await?.0)}).await{@@ -1337,7 +1337,7 @@ async fn test_many_parameters(dynamic: bool, concurrent: bool) -> Result<()> {store.run_concurrent(async |store| {func.call_concurrent(store, &input, &mut results).await?;- anyhow::Ok(())+ wasmtime::error::Ok(())}).await??;} else {@@ -1381,7 +1381,7 @@ async fn test_many_parameters(dynamic: bool, concurrent: bool) -> Result<()> {if concurrent {store.run_concurrent(async move |accessor| {- anyhow::Ok(func.call_concurrent(accessor, input).await?.0)+ wasmtime::error::Ok(func.call_concurrent(accessor, input).await?.0)}).await??.0@@ -1771,7 +1771,7 @@ async fn test_many_results(dynamic: bool, concurrent: bool) -> Result<()> {store.run_concurrent(async |store| {func.call_concurrent(store, &[], &mut results).await?;- anyhow::Ok(())+ wasmtime::error::Ok(())}).await??;} else {@@ -1860,7 +1860,7 @@ async fn test_many_results(dynamic: bool, concurrent: bool) -> Result<()> {if concurrent {store.run_concurrent(async move |accessor| {- anyhow::Ok(func.call_concurrent(accessor, ()).await?.0)+ wasmtime::error::Ok(func.call_concurrent(accessor, ()).await?.0)}).await??.0@@ -2029,7 +2029,7 @@ fn some_traps() -> Result<()> {// FIXME(WebAssembly/component-model#32) confirm the semantics here are// what's desired.#[track_caller]- fn assert_oob(err: &anyhow::Error) {+ fn assert_oob(err: &wasmtime::Error) {assert!(err.to_string().contains("realloc return: beyond end of memory"),diff --git a/tests/all/component_model/import.rs b/tests/all/component_model/import.rsindex 6a65dc3a63..3ab9c50d81 100644--- a/tests/all/component_model/import.rs+++ b/tests/all/component_model/import.rs@@ -1,8 +1,8 @@#![cfg(not(miri))]use super::REALLOC_AND_FREE;-use anyhow::Result;use std::ops::Deref;+use wasmtime::Result;use wasmtime::component::*;use wasmtime::{Config, Engine, Store, StoreContextMut, Trap, WasmBacktrace};@@ -837,7 +837,7 @@ async fn test_stack_and_heap_args_and_rets(concurrent: bool) -> Result<()> {if concurrent {store.run_concurrent(async move |accessor| {- anyhow::Ok(run.call_concurrent(accessor, ()).await?.0)+ wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?.0)}).await??;} else {@@ -962,7 +962,7 @@ async fn test_stack_and_heap_args_and_rets(concurrent: bool) -> Result<()> {store.run_concurrent(async |store| {run.call_concurrent(store, &[], &mut []).await?;- anyhow::Ok(())+ wasmtime::error::Ok(())}).await??;} else {diff --git a/tests/all/component_model/instance.rs b/tests/all/component_model/instance.rsindex 9e0b960d70..ad7b6d3f23 100644--- a/tests/all/component_model/instance.rs+++ b/tests/all/component_model/instance.rs@@ -1,4 +1,4 @@-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::*;use wasmtime::{Module, Store};diff --git a/tests/all/component_model/linker.rs b/tests/all/component_model/linker.rsindex 537390915f..7564ec52ee 100644--- a/tests/all/component_model/linker.rs+++ b/tests/all/component_model/linker.rs@@ -1,4 +1,4 @@-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::types::ComponentItem;use wasmtime::component::{Component, Linker, ResourceType};use wasmtime::{Engine, Store};diff --git a/tests/all/component_model/macros.rs b/tests/all/component_model/macros.rsindex 0d11298750..c8d790c7ff 100644--- a/tests/all/component_model/macros.rs+++ b/tests/all/component_model/macros.rs@@ -1,7 +1,7 @@#![cfg(not(miri))]use super::{TypedFuncExt, make_echo_component};-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::{Component, ComponentType, Lift, Linker, Lower};use wasmtime::{Engine, Store};use wasmtime_test_macros::{add_variants, flags_test};diff --git a/tests/all/component_model/nested.rs b/tests/all/component_model/nested.rsindex 35349c2e73..2a6cddd9af 100644--- a/tests/all/component_model/nested.rs+++ b/tests/all/component_model/nested.rs@@ -1,7 +1,7 @@#![cfg(not(miri))]use super::REALLOC_AND_FREE;-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::*;use wasmtime::{Module, Store, StoreContextMut};diff --git a/tests/all/component_model/post_return.rs b/tests/all/component_model/post_return.rsindex e8d95a9364..9ae1d30a63 100644--- a/tests/all/component_model/post_return.rs+++ b/tests/all/component_model/post_return.rs@@ -1,6 +1,6 @@#![cfg(not(miri))]-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::*;use wasmtime::{Store, StoreContextMut, Trap};diff --git a/tests/all/component_model/resources.rs b/tests/all/component_model/resources.rsindex 68f3395761..410a35e144 100644--- a/tests/all/component_model/resources.rs+++ b/tests/all/component_model/resources.rs@@ -1,6 +1,6 @@#![cfg(not(miri))]-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::*;use wasmtime::{Store, Trap};diff --git a/tests/all/component_model/strings.rs b/tests/all/component_model/strings.rsindex a33dd960d2..3caabf4325 100644--- a/tests/all/component_model/strings.rs+++ b/tests/all/component_model/strings.rs@@ -1,7 +1,7 @@#![cfg(not(miri))]use super::REALLOC_AND_FREE;-use anyhow::Result;+use wasmtime::Result;use wasmtime::component::{Component, Linker};use wasmtime::{Engine, Store, StoreContextMut, Trap};@@ -524,7 +524,7 @@ fn test_raw_when_encoded(dst: &str,bytes: &[u8],len: u32,-) -> Result<Option<anyhow::Error>> {+) -> Result<Option<wasmtime::Error>> {let component = format!(r#"(componentdiff --git a/tests/all/coredump.rs b/tests/all/coredump.rsindex 86b4da8eed..2e91e1076c 100644--- a/tests/all/coredump.rs+++ b/tests/all/coredump.rs@@ -1,4 +1,4 @@-use anyhow::bail;+use wasmtime::bail;use wasmtime::*;#[test]diff --git a/tests/all/custom_code_memory.rs b/tests/all/custom_code_memory.rsindex 41ac490f6e..0413843c11 100644--- a/tests/all/custom_code_memory.rs+++ b/tests/all/custom_code_memory.rs@@ -11,7 +11,7 @@ mod not_for_windows {page_size()}- fn publish_executable(&self, ptr: *const u8, len: usize) -> anyhow::Result<()> {+ fn publish_executable(&self, ptr: *const u8, len: usize) -> wasmtime::Result<()> {unsafe {mprotect(ptr as *mut _,@@ -22,7 +22,7 @@ mod not_for_windows {Ok(())}- fn unpublish_executable(&self, ptr: *const u8, len: usize) -> anyhow::Result<()> {+ fn unpublish_executable(&self, ptr: *const u8, len: usize) -> wasmtime::Result<()> {unsafe {mprotect(ptr as *mut _,diff --git a/tests/all/debug.rs b/tests/all/debug.rsindex 20407fc78b..318ba1c272 100644--- a/tests/all/debug.rs+++ b/tests/all/debug.rs@@ -18,7 +18,7 @@ fn debugging_does_not_work_with_signal_based_traps() {fn get_module_and_store<C: Fn(&mut Config)>(c: C,wat: &str,-) -> anyhow::Result<(Module, Store<()>)> {+) -> wasmtime::Result<(Module, Store<()>)> {let mut config = Config::default();config.guest_debug(true);config.wasm_exceptions(true);@@ -32,7 +32,7 @@ fn test_stack_values<C: Fn(&mut Config), F: Fn(Caller<'_, ()>) + Send + Sync + 'wat: &str,c: C,f: F,-) -> anyhow::Result<()> {+) -> wasmtime::Result<()> {let (module, mut store) = get_module_and_store(c, wat)?;let func = Func::wrap(&mut store, move |caller: Caller<'_, ()>| {f(caller);@@ -49,7 +49,7 @@ fn test_stack_values<C: Fn(&mut Config), F: Fn(Caller<'_, ()>) + Send + Sync + '#[test]#[cfg_attr(miri, ignore)]-fn stack_values_two_frames() -> anyhow::Result<()> {+fn stack_values_two_frames() -> wasmtime::Result<()> {let _ = env_logger::try_init();for inlining in [false, true] {@@ -104,7 +104,7 @@ fn stack_values_two_frames() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn stack_values_exceptions() -> anyhow::Result<()> {+fn stack_values_exceptions() -> wasmtime::Result<()> {test_stack_values(r#"(module@@ -132,7 +132,7 @@ fn stack_values_exceptions() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn stack_values_dead_gc_ref() -> anyhow::Result<()> {+fn stack_values_dead_gc_ref() -> wasmtime::Result<()> {test_stack_values(r#"(module@@ -159,7 +159,7 @@ fn stack_values_dead_gc_ref() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn gc_access_during_call() -> anyhow::Result<()> {+fn gc_access_during_call() -> wasmtime::Result<()> {test_stack_values(r#"(module@@ -202,7 +202,7 @@ fn gc_access_during_call() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn stack_values_two_activations() -> anyhow::Result<()> {+fn stack_values_two_activations() -> wasmtime::Result<()> {let _ = env_logger::try_init();let mut config = Config::default();@@ -293,7 +293,7 @@ fn stack_values_two_activations() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn debug_frames_on_store_with_no_wasm_activation() -> anyhow::Result<()> {+fn debug_frames_on_store_with_no_wasm_activation() -> wasmtime::Result<()> {let mut config = Config::default();config.guest_debug(true);let engine = Engine::new(&config)?;@@ -355,7 +355,7 @@ macro_rules! debug_event_checker {#[tokio::test]#[cfg_attr(miri, ignore)]-async fn uncaught_exception_events() -> anyhow::Result<()> {+async fn uncaught_exception_events() -> wasmtime::Result<()> {let _ = env_logger::try_init();let (module, mut store) = get_module_and_store(@@ -407,7 +407,7 @@ async fn uncaught_exception_events() -> anyhow::Result<()> {#[tokio::test]#[cfg_attr(miri, ignore)]-async fn caught_exception_events() -> anyhow::Result<()> {+async fn caught_exception_events() -> wasmtime::Result<()> {let _ = env_logger::try_init();let (module, mut store) = get_module_and_store(@@ -462,7 +462,7 @@ async fn caught_exception_events() -> anyhow::Result<()> {#[tokio::test]#[cfg_attr(miri, ignore)]-async fn hostcall_trap_events() -> anyhow::Result<()> {+async fn hostcall_trap_events() -> wasmtime::Result<()> {let _ = env_logger::try_init();let (module, mut store) = get_module_and_store(@@ -502,7 +502,7 @@ async fn hostcall_trap_events() -> anyhow::Result<()> {#[tokio::test]#[cfg_attr(miri, ignore)]-async fn hostcall_error_events() -> anyhow::Result<()> {+async fn hostcall_error_events() -> wasmtime::Result<()> {let _ = env_logger::try_init();let (module, mut store) = get_module_and_store(@@ -532,8 +532,8 @@ async fn hostcall_error_events() -> anyhow::Result<()> {let do_a_trap = Func::wrap(&mut store,- |_caller: Caller<'_, ()>| -> anyhow::Result<()> {- Err(anyhow::anyhow!("secret error message"))+ |_caller: Caller<'_, ()>| -> wasmtime::Result<()> {+ Err(wasmtime::format_err!("secret error message"))},);let instance = Instance::new_async(&mut store, &module, &[Extern::Func(do_a_trap)]).await?;@@ -547,7 +547,7 @@ async fn hostcall_error_events() -> anyhow::Result<()> {#[tokio::test]#[cfg_attr(miri, ignore)]-async fn breakpoint_events() -> anyhow::Result<()> {+async fn breakpoint_events() -> wasmtime::Result<()> {let _ = env_logger::try_init();let (module, mut store) = get_module_and_store(@@ -689,7 +689,7 @@ async fn breakpoint_events() -> anyhow::Result<()> {#[tokio::test]#[cfg_attr(miri, ignore)]-async fn breakpoints_in_inlined_code() -> anyhow::Result<()> {+async fn breakpoints_in_inlined_code() -> wasmtime::Result<()> {let _ = env_logger::try_init();let (module, mut store) = get_module_and_store(@@ -756,7 +756,7 @@ async fn breakpoints_in_inlined_code() -> anyhow::Result<()> {#[tokio::test]#[cfg_attr(miri, ignore)]-async fn epoch_events() -> anyhow::Result<()> {+async fn epoch_events() -> wasmtime::Result<()> {let _ = env_logger::try_init();let (module, mut store) = get_module_and_store(diff --git a/tests/all/epoch_interruption.rs b/tests/all/epoch_interruption.rsindex 1cbac77efe..b861e252aa 100644--- a/tests/all/epoch_interruption.rs+++ b/tests/all/epoch_interruption.rs@@ -1,9 +1,9 @@#![cfg(not(miri))]use crate::async_functions::{CountPending, PollOnce};-use anyhow::anyhow;use std::sync::Arc;use std::sync::atomic::{AtomicBool, Ordering};+use wasmtime::format_err;use wasmtime::*;use wasmtime_test_macros::wasmtime_test;@@ -433,7 +433,7 @@ async fn epoch_callback_trap(config: &mut Config) -> Result<()> {(func $subfunc))",1,- InterruptMode::Callback(|_| Err(anyhow!("Failing in callback"))),+ InterruptMode::Callback(|_| Err(format_err!("Failing in callback"))),|_| {},).await?diff --git a/tests/all/externals.rs b/tests/all/externals.rsindex 0826f794d9..31cfc243b6 100644--- a/tests/all/externals.rs+++ b/tests/all/externals.rs@@ -55,7 +55,7 @@ fn bad_tables() {#[test]#[cfg_attr(miri, ignore)]-fn cross_store() -> anyhow::Result<()> {+fn cross_store() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;@@ -153,7 +153,7 @@ fn cross_store() -> anyhow::Result<()> {}#[test]-fn get_set_externref_globals_via_api() -> anyhow::Result<()> {+fn get_set_externref_globals_via_api() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;@@ -207,7 +207,7 @@ fn get_set_externref_globals_via_api() -> anyhow::Result<()> {}#[test]-fn get_set_funcref_globals_via_api() -> anyhow::Result<()> {+fn get_set_funcref_globals_via_api() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;@@ -242,7 +242,7 @@ fn get_set_funcref_globals_via_api() -> anyhow::Result<()> {}#[test]-fn create_get_set_funcref_tables_via_api() -> anyhow::Result<()> {+fn create_get_set_funcref_tables_via_api() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;@@ -260,7 +260,7 @@ fn create_get_set_funcref_tables_via_api() -> anyhow::Result<()> {}#[test]-fn fill_funcref_tables_via_api() -> anyhow::Result<()> {+fn fill_funcref_tables_via_api() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;@@ -287,7 +287,7 @@ fn fill_funcref_tables_via_api() -> anyhow::Result<()> {}#[test]-fn grow_funcref_tables_via_api() -> anyhow::Result<()> {+fn grow_funcref_tables_via_api() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;@@ -304,7 +304,7 @@ fn grow_funcref_tables_via_api() -> anyhow::Result<()> {}#[test]-fn create_get_set_externref_tables_via_api() -> anyhow::Result<()> {+fn create_get_set_externref_tables_via_api() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;@@ -333,7 +333,7 @@ fn create_get_set_externref_tables_via_api() -> anyhow::Result<()> {}#[test]-fn fill_externref_tables_via_api() -> anyhow::Result<()> {+fn fill_externref_tables_via_api() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;@@ -371,7 +371,7 @@ fn fill_externref_tables_via_api() -> anyhow::Result<()> {}#[test]-fn grow_externref_tables_via_api() -> anyhow::Result<()> {+fn grow_externref_tables_via_api() -> wasmtime::Result<()> {let mut cfg = Config::new();cfg.wasm_reference_types(true);let engine = Engine::new(&cfg)?;diff --git a/tests/all/func.rs b/tests/all/func.rsindex 98e39f8602..7b068b8090 100644--- a/tests/all/func.rs+++ b/tests/all/func.rs@@ -1,7 +1,7 @@-use anyhow::bail;use std::sync::Arc;use std::sync::atomic::Ordering;use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};+use wasmtime::bail;use wasmtime::*;use wasmtime_test_macros::wasmtime_test;@@ -923,7 +923,7 @@ fn get_from_signature() {#[wasmtime_test]#[cfg_attr(miri, ignore)]-fn get_from_module(config: &mut Config) -> anyhow::Result<()> {+fn get_from_module(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let mut store = Store::<()>::new(&engine, ());let module = Module::new(@@ -996,7 +996,7 @@ fn call_wrapped_func() -> Result<()> {#[wasmtime_test]#[cfg_attr(miri, ignore)]-fn caller_memory(config: &mut Config) -> anyhow::Result<()> {+fn caller_memory(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(config)?;let mut store = Store::<()>::new(&engine, ());let f = Func::wrap(&mut store, |mut c: Caller<'_, ()>| {@@ -1063,7 +1063,7 @@ fn caller_memory(config: &mut Config) -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn func_write_nothing() -> anyhow::Result<()> {+fn func_write_nothing() -> wasmtime::Result<()> {let mut store = Store::<()>::default();let ty = FuncType::new(store.engine(), None, Some(ValType::I32));let f = Func::new(&mut store, ty, |_, _, _| Ok(()));@@ -1077,7 +1077,7 @@ fn func_write_nothing() -> anyhow::Result<()> {#[wasmtime_test(wasm_features(reference_types))]#[cfg_attr(miri, ignore)]-fn return_cross_store_value(config: &mut Config) -> anyhow::Result<()> {+fn return_cross_store_value(config: &mut Config) -> wasmtime::Result<()> {let _ = env_logger::try_init();let wasm = wat::parse_str(@@ -1109,7 +1109,7 @@ fn return_cross_store_value(config: &mut Config) -> anyhow::Result<()> {}#[wasmtime_test(wasm_features(reference_types))]-fn pass_cross_store_arg(config: &mut Config) -> anyhow::Result<()> {+fn pass_cross_store_arg(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let mut store1 = Store::new(&engine, ());@@ -1137,7 +1137,7 @@ fn pass_cross_store_arg(config: &mut Config) -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn externref_signature_no_reference_types() -> anyhow::Result<()> {+fn externref_signature_no_reference_types() -> wasmtime::Result<()> {let mut config = Config::new();config.wasm_reference_types(false);let mut store = Store::new(&Engine::new(&config)?, ());@@ -1153,7 +1153,7 @@ fn externref_signature_no_reference_types() -> anyhow::Result<()> {#[wasmtime_test]#[cfg_attr(miri, ignore)]-fn trampolines_always_valid(config: &mut Config) -> anyhow::Result<()> {+fn trampolines_always_valid(config: &mut Config) -> wasmtime::Result<()> {// Compile two modules up frontlet engine = Engine::new(&config)?;let mut store = Store::<()>::new(&engine, ());@@ -1181,7 +1181,7 @@ fn trampolines_always_valid(config: &mut Config) -> anyhow::Result<()> {#[wasmtime_test]#[cfg_attr(miri, ignore)]-fn typed_multiple_results(config: &mut Config) -> anyhow::Result<()> {+fn typed_multiple_results(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let mut store = Store::<()>::new(&engine, ());let module = Module::new(@@ -1219,7 +1219,7 @@ fn typed_multiple_results(config: &mut Config) -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn trap_doesnt_leak() -> anyhow::Result<()> {+fn trap_doesnt_leak() -> wasmtime::Result<()> {#[derive(Default)]struct Canary(Arc<AtomicBool>);@@ -1261,8 +1261,8 @@ fn trap_doesnt_leak() -> anyhow::Result<()> {#[wasmtime_test]#[cfg_attr(miri, ignore)]-fn wrap_multiple_results(config: &mut Config) -> anyhow::Result<()> {- fn test<T>(store: &mut Store<()>, t: T) -> anyhow::Result<()>+fn wrap_multiple_results(config: &mut Config) -> wasmtime::Result<()> {+ fn test<T>(store: &mut Store<()>, t: T) -> wasmtime::Result<()>whereT: WasmRet+ WasmResults@@ -1427,7 +1427,7 @@ fn wrap_multiple_results(config: &mut Config) -> anyhow::Result<()> {#[wasmtime_test(wasm_features(reference_types, gc_types))]#[cfg_attr(miri, ignore)]-fn trampoline_for_declared_elem(config: &mut Config) -> anyhow::Result<()> {+fn trampoline_for_declared_elem(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let module = Module::new(@@ -1455,7 +1455,7 @@ fn trampoline_for_declared_elem(config: &mut Config) -> anyhow::Result<()> {#[wasmtime_test]#[cfg_attr(miri, ignore)]-fn wasm_ty_roundtrip(config: &mut Config) -> Result<(), anyhow::Error> {+fn wasm_ty_roundtrip(config: &mut Config) -> Result<(), wasmtime::Error> {let engine = Engine::new(&config)?;let mut store = Store::<()>::new(&engine, ());let debug = Func::wrap(@@ -1512,7 +1512,9 @@ fn wasm_ty_roundtrip(config: &mut Config) -> Result<(), anyhow::Error> {#[wasmtime_test]#[cfg_attr(miri, ignore)]-fn typed_funcs_count_params_correctly_in_error_messages(config: &mut Config) -> anyhow::Result<()> {+fn typed_funcs_count_params_correctly_in_error_messages(+ config: &mut Config,+) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let mut store = Store::<()>::new(&engine, ());let module = Module::new(@@ -1556,7 +1558,7 @@ fn typed_funcs_count_params_correctly_in_error_messages(config: &mut Config) ->#[wasmtime_test(wasm_features(reference_types, gc_types))]#[cfg_attr(miri, ignore)]-fn calls_with_funcref_and_externref(config: &mut Config) -> anyhow::Result<()> {+fn calls_with_funcref_and_externref(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let mut store = Store::<()>::new(&engine, ());let module = Module::new(@@ -1675,7 +1677,7 @@ fn calls_with_funcref_and_externref(config: &mut Config) -> anyhow::Result<()> {#[wasmtime_test(wasm_features(function_references))]#[cfg_attr(miri, ignore)]-fn typed_concrete_param(config: &mut Config) -> anyhow::Result<()> {+fn typed_concrete_param(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let module = Module::new(&engine,@@ -1748,7 +1750,7 @@ fn typed_concrete_param(config: &mut Config) -> anyhow::Result<()> {#[wasmtime_test(wasm_features(function_references))]#[cfg_attr(miri, ignore)]-fn typed_concrete_result(config: &mut Config) -> anyhow::Result<()> {+fn typed_concrete_result(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let module = Module::new(&engine,@@ -1801,7 +1803,7 @@ fn typed_concrete_result(config: &mut Config) -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn wrap_subtype_param() -> anyhow::Result<()> {+fn wrap_subtype_param() -> wasmtime::Result<()> {let mut store = Store::<()>::default();let f = Func::wrap(&mut store, |_caller: Caller<'_, ()>, _: Option<Func>| {// No-op.@@ -1825,7 +1827,7 @@ fn wrap_subtype_param() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn wrap_supertype_result() -> anyhow::Result<()> {+fn wrap_supertype_result() -> wasmtime::Result<()> {let mut store = Store::<()>::default();let f = Func::wrap(&mut store, |_caller: Caller<'_, ()>| -> NoFunc {unreachable!()@@ -1845,7 +1847,7 @@ fn wrap_supertype_result() -> anyhow::Result<()> {#[wasmtime_test(wasm_features(function_references))]#[cfg_attr(miri, ignore)]-fn call_wasm_passing_subtype_func_param(config: &mut Config) -> anyhow::Result<()> {+fn call_wasm_passing_subtype_func_param(config: &mut Config) -> wasmtime::Result<()> {config.wasm_function_references(true);let engine = Engine::new(&config)?;let mut store = Store::new(&engine, ());@@ -1924,7 +1926,7 @@ fn call_wasm_passing_subtype_func_param(config: &mut Config) -> anyhow::Result<(#[wasmtime_test(wasm_features(gc, function_references))]#[cfg_attr(miri, ignore)]-fn call_wasm_getting_subtype_func_return(config: &mut Config) -> anyhow::Result<()> {+fn call_wasm_getting_subtype_func_return(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let mut store = Store::new(&engine, ());@@ -1996,7 +1998,7 @@ fn call_wasm_getting_subtype_func_return(config: &mut Config) -> anyhow::Result<#[wasmtime_test(wasm_features(simd), strategies(not(Winch)))]#[cfg_attr(miri, ignore)]-fn typed_v128(config: &mut Config) -> anyhow::Result<()> {+fn typed_v128(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let mut store = Store::<()>::new(&engine, ());let module = Module::new(@@ -2065,7 +2067,7 @@ fn typed_v128(config: &mut Config) -> anyhow::Result<()> {#[wasmtime_test(wasm_features(simd))]#[cfg_attr(miri, ignore)]-fn typed_v128_imports(config: &mut Config) -> anyhow::Result<()> {+fn typed_v128_imports(config: &mut Config) -> wasmtime::Result<()> {let engine = Engine::new(&config)?;let mut store = Store::<()>::new(&engine, ());let module = Module::new(diff --git a/tests/all/funcref.rs b/tests/all/funcref.rsindex 2f4a9449e5..55508253f3 100644--- a/tests/all/funcref.rs+++ b/tests/all/funcref.rs@@ -5,7 +5,7 @@ use wasmtime::*;#[test]#[cfg_attr(miri, ignore)]-fn pass_funcref_in_and_out_of_wasm() -> anyhow::Result<()> {+fn pass_funcref_in_and_out_of_wasm() -> wasmtime::Result<()> {let (mut store, module) = ref_types_module(false,r#"@@ -79,7 +79,7 @@ fn pass_funcref_in_and_out_of_wasm() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn receive_null_funcref_from_wasm() -> anyhow::Result<()> {+fn receive_null_funcref_from_wasm() -> wasmtime::Result<()> {let (mut store, module) = ref_types_module(false,r#"@@ -103,7 +103,7 @@ fn receive_null_funcref_from_wasm() -> anyhow::Result<()> {}#[test]-fn wrong_store() -> anyhow::Result<()> {+fn wrong_store() -> wasmtime::Result<()> {let dropped = Arc::new(AtomicBool::new(false));{let mut store1 = Store::<()>::default();@@ -131,7 +131,7 @@ fn wrong_store() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn func_new_returns_wrong_store() -> anyhow::Result<()> {+fn func_new_returns_wrong_store() -> wasmtime::Result<()> {let dropped = Arc::new(AtomicBool::new(false));{let mut store1 = Store::<()>::default();diff --git a/tests/all/gc.rs b/tests/all/gc.rsindex 8593b9e6f1..7892c7663e 100644--- a/tests/all/gc.rs+++ b/tests/all/gc.rs@@ -649,7 +649,7 @@ fn gc_and_tail_calls_and_stack_arguments() -> Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn no_leak_with_global_get_elem_segment() -> anyhow::Result<()> {+fn no_leak_with_global_get_elem_segment() -> wasmtime::Result<()> {let dropped = Arc::new(AtomicBool::new(false));let engine = Engine::default();@@ -695,7 +695,7 @@ fn no_leak_with_global_get_elem_segment() -> anyhow::Result<()> {#[test]#[cfg_attr(miri, ignore)]-fn table_init_with_externref_global_get() -> anyhow::Result<()> {+fn table_init_with_externref_global_get() -> wasmtime::Result<()> {let dropped = Arc::new(AtomicBool::new(false));let mut config = Config::new();@@ -1487,7 +1487,7 @@ fn drc_gc_inbetween_host_calls() -> Result<()> {assert!(!inner_dropped.load(SeqCst));store.gc(None);assert!(inner_dropped.load(SeqCst));- anyhow::Ok(())+ wasmtime::error::Ok(())};invoke_func()?;diff --git a/tests/all/globals.rs b/tests/all/globals.rsindex 177bdb6291..e6694f6d4e 100644--- a/tests/all/globals.rs+++ b/tests/all/globals.rs@@ -1,7 +1,7 @@use wasmtime::*;#[test]-fn smoke() -> anyhow::Result<()> {+fn smoke() -> wasmtime::Result<()> {let mut store = Store::<()>::default();let g = Global::new(&mut store,@@ -42,7 +42,7 @@ fn smoke() -> anyhow::Result<()> {}#[test]-fn mutability() -> anyhow::Result<()> {+fn mutability() -> wasmtime::Result<()> {let mut store = Store::<()>::default();let g = Global::new(&mut store,@@ -60,7 +60,7 @@ fn mutability() -> anyhow::Result<()> {// implementation, but for now should hopefully be resilient enough to catch at// least some cases of heap corruption.#[test]-fn use_after_drop() -> anyhow::Result<()> {+fn use_after_drop() -> wasmtime::Result<()> {let mut store = Store::<()>::default();let module = Module::new(store.engine(),@@ -90,7 +90,7 @@ fn use_after_drop() -> anyhow::Result<()> {}#[test]-fn v128() -> anyhow::Result<()> {+fn v128() -> wasmtime::Result<()> {let mut store = Store::<()>::default();let g = Global::new(&mut store,diff --git a/tests/all/host_funcs.rs b/tests/all/host_funcs.rsindex 8aae8499b0..627138d1a7 100644--- a/tests/all/host_funcs.rs+++ b/tests/all/host_funcs.rs@@ -1,5 +1,5 @@-use anyhow::bail;use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};+use wasmtime::bail;use wasmtime::*;#[test]diff --git a/tests/all/iloop.rs b/tests/all/iloop.rsindex 6e7077e874..4e6e8771e6 100644--- a/tests/all/iloop.rs+++ b/tests/all/iloop.rs@@ -10,7 +10,7 @@ fn interruptable_store() -> Store<()> {store}-fn hugely_recursive_module(engine: &Engine) -> anyhow::Result<Module> {+fn hugely_recursive_module(engine: &Engine) -> wasmtime::Result<Module> {let mut wat = String::new();wat.push_str(r#"@@ -27,7 +27,7 @@ fn hugely_recursive_module(engine: &Engine) -> anyhow::Result<Module> {}#[test]-fn loops_interruptable() -> anyhow::Result<()> {+fn loops_interruptable() -> wasmtime::Result<()> {let mut store = interruptable_store();let module = Module::new(store.engine(), r#"(func (export "loop") (loop br 0))"#)?;let instance = Instance::new(&mut store, &module, &[])?;@@ -39,7 +39,7 @@ fn loops_interruptable() -> anyhow::Result<()> {}#[test]-fn functions_interruptable() -> anyhow::Result<()> {+fn functions_interruptable() -> wasmtime::Result<()> {let mut store = interruptable_store();let module = hugely_recursive_module(store.engine())?;let func = Func::wrap(&mut store, || {});@@ -54,7 +54,7 @@ fn functions_interruptable() -> anyhow::Result<()> {const NUM_HITS: usize = 100_000;#[test]-fn loop_interrupt_from_afar() -> anyhow::Result<()> {+fn loop_interrupt_from_afar() -> wasmtime::Result<()> {// Create an instance which calls an imported function on each iteration of// the loop so we can count the number of loop iterations we've executed so// far.@@ -101,7 +101,7 @@ fn loop_interrupt_from_afar() -> anyhow::Result<()> {}#[test]-fn function_interrupt_from_afar() -> anyhow::Result<()> {+fn function_interrupt_from_afar() -> wasmtime::Result<()> {// Create an instance which calls an imported function on each iteration of// the loop so we can count the number of loop iterations we've executed so// far.diff --git a/tests/all/import_indexes.rs b/tests/all/import_indexes.rsindex 6a92ddd283..67b58f77d4 100644--- a/tests/all/import_indexes.rs+++ b/tests/all/import_indexes.rs@@ -3,7 +3,7 @@use wasmtime::*;#[test]-fn same_import_names_still_distinct() -> anyhow::Result<()> {+fn same_import_names_still_distinct() -> wasmtime::Result<()> {const WAT: &str = r#"(module(import "" "" (func $a (result i32)))diff --git a/tests/all/invoke_func_via_table.rs b/tests/all/invoke_func_via_table.rsindex 9504baea1b..2564c217e3 100644--- a/tests/all/invoke_func_via_table.rs+++ b/tests/all/invoke_func_via_table.rs@@ -1,6 +1,6 @@#![cfg(not(miri))]-use anyhow::Context as _;+use wasmtime::error::Context as _;use wasmtime::*;#[test]diff --git a/tests/all/limits.rs b/tests/all/limits.rsindex fb74ce81ef..01f7bda589 100644--- a/tests/all/limits.rs+++ b/tests/all/limits.rs@@ -726,7 +726,7 @@ impl ResourceLimiter for FailureDetector {self.memory_desired = desired;Ok(true)}- fn memory_grow_failed(&mut self, err: anyhow::Error) -> Result<()> {+ fn memory_grow_failed(&mut self, err: wasmtime::Error) -> Result<()> {self.memory_error = Some(err.to_string());Ok(())}@@ -740,7 +740,7 @@ impl ResourceLimiter for FailureDetector {self.table_desired = desired;Ok(true)}- fn table_grow_failed(&mut self, err: anyhow::Error) -> Result<()> {+ fn table_grow_failed(&mut self, err: wasmtime::Error) -> Result<()> {self.table_error = Some(err.to_string());Ok(())}@@ -835,7 +835,7 @@ impl ResourceLimiterAsync for FailureDetector {self.memory_desired = desired;Ok(true)}- fn memory_grow_failed(&mut self, err: anyhow::Error) -> Result<()> {+ fn memory_grow_failed(&mut self, err: wasmtime::Error) -> Result<()> {self.memory_error = Some(err.to_string());Ok(())}@@ -850,7 +850,7 @@ impl ResourceLimiterAsync for FailureDetector {self.table_desired = desired;Ok(true)}- fn table_grow_failed(&mut self, err: anyhow::Error) -> Result<()> {+ fn table_grow_failed(&mut self, err: wasmtime::Error) -> Result<()> {self.table_error = Some(err.to_string());Ok(())}diff --git a/tests/all/main.rs b/tests/all/main.rsindex 7aabc438bd..3a365ba16a 100644--- a/tests/all/main.rs+++ b/tests/all/main.rs@@ -63,7 +63,7 @@ mod winch_engine_features;pub(crate) fn ref_types_module(use_epochs: bool,source: &str,-) -> anyhow::Result<(wasmtime::Store<()>, wasmtime::Module)> {+) -> wasmtime::Result<(wasmtime::Store<()>, wasmtime::Module)> {use wasmtime::*;let _ = env_logger::try_init();@@ -132,7 +132,7 @@ trait ErrorExt {fn assert_contains(&self, msg: &str);}-impl ErrorExt for anyhow::Error {+impl ErrorExt for wasmtime::Error {fn assert_contains(&self, msg: &str) {if self.chain().any(|e| e.to_string().contains(msg)) {return;diff --git a/tests/all/memory_creator.rs b/tests/all/memory_creator.rsindex f210e01dc6..8d7a1fc8fe 100644--- a/tests/all/memory_creator.rs+++ b/tests/all/memory_creator.rs@@ -133,7 +133,7 @@ mod not_for_windows {}#[test]- fn host_memory() -> anyhow::Result<()> {+ fn host_memory() -> wasmtime::Result<()> {let (mut store, mem_creator) = config();let module = Module::new(store.engine(),@@ -151,7 +151,7 @@ mod not_for_windows {}#[test]- fn host_memory_grow() -> anyhow::Result<()> {+ fn host_memory_grow() -> wasmtime::Result<()> {let (mut store, mem_creator) = config();let module = Module::new(store.engine(),diff --git a/tests/all/module.rs b/tests/all/module.rsindex fb6d8c7725..da99f7442b 100644--- a/tests/all/module.rs+++ b/tests/all/module.rs@@ -1,7 +1,7 @@-use anyhow::Context;use std::sync::Arc;use std::sync::atomic::{AtomicBool, Ordering::Relaxed};use target_lexicon::Triple;+use wasmtime::error::Context as _;use wasmtime::*;use wasmtime_environ::TripleExt;use wasmtime_test_macros::wasmtime_test;diff --git a/tests/all/module_serialize.rs b/tests/all/module_serialize.rsindex 1eb1a8a38d..134f554051 100644--- a/tests/all/module_serialize.rs+++ b/tests/all/module_serialize.rs@@ -1,5 +1,5 @@-use anyhow::bail;use std::fs::{self, OpenOptions};+use wasmtime::bail;use wasmtime::*;fn serialize(engine: &Engine, wat: &str) -> Result<Vec<u8>> {diff --git a/tests/all/name.rs b/tests/all/name.rsindex 5e64e19356..04bc8df978 100644--- a/tests/all/name.rs+++ b/tests/all/name.rs@@ -3,7 +3,7 @@use wasmtime::*;#[test]-fn test_module_no_name() -> anyhow::Result<()> {+fn test_module_no_name() -> wasmtime::Result<()> {let engine = Engine::default();let wat = r#"(module@@ -18,7 +18,7 @@ fn test_module_no_name() -> anyhow::Result<()> {}#[test]-fn test_module_name() -> anyhow::Result<()> {+fn test_module_name() -> wasmtime::Result<()> {let engine = Engine::default();let wat = r#"(module $from_name_sectiondiff --git a/tests/all/native_debug/dump.rs b/tests/all/native_debug/dump.rsindex 9a7d7039cb..96c0b5a7ad 100644--- a/tests/all/native_debug/dump.rs+++ b/tests/all/native_debug/dump.rs@@ -1,6 +1,6 @@-use anyhow::{Context, Result, bail};use std::env;use std::process::Command;+use wasmtime::{Result, bail, error::Context as _};#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum DwarfDumpSection {diff --git a/tests/all/native_debug/gdb.rs b/tests/all/native_debug/gdb.rsindex c28561606a..c58cf4aac4 100644--- a/tests/all/native_debug/gdb.rs+++ b/tests/all/native_debug/gdb.rs@@ -1,9 +1,9 @@-use anyhow::{Result, bail, format_err};use filecheck::{CheckerBuilder, NO_VARIABLES};use std::env;use std::io::Write;use std::process::Command;use tempfile::NamedTempFile;+use wasmtime::{Result, bail, format_err};fn gdb_with_script(args: &[&str], script: &str) -> Result<String> {let lldb_path = env::var("GDB").unwrap_or("gdb".to_string());diff --git a/tests/all/native_debug/lldb.rs b/tests/all/native_debug/lldb.rsindex 9d30f51d3b..700f113bb1 100644--- a/tests/all/native_debug/lldb.rs+++ b/tests/all/native_debug/lldb.rs@@ -1,10 +1,10 @@-use anyhow::{Result, bail, format_err};use filecheck::{CheckerBuilder, NO_VARIABLES};use std::env;use std::io::Write;use std::process::Command;use tempfile::NamedTempFile;use test_programs_artifacts::*;+use wasmtime::{Result, bail, format_err};macro_rules! assert_test_exists {($name:ident) => {diff --git a/tests/all/native_debug/obj.rs b/tests/all/native_debug/obj.rsindex 4395da771b..cebd553d91 100644--- a/tests/all/native_debug/obj.rs+++ b/tests/all/native_debug/obj.rs@@ -1,9 +1,8 @@-use anyhow::{Context as _, Result};use std::fs::File;use std::io::Write;use std::path::Path;use target_lexicon::Triple;-use wasmtime::{CodeBuilder, Config, Engine};+use wasmtime::{CodeBuilder, Config, Engine, Result, error::Context as _};pub fn compile_cranelift(wasm: &[u8],diff --git a/tests/all/native_debug/simulate.rs b/tests/all/native_debug/simulate.rsindex c59a799d40..1826e5e95d 100644--- a/tests/all/native_debug/simulate.rs+++ b/tests/all/native_debug/simulate.rs@@ -1,8 +1,8 @@use super::dump::{DwarfDumpSection, get_dwarfdump};use super::obj::compile_cranelift;-use anyhow::{Result, format_err};use filecheck::{CheckerBuilder, NO_VARIABLES};use tempfile::NamedTempFile;+use wasmtime::{Result, format_err};use wat::parse_str;#[allow(dead_code, reason = "used by conditionally-defined tests below")]diff --git a/tests/all/native_debug/translate.rs b/tests/all/native_debug/translate.rsindex ce298d009f..afd55e8857 100644--- a/tests/all/native_debug/translate.rs+++ b/tests/all/native_debug/translate.rs@@ -1,10 +1,10 @@use super::dump::{DwarfDumpSection, get_dwarfdump};use super::obj::compile_cranelift;-use anyhow::{Result, format_err};use filecheck::{CheckerBuilder, NO_VARIABLES};use std::fs::read;use tempfile::NamedTempFile;use test_programs_artifacts::*;+use wasmtime::{Result, format_err};fn check_wasm(wasm_path: &str, directives: &str) -> Result<()> {println!("check {wasm_path}");diff --git a/tests/all/piped_tests.rs b/tests/all/piped_tests.rsindex 527446bb80..0a9dfad4f1 100644--- a/tests/all/piped_tests.rs+++ b/tests/all/piped_tests.rs@@ -1,8 +1,8 @@#![cfg(not(miri))]use super::cli_tests::get_wasmtime_command;-use anyhow::Result;use std::process::Stdio;+use wasmtime::Result;pub fn run_wasmtime_piped(component_path: &str) -> Result<()> {let mut producer = get_wasmtime_command()?diff --git a/tests/all/pulley.rs b/tests/all/pulley.rsindex cccc5579b5..4e2127583d 100644--- a/tests/all/pulley.rs+++ b/tests/all/pulley.rs@@ -1,6 +1,6 @@-use anyhow::Result;use std::ptr::NonNull;use std::thread;+use wasmtime::Result;use wasmtime::component::{self, Component};use wasmtime::{Caller, Config, Engine, Func, FuncType, Instance, Module, Store, Trap, Val, ValType,@@ -461,28 +461,28 @@ async fn pulley_provenance_test_async_components() -> Result<()> {let run = instance.get_typed_func::<(), ()>(&mut store, "run-stackless")?;store.run_concurrent(async move |accessor| {- anyhow::Ok(run.call_concurrent(accessor, ()).await?.0)+ wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?.0)}).await??;let run = instance.get_typed_func::<(), ()>(&mut store, "run-stackful")?;store.run_concurrent(async move |accessor| {- anyhow::Ok(run.call_concurrent(accessor, ()).await?.0)+ wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?.0)}).await??;let run = instance.get_typed_func::<(), ()>(&mut store, "run-stackless-stackless")?;store.run_concurrent(async move |accessor| {- anyhow::Ok(run.call_concurrent(accessor, ()).await?.0)+ wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?.0)}).await??;let run = instance.get_typed_func::<(), ()>(&mut store, "run-stackful-stackful")?;store.run_concurrent(async move |accessor| {- anyhow::Ok(run.call_concurrent(accessor, ()).await?.0)+ wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?.0)}).await??;}diff --git a/tests/all/stack_creator.rs b/tests/all/stack_creator.rsindex eeb0c6ac93..10fe25e8b8 100644--- a/tests/all/stack_creator.rs+++ b/tests/all/stack_creator.rs@@ -1,11 +1,11 @@#![cfg(all(not(target_os = "windows"), not(miri)))]-use anyhow::{Context, bail};use std::{alloc::{GlobalAlloc, Layout, System},ops::Range,ptr::NonNull,sync::Arc,};+use wasmtime::error::Context as _;use wasmtime::*;fn align_up(v: usize, align: usize) -> usize {diff --git a/tests/all/traps.rs b/tests/all/traps.rsindex b7ab0ed307..fa7752afd4 100644--- a/tests/all/traps.rs+++ b/tests/all/traps.rs@@ -1,10 +1,10 @@#![cfg(not(miri))]use crate::ErrorExt;-use anyhow::bail;use std::panic::{self, AssertUnwindSafe};use std::process::Command;use std::sync::{Arc, Mutex};+use wasmtime::bail;use wasmtime::*;use wasmtime_test_macros::wasmtime_test;@@ -37,7 +37,7 @@ fn test_trap_return() -> Result<()> {}#[test]-fn test_anyhow_error_return() -> Result<()> {+fn test_format_err_error_return() -> Result<()> {let mut store = Store::<()>::default();let wat = r#"(module@@ -49,7 +49,7 @@ fn test_anyhow_error_return() -> Result<()> {let module = Module::new(store.engine(), wat)?;let hello_type = FuncType::new(store.engine(), None, None);let hello_func = Func::new(&mut store, hello_type, |_, _, _| {- Err(anyhow::Error::msg("test 1234"))+ Err(wasmtime::Error::msg("test 1234"))});let instance = Instance::new(&mut store, &module, &[hello_func.into()])?;@@ -86,7 +86,7 @@ fn test_trap_return_downcast() -> Result<()> {let module = Module::new(store.engine(), wat)?;let hello_type = FuncType::new(store.engine(), None, None);let hello_func = Func::new(&mut store, hello_type, |_, _, _| {- Err(anyhow::Error::from(MyTrap))+ Err(wasmtime::Error::from(MyTrap))});let instance = Instance::new(&mut store, &module, &[hello_func.into()])?;@@ -1513,7 +1513,7 @@ fn dont_see_stale_stack_walking_registers() -> Result<()> {let host_get_trap = Func::new(&mut store,FuncType::new(&engine, [], []),- |_caller, _args, _results| Err(anyhow::anyhow!("trap!!!")),+ |_caller, _args, _results| Err(wasmtime::format_err!("trap!!!")),);linker.define(&store, "", "host_get_trap", host_get_trap)?;diff --git a/tests/all/winch_engine_features.rs b/tests/all/winch_engine_features.rsindex 1ee887fc6e..d99023daf3 100644--- a/tests/all/winch_engine_features.rs+++ b/tests/all/winch_engine_features.rs@@ -12,7 +12,9 @@ fn ensure_compatibility_between_winch_and_table_lazy_init(config: &mut Config) -let result = Engine::new(&config);match result {Ok(_) => {- anyhow::bail!("Expected incompatibility between the `table_lazy_init` option and Winch")+ wasmtime::bail!(+ "Expected incompatibility between the `table_lazy_init` option and Winch"+ )}Err(e) => {assert_eq!(@@ -32,7 +34,7 @@ fn ensure_compatibility_between_winch_and_signals_based_traps(config: &mut Confilet result = Engine::new(&config);match result {Ok(_) => {- anyhow::bail!(+ wasmtime::bail!("Expected incompatibility between the `signals_based_traps` option and Winch")}@@ -54,7 +56,7 @@ fn ensure_compatibility_between_winch_and_debug_native(config: &mut Config) -> Rlet result = Engine::new(&config);match result {Ok(_) => {- anyhow::bail!("Expected incompatibility between the `debug_native` option and Winch")+ wasmtime::bail!("Expected incompatibility between the `debug_native` option and Winch")}Err(e) => {assert_eq!(diff --git a/tests/disable_host_trap_handlers.rs b/tests/disable_host_trap_handlers.rsindex da2830d80a..9065415d48 100644--- a/tests/disable_host_trap_handlers.rs+++ b/tests/disable_host_trap_handlers.rs@@ -7,7 +7,7 @@//! This will ensure that various trapping scenarios all work and additionally//! signal handlers are not registered.-use anyhow::Result;+use wasmtime::Result;use wasmtime::{Config, Engine, Instance, Module, Store, Trap};#[test]diff --git a/tests/disas.rs b/tests/disas.rsindex 7b0a0956db..eb2b4878fb 100644--- a/tests/disas.rs+++ b/tests/disas.rs@@ -39,7 +39,6 @@//! at the start of the file. These comments are then parsed as TOML and//! deserialized into `TestConfig` in this crate.-use anyhow::{Context, Result, bail};use clap::Parser;use cranelift_codegen::ir::Function;use libtest_mimic::{Arguments, Trial};@@ -50,7 +49,9 @@ use std::io::Write as _;use std::path::{Path, PathBuf};use std::process::Stdio;use tempfile::TempDir;-use wasmtime::{CodeBuilder, CodeHint, Engine, OptLevel, Strategy};+use wasmtime::{+ CodeBuilder, CodeHint, Engine, OptLevel, Result, Strategy, bail, error::Context as _,+};use wasmtime_cli_flags::CommonOptions;fn main() -> Result<()> {diff --git a/tests/rlimited-memory.rs b/tests/rlimited-memory.rsindex a6aba1653c..54d2a44d9d 100644--- a/tests/rlimited-memory.rs+++ b/tests/rlimited-memory.rs@@ -22,7 +22,7 @@ impl ResourceLimiter for MemoryGrowFailureDetector {self.desired = desired;Ok(true)}- fn memory_grow_failed(&mut self, err: anyhow::Error) -> Result<()> {+ fn memory_grow_failed(&mut self, err: wasmtime::Error) -> Result<()> {self.error = Some(err.to_string());Ok(())}diff --git a/tests/wasi.rs b/tests/wasi.rsindex ab1aed82ea..fffe64b37a 100644--- a/tests/wasi.rs+++ b/tests/wasi.rs@@ -3,7 +3,6 @@//!//! [wasi-testsuite]: https://github.com/WebAssembly/wasi-testsuite-use anyhow::{Result, anyhow};use libtest_mimic::{Arguments, Trial};use serde_derive::Deserialize;use std::collections::HashMap;@@ -12,6 +11,7 @@ use std::fs;use std::path::Path;use std::process::Output;use tempfile::TempDir;+use wasmtime::{Result, format_err};use wit_component::ComponentEncoder;const KNOWN_FAILURES: &[&str] = &[@@ -149,7 +149,7 @@ fn run_test(path: &Path, componentize: bool) -> Result<()> {let wasmtime = Path::new(env!("CARGO_BIN_EXE_wasmtime"));let test_name = path.file_stem().unwrap().to_str().unwrap();let target_dir = wasmtime.parent().unwrap().parent().unwrap();- let parent_dir = path.parent().ok_or(anyhow!("module has no parent?"))?;+ let parent_dir = path.parent().ok_or(format_err!("module has no parent?"))?;let spec = if let Ok(contents) = fs::read_to_string(&path.with_extension("json")) {serde_json::from_str(&contents)?} else {@@ -236,13 +236,13 @@ fn run_test(path: &Path, componentize: bool) -> Result<()> {String::from_utf8_lossy(&result.stderr).replace("\n", "\n "))?;}- anyhow::bail!("{msg}\nFAILED! The result does not match the specification");+ wasmtime::bail!("{msg}\nFAILED! The result does not match the specification");}// If this test passed but it's flagged as should be failed, then fail// this test for someone to update `KNOWN_FAILURES`.(true, true) => {- anyhow::bail!("test passed but it's listed in `KNOWN_FAILURES`")+ wasmtime::bail!("test passed but it's listed in `KNOWN_FAILURES`")}}}diff --git a/tests/wast.rs b/tests/wast.rsindex df84b55eeb..4dc7a28184 100644--- a/tests/wast.rs+++ b/tests/wast.rs@@ -1,7 +1,9 @@-use anyhow::{Context, bail};use libtest_mimic::{Arguments, FormatSetting, Trial};use std::sync::{Condvar, LazyLock, Mutex};-use wasmtime::{Config, Enabled, Engine, InstanceAllocationStrategy, PoolingAllocationConfig};+use wasmtime::{+ Config, Enabled, Engine, InstanceAllocationStrategy, PoolingAllocationConfig, bail,+ error::Context as _,+};use wasmtime_test_util::wast::{Collector, Compiler, WastConfig, WastTest, limits};use wasmtime_wast::{Async, SpectestConfig, WastContext};@@ -118,7 +120,7 @@ fn main() {// Each of the tests included from `wast_testsuite_tests` will call this// function which actually executes the `wast` test suite given the `strategy`// to compile it.-fn run_wast(test: &WastTest, config: WastConfig) -> anyhow::Result<()> {+fn run_wast(test: &WastTest, config: WastConfig) -> wasmtime::Result<()> {let test_config = test.config.clone();// Determine whether this test is expected to fail or pass. Regardless the