Skip to content

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

Replace `anyhow` with `wasmtime_internal_error` (#12309)

Nick Fitzgeralde2fbd1453b6d
diff --git a/Cargo.lock b/Cargo.lock
index 9ce029c047..f2ed407d46 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4713,6 +4713,7 @@ dependencies = [
"wasmparser 0.244.0",
"wasmprinter",
"wasmtime-internal-component-util",
+ "wasmtime-internal-error",
"wat",
]
diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.toml
index ee3bc5c963..4f6c2e7568 100644
--- a/crates/environ/Cargo.toml
+++ b/crates/environ/Cargo.toml
@@ -35,6 +35,7 @@ target-lexicon = { workspace = true }
wasm-encoder = { workspace = true, optional = true }
wasmprinter = { workspace = true, optional = true }
wasmtime-component-util = { workspace = true, optional = true }
+wasmtime-error = { workspace = true }
semver = { workspace = true, optional = true, features = ['serde'] }
smallvec = { workspace = true, features = ['serde'] }
@@ -55,7 +56,7 @@ name = "factc"
required-features = ['component-model', 'compile']
[features]
-anyhow = []
+anyhow = ["wasmtime-error/anyhow"]
component-model = [
"dep:wasmtime-component-util",
"dep:semver",
diff --git a/crates/environ/src/lib.rs b/crates/environ/src/lib.rs
index 1fabe90141..ea552f80ff 100644
--- a/crates/environ/src/lib.rs
+++ b/crates/environ/src/lib.rs
@@ -80,24 +80,12 @@ pub mod fact;
// one of three and making sure you're using the right one.
pub use cranelift_entity::*;
-// Temporarily re-export `anyhow` as `wasmtime_environ::error` to ease the
-// migration to the `wasmtime-internal-error` crate.
-pub use anyhow as error;
+// Reexport the error crate as a submodule for convenience.
+#[doc(inline)]
+pub use wasmtime_error as error;
-// Temporarily polyfill `wasmtime_internal_error::ToWasmtimeResult` to ease
-// migration, before we swap out `anyhow` with the `wasmtime_internal_error`
-// crate.
#[cfg(feature = "anyhow")]
-#[doc(hidden)]
-pub trait ToWasmtimeResult<T> {
- fn to_wasmtime_result(self) -> self::error::Result<T>;
-}
-#[cfg(feature = "anyhow")]
-impl<T> ToWasmtimeResult<T> for anyhow::Result<T> {
- fn to_wasmtime_result(self) -> self::error::Result<T> {
- self
- }
-}
+pub use wasmtime_error::ToWasmtimeResult;
// Only for use with `bindgen!`-generated code.
#[doc(hidden)]
diff --git a/scripts/publish.rs b/scripts/publish.rs
index d752ed60e5..c418760cf3 100644
--- a/scripts/publish.rs
+++ b/scripts/publish.rs
@@ -40,6 +40,7 @@ const CRATES_TO_PUBLISH: &[&str] = &[
"cranelift-native",
"cranelift-object",
"cranelift-interpreter",
+ "wasmtime-internal-error",
"wasmtime-internal-component-util",
"wasmtime-environ",
"wasmtime-internal-jit-icache-coherence",
@@ -52,7 +53,6 @@ const CRATES_TO_PUBLISH: &[&str] = &[
"wiggle-generate",
"wiggle-macro",
// wasmtime
- "wasmtime-internal-error",
"wasmtime-internal-versioned-export-macros",
"wasmtime-internal-slab",
"wasmtime-internal-wit-bindgen",