A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Fold the `wasmtime-error` crate into `wasmtime-core` (#12418)
Alex Crichton8325e1ec28be
diff --git a/.github/workflows/main.yml b/.github/workflows/main.ymlindex 3937129593..0ba6fe064a 100644--- a/.github/workflows/main.yml+++ b/.github/workflows/main.yml@@ -1177,8 +1177,6 @@ jobs:- crate: "wasmtime-cli"- crate: "wasmtime-environ --all-features"- crate: "pulley-interpreter --all-features"- - crate: "wasmtime-internal-error"- - crate: "wasmtime-internal-error --all-features"- crate: "wasmtime-internal-core"- crate: "wasmtime-internal-core --all-features"- script: ./ci/miri-provenance-test.shdiff --git a/Cargo.lock b/Cargo.lockindex db111d5880..4e1876bf1d 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -744,7 +744,6 @@ dependencies = ["serde","serde_derive","wasmtime-internal-core",- "wasmtime-internal-error",][[package]]@@ -812,7 +811,7 @@ dependencies = ["cranelift-bitset","serde","serde_derive",- "wasmtime-internal-error",+ "wasmtime-internal-core",][[package]]@@ -4717,7 +4716,6 @@ dependencies = ["wasmprinter","wasmtime-internal-component-util","wasmtime-internal-core",- "wasmtime-internal-error","wat",]@@ -4799,7 +4797,7 @@ dependencies = ["wasmtime","wasmtime-cli-flags","wasmtime-environ",- "wasmtime-internal-error",+ "wasmtime-internal-core","wasmtime-test-util","wasmtime-wasi","wasmtime-wast",@@ -4863,8 +4861,8 @@ version = "42.0.0"name = "wasmtime-internal-core"version = "42.0.0"dependencies = [+ "anyhow","libm",- "wasmtime-internal-error",][[package]]@@ -4902,13 +4900,6 @@ dependencies = ["wasmtime",]-[[package]]-name = "wasmtime-internal-error"-version = "42.0.0"-dependencies = [- "anyhow",-]-[[package]]name = "wasmtime-internal-explorer"version = "42.0.0"diff --git a/Cargo.toml b/Cargo.tomlindex 679c0e3bdb..c37eeae36e 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -158,9 +158,7 @@ members = ["cranelift/serde","crates/bench-api","crates/c-api/artifact",- "crates/core","crates/environ/fuzz",- "crates/error","crates/misc/component-async-tests","crates/test-programs","crates/wasi-preview1-component-adapter",@@ -265,7 +263,6 @@ wasmtime-wast = { path = "crates/wast", version = "=42.0.0" }# part of the project organization of other public crates in Wasmtime and are# otherwise not supported in terms of CVEs for example.wasmtime-core = { path = "crates/core", version = "=42.0.0", package = 'wasmtime-internal-core' }-wasmtime-error = { path = "crates/error", version = "=42.0.0", package = 'wasmtime-internal-error' }wasmtime-wmemcheck = { path = "crates/wmemcheck", version = "=42.0.0", package = 'wasmtime-internal-wmemcheck' }wasmtime-c-api-macros = { path = "crates/c-api-macros", version = "=42.0.0", package = 'wasmtime-internal-c-api-macros' }wasmtime-cache = { path = "crates/cache", version = "=42.0.0", package = 'wasmtime-internal-cache' }diff --git a/cranelift/bitset/Cargo.toml b/cranelift/bitset/Cargo.tomlindex 10dabbab6c..787b083285 100644--- a/cranelift/bitset/Cargo.toml+++ b/cranelift/bitset/Cargo.toml@@ -16,7 +16,6 @@ workspace = truearbitrary = { workspace = true, optional = true }serde = { workspace = true, optional = true }serde_derive = { workspace = true, optional = true }-wasmtime-error = { workspace = true }wasmtime-core = { workspace = true }[features]diff --git a/cranelift/bitset/src/compound.rs b/cranelift/bitset/src/compound.rsindex 93a000d8bc..ed5991821f 100644--- a/cranelift/bitset/src/compound.rs+++ b/cranelift/bitset/src/compound.rs@@ -3,7 +3,7 @@use crate::scalar::{self, ScalarBitSet, ScalarBitSetStorage};use alloc::boxed::Box;use core::{cmp, iter, mem};-use wasmtime_error::OutOfMemory;+use wasmtime_core::error::OutOfMemory;/// A large bit set backed by dynamically-sized storage.///diff --git a/cranelift/entity/Cargo.toml b/cranelift/entity/Cargo.tomlindex 18965549da..0e08c9c1ec 100644--- a/cranelift/entity/Cargo.toml+++ b/cranelift/entity/Cargo.toml@@ -19,7 +19,7 @@ workspace = truecranelift-bitset = { workspace=true }serde = { workspace = true, optional = true }serde_derive = { workspace = true, optional = true }-wasmtime-error = { workspace = true }+wasmtime-core = { workspace = true }[features]enable-serde = ["serde", "serde_derive", "cranelift-bitset/enable-serde"]diff --git a/cranelift/entity/src/primary.rs b/cranelift/entity/src/primary.rsindex babf4d5790..a39953a5d9 100644--- a/cranelift/entity/src/primary.rs+++ b/cranelift/entity/src/primary.rs@@ -11,7 +11,7 @@ use core::ops::{Index, IndexMut};use core::slice;#[cfg(feature = "enable-serde")]use serde_derive::{Deserialize, Serialize};-use wasmtime_error::OutOfMemory;+use wasmtime_core::error::OutOfMemory;/// A primary mapping `K -> V` allocating dense entity references.///diff --git a/cranelift/entity/src/set.rs b/cranelift/entity/src/set.rsindex 944c429440..e93316c154 100644--- a/cranelift/entity/src/set.rs+++ b/cranelift/entity/src/set.rs@@ -5,7 +5,7 @@ use crate::keys::Keys;use core::fmt;use core::marker::PhantomData;use cranelift_bitset::CompoundBitSet;-use wasmtime_error::OutOfMemory;+use wasmtime_core::error::OutOfMemory;/// A set of `K` for densely indexed entity references.///diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.tomlindex 0f941d02e5..0658e7869f 100644--- a/crates/core/Cargo.toml+++ b/crates/core/Cargo.toml@@ -10,11 +10,17 @@ version.workspace = true[dependencies]# This crate should have *very* minimal dependencies! Don't add new ones# lightly.-wasmtime-error = { workspace = true }libm = { workspace = true }+anyhow = { workspace = true, optional = true }[lints]workspace = true[features]+# Enable the use of the `std` crate.std = []+# Enable backtraces in errors.+backtrace = ["std"]+# Enable the `From<Error> for anyhow::Error` implementation and+# `Error::from_anyhow` constructor.+anyhow = ["dep:anyhow"]diff --git a/crates/core/src/alloc.rs b/crates/core/src/alloc.rsindex dbaad07fa5..1dd2c5f103 100644--- a/crates/core/src/alloc.rs+++ b/crates/core/src/alloc.rs@@ -7,8 +7,8 @@ mod try_new;pub use boxed::{BoxedSliceFromIterError, new_boxed_slice_from_iter};pub use try_new::{TryNew, try_new};+use crate::error::OutOfMemory;use core::{alloc::Layout, ptr::NonNull};-use wasmtime_error::OutOfMemory;/// Try to allocate a block of memory that fits the given layout, or return an/// `OutOfMemory` error.diff --git a/crates/core/src/alloc/arc.rs b/crates/core/src/alloc/arc.rsindex fcd2d98750..a1166c31a9 100644--- a/crates/core/src/alloc/arc.rs+++ b/crates/core/src/alloc/arc.rs@@ -1,6 +1,6 @@use super::TryNew;+use crate::error::OutOfMemory;use std_alloc::sync::Arc;-use wasmtime_error::OutOfMemory;/// XXX: Stable Rust doesn't actually give us any method to build fallible/// allocation for `Arc<T>`, so this is only actually fallible when usingdiff --git a/crates/core/src/alloc/boxed.rs b/crates/core/src/alloc/boxed.rsindex 65483f4112..840e063fc7 100644--- a/crates/core/src/alloc/boxed.rs+++ b/crates/core/src/alloc/boxed.rs@@ -1,7 +1,7 @@use super::{TryNew, try_alloc};+use crate::error::OutOfMemory;use core::{alloc::Layout, mem::MaybeUninit};use std_alloc::boxed::Box;-use wasmtime_error::OutOfMemory;/// Allocate an `Box<MaybeUninit<T>>` with uninitialized contents, returning/// `Err(OutOfMemory)` on allocation failure.diff --git a/crates/core/src/alloc/try_new.rs b/crates/core/src/alloc/try_new.rsindex 9c3487e37e..1e1a6f0106 100644--- a/crates/core/src/alloc/try_new.rs+++ b/crates/core/src/alloc/try_new.rs@@ -1,4 +1,4 @@-use wasmtime_error::OutOfMemory;+use crate::error::OutOfMemory;/// Helper function to invoke `<T as TryNew>::try_new`.///@@ -6,7 +6,7 @@ use wasmtime_error::OutOfMemory;////// ```/// # use wasmtime_internal_core::alloc::*;-/// # use wasmtime_error::Result;+/// # use wasmtime_internal_core::error::Result;/// # fn _foo() -> Result<()> {/// let boxed = try_new::<Box<u32>>(36)?;/// assert_eq!(*boxed, 36);diff --git a/crates/error/src/backtrace.rs b/crates/core/src/error/backtrace.rssimilarity index 100%rename from crates/error/src/backtrace.rsrename to crates/core/src/error/backtrace.rsdiff --git a/crates/error/src/boxed.rs b/crates/core/src/error/boxed.rssimilarity index 88%rename from crates/error/src/boxed.rsrename to crates/core/src/error/boxed.rsindex 7d84aebc2e..81f29f3fa0 100644--- a/crates/error/src/boxed.rs+++ b/crates/core/src/error/boxed.rs@@ -1,8 +1,8 @@use super::{OutOfMemory, Result};-use alloc::boxed::Box;use core::alloc::Layout;use core::mem::MaybeUninit;use core::ptr::NonNull;+use std_alloc::boxed::Box;/// Try to allocate a block of memory that fits the given layout, or return an/// `OutOfMemory` error.@@ -14,7 +14,7 @@ use core::ptr::NonNull;pub(crate) unsafe fn try_alloc(layout: Layout) -> Result<NonNull<u8>, OutOfMemory> {// Safety: same as our safety conditions.debug_assert!(layout.size() > 0);- let ptr = unsafe { alloc::alloc::alloc(layout) };+ let ptr = unsafe { std_alloc::alloc::alloc(layout) };if let Some(ptr) = NonNull::new(ptr) {Ok(ptr)@@ -26,7 +26,7 @@ pub(crate) unsafe fn try_alloc(layout: Layout) -> Result<NonNull<u8>, OutOfMemor/// Create a `Box<T>`, or return an `OutOfMemory` error.#[inline]pub(crate) fn try_new_uninit_box<T>() -> Result<Box<MaybeUninit<T>>, OutOfMemory> {- let layout = alloc::alloc::Layout::new::<MaybeUninit<T>>();+ let layout = std_alloc::alloc::Layout::new::<MaybeUninit<T>>();if layout.size() == 0 {// NB: no actual allocation takes place when boxing zero-sized types.diff --git a/crates/error/src/context.rs b/crates/core/src/error/context.rssimilarity index 97%rename from crates/error/src/context.rsrename to crates/core/src/error/context.rsindex 40465aae70..7357cb9cc8 100644--- a/crates/error/src/context.rs+++ b/crates/core/src/error/context.rs@@ -1,12 +1,12 @@-use crate::{+use crate::error::{Error, ErrorExt, OutOfMemory, Result,boxed::try_new_uninit_box,error::{OomOrDynError, OomOrDynErrorMut, OomOrDynErrorRef},};-use alloc::boxed::Box;use core::any::TypeId;use core::fmt;use core::ptr::NonNull;+use std_alloc::boxed::Box;mod sealed {use super::*;@@ -35,10 +35,10 @@ mod sealed {/// # Example////// ```-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::{Context as _, Result};/// # #[cfg(feature = "backtrace")]-/// # wasmtime_internal_error::disable_backtrace();+/// # wasmtime_internal_core::error::disable_backtrace();////// fn u32_to_u8(x: u32) -> Result<u8> {/// let y = u8::try_from(x).with_context(|| {@@ -84,8 +84,8 @@ mod sealed {/// fallible function returns an `Option`:////// ```-/// # use wasmtime_internal_error as wasmtime;-/// use wasmtime::{Context as _, Result};+/// # use wasmtime_internal_core as wasmtime;+/// use wasmtime::error::{Context as _, Result};////// fn try_get<T>(slice: &[T], i: usize) -> Result<&T> {/// let elem: Option<&T> = slice.get(i);diff --git a/crates/error/src/error.rs b/crates/core/src/error/error.rssimilarity index 97%rename from crates/error/src/error.rsrename to crates/core/src/error/error.rsindex 136461b587..29f03639bd 100644--- a/crates/error/src/error.rs+++ b/crates/core/src/error/error.rs@@ -2,8 +2,7 @@ use super::boxed::try_new_uninit_box;use super::context::ContextError;use super::ptr::{MutPtr, OwnedPtr, SharedPtr};use super::vtable::Vtable;-use crate::{OutOfMemory, Result};-use alloc::boxed::Box;+use crate::error::{OutOfMemory, Result};use core::{any::TypeId,fmt::{self, Debug},@@ -13,6 +12,7 @@ use core::{};#[cfg(feature = "backtrace")]use std::backtrace::{Backtrace, BacktraceStatus};+use std_alloc::boxed::Box;/// Internal extension trait for errors.///@@ -146,7 +146,7 @@ impl BoxedDynError {#[cfg(feature = "backtrace")]let backtrace = match error.take_backtrace() {Some(bt) => bt,- None => crate::backtrace::capture(),+ None => crate::error::backtrace::capture(),};let boxed = try_new_uninit_box()?;@@ -241,7 +241,7 @@ impl BoxedDynError {/// early-returns an error unconditionally.////// ```-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::{bail, ensure, Result};////// fn my_fallible_function(x: u32) -> Result<()> {@@ -263,7 +263,7 @@ impl BoxedDynError {/// [`format_err!`][crate::format_err] macro is preferred:////// ```-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::{format_err, Error};////// let x = 42;@@ -274,7 +274,7 @@ impl BoxedDynError {/// macro, you can use either [`Error::new`] or [`Error::msg`]:////// ```-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::Error;////// let messages = ["yikes", "uh oh", "ouch"];@@ -314,8 +314,8 @@ impl BoxedDynError {/// # fn _foo() {/// #![cfg(all(feature = "backtrace", not(miri)))]/// # let _ = unsafe { std::env::set_var("RUST_BACKTRACE", "1") };-/// # use wasmtime_internal_error as wasmtime;-/// use wasmtime::{bail, Context as _, Result};+/// # use wasmtime_internal_core as wasmtime;+/// use wasmtime::error::{bail, Context as _, Result};////// fn uno() -> Result<()> {/// bail!("ouch")@@ -378,7 +378,7 @@ impl BoxedDynError {/// ```/// # fn _foo() {/// #![cfg(feature = "anyhow")]-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;////// fn foo() -> Result<(), wasmtime::Error> {/// wasmtime::bail!("decontamination failure")@@ -405,7 +405,7 @@ impl BoxedDynError {/// ```/// # fn _foo() {/// #![cfg(feature = "anyhow")]-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;////// fn baz() -> Result<(), anyhow::Error> {/// anyhow::bail!("oops I ate worms")@@ -522,7 +522,7 @@ impl From<Error> for Box<dyn core::error::Error + 'static> {/// # Example////// ```-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// let wasmtime_error = wasmtime::Error::msg("whoops");/// let anyhow_error = anyhow::Error::from(wasmtime_error);/// ```@@ -582,7 +582,7 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::Error;////// let error = Error::new(std::fmt::Error);@@ -621,7 +621,7 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::Error;////// let error = Error::msg("hello");@@ -653,7 +653,7 @@ impl Error {/// ```/// # fn _foo() {/// #![cfg(all(feature = "std", feature = "anyhow"))]- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// use std::error::Error;////// // You happen to have a boxed error trait object.@@ -682,7 +682,7 @@ impl Error {/// ```/// # fn _foo() {/// #![cfg(all(feature = "std", feature = "anyhow"))]- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// let anyhow_error = anyhow::Error::msg("failed to flim the flam");/// let wasmtime_error = wasmtime::Error::from_anyhow(anyhow_error);/// assert_eq!(@@ -718,7 +718,7 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::Error;////// let error = Error::msg("root cause");@@ -786,7 +786,7 @@ impl Error {/// ```/// # fn _foo() {/// #![cfg(feature = "backtrace")]- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// use std::backtrace::BacktraceStatus;/// use wasmtime::Error;///@@ -814,7 +814,7 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::Error;////// let error = Error::msg("root cause");@@ -837,7 +837,7 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::Error;////// let error = Error::msg("ghosts");@@ -861,8 +861,8 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;- /// use wasmtime::{Error, OutOfMemory};+ /// # use wasmtime_internal_core as wasmtime;+ /// use wasmtime::error::{Error, OutOfMemory};////// let oom = Error::from(OutOfMemory::new(1234));/// assert!(oom.is::<OutOfMemory>());@@ -911,8 +911,8 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;- /// use wasmtime::{Error, OutOfMemory};+ /// # use wasmtime_internal_core as wasmtime;+ /// use wasmtime::error::{Error, OutOfMemory};////// let error = Error::msg("whoops");///@@ -971,8 +971,8 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;- /// use wasmtime::{Error, OutOfMemory};+ /// # use wasmtime_internal_core as wasmtime;+ /// use wasmtime::error::{Error, OutOfMemory};////// let error = Error::msg("whoops");///@@ -1038,8 +1038,8 @@ impl Error {/// # Example////// ```- /// # use wasmtime_internal_error as wasmtime;- /// use wasmtime::{Error, OutOfMemory};+ /// # use wasmtime_internal_core as wasmtime;+ /// use wasmtime::error::{Error, OutOfMemory};////// let mut error = Error::msg("whoops");///@@ -1143,7 +1143,7 @@ impl Error {/// }/// }///- /// # use wasmtime_internal_error as wasmtime;+ /// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::Error;////// // Create an `Error`.diff --git a/crates/error/src/macros.rs b/crates/core/src/error/macros.rssimilarity index 92%rename from crates/error/src/macros.rsrename to crates/core/src/error/macros.rsindex 3d4c789783..227d2fb52b 100644--- a/crates/error/src/macros.rs+++ b/crates/core/src/error/macros.rs@@ -6,8 +6,8 @@ pub use core::format_args;pub use core::result::Result::Err;use super::{Error, OutOfMemory};-use alloc::string::String;use core::fmt::{self, write};+use std_alloc::string::String;/// Construct an [`Error`](crate::Error) via string formatting or another error.///@@ -20,7 +20,7 @@ use core::fmt::{self, write};/// string template and the rest of the arguments are format arguments:////// ```-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::{format_err, Error};////// let x = 42;@@ -44,7 +44,7 @@ use core::fmt::{self, write};/// ```/// # fn _foo() {/// #![cfg(feature = "std")]-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use std::fmt;/// use wasmtime::{format_err, Error};///@@ -75,7 +75,7 @@ use core::fmt::{self, write};/// ```/// # fn _foo() {/// #![cfg(feature = "anyhow")]-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::format_err;////// let anyhow_error: anyhow::Error = anyhow::anyhow!("aw crap");@@ -87,18 +87,18 @@ use core::fmt::{self, write};macro_rules! format_err {// Format-style invocation without explicit format arguments.( $message:literal $(,)? ) => {- $crate::Error::from_format_args($crate::macros::format_args!($message))+ $crate::error::Error::from_format_args($crate::error::macros::format_args!($message))};// Format-style invocation with explicit format arguments.( $message:literal , $( $args:tt )* ) => {- $crate::Error::from_format_args($crate::macros::format_args!($message , $( $args )* ))+ $crate::error::Error::from_format_args($crate::error::macros::format_args!($message , $( $args )* ))};// Do either `Error::new($error)` or `Error::msg($error)` depending on// whether `$error` implements `core::error::Error` or not.( $error:expr $(,)? ) => {{- use $crate::macros::ctor_specialization::*;+ use $crate::error::macros::ctor_specialization::*;let error = $error;(&&&error).wasmtime_error_choose_ctor().construct(error)}};@@ -112,7 +112,7 @@ macro_rules! format_err {#[deprecated = "Use `format_err!(...)` instead"]macro_rules! anyhow {( $( $args:tt )* ) => {- $crate::format_err!( $( $args )* )+ $crate::error::format_err!( $( $args )* )};}@@ -128,7 +128,7 @@ macro_rules! anyhow {/// # Example////// ```-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::{bail, Result};////// fn error_on_none(option: Option<u32>) -> Result<u32> {@@ -150,7 +150,7 @@ macro_rules! anyhow {#[macro_export]macro_rules! bail {( $($args:tt)* ) => {{- return $crate::macros::Err($crate::format_err!( $( $args )* ));+ return $crate::error::macros::Err($crate::error::format_err!( $( $args )* ));}};}@@ -170,7 +170,7 @@ macro_rules! bail {/// # Example////// ```rust-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::{ensure, Result};////// fn checked_div(a: u32, b: u32) -> Result<u32> {@@ -190,12 +190,12 @@ macro_rules! bail {#[macro_export]macro_rules! ensure {( $condition:expr ) => {{- $crate::ensure!($condition, concat!("Condition failed: `", stringify!($condition), "`"))+ $crate::error::ensure!($condition, concat!("Condition failed: `", stringify!($condition), "`"))}};( $condition:expr , $( $args:tt )* ) => {{- if $crate::macros::ensure::not($condition) {- $crate::bail!( $( $args )* );+ if $crate::error::macros::ensure::not($condition) {+ $crate::error::bail!( $( $args )* );}}};}diff --git a/crates/error/src/lib.rs b/crates/core/src/error/mod.rssimilarity index 78%rename from crates/error/src/lib.rsrename to crates/core/src/error/mod.rsindex bc9ebfea81..44cb531a19 100644--- a/crates/error/src/lib.rs+++ b/crates/core/src/error/mod.rs@@ -1,20 +1,10 @@-//! Wasmtime's universal error handling crate.+//! Wasmtime's universal error handling types.//!//! 99% API-compatible with `anyhow`, but additionally handles out-of-memory//! errors, instead of aborting the process.//!//! See the [`Error`] documentation for more details.-#![no_std]-#![deny(missing_docs)]-#![doc(test(attr(deny(warnings))))]-#![doc(test(attr(allow(dead_code, unused_variables, unused_mut))))]-#![cfg_attr(docsrs, feature(doc_cfg))]--extern crate alloc;-#[cfg(feature = "std")]-extern crate std;-#[cfg(feature = "backtrace")]mod backtrace;mod boxed;@@ -29,6 +19,7 @@ mod vtable;#[doc(hidden)]pub mod macros;+pub use crate::{bail, ensure, format_err};#[cfg(feature = "backtrace")]pub use backtrace::disable_backtrace;pub use context::Context;diff --git a/crates/error/src/oom.rs b/crates/core/src/error/oom.rssimilarity index 95%rename from crates/error/src/oom.rsrename to crates/core/src/error/oom.rsindex 1e865f68e6..aeac66b4c5 100644--- a/crates/error/src/oom.rs+++ b/crates/core/src/error/oom.rs@@ -1,4 +1,4 @@-use crate::error::OomOrDynError;+use crate::error::{Error, OomOrDynError};use core::{fmt, mem, ptr::NonNull};/// Out-of-memory error.@@ -63,9 +63,9 @@ impl OutOfMemory {const _SAME_ALIGN_AS_OOM_OR_DYN_ERROR: () =assert!(mem::align_of::<OutOfMemory>() == mem::align_of::<OomOrDynError>());const _SAME_SIZE_AS_ERROR: () =- assert!(mem::size_of::<OutOfMemory>() == mem::size_of::<crate::Error>());+ assert!(mem::size_of::<OutOfMemory>() == mem::size_of::<Error>());const _SAME_ALIGN_AS_ERROR: () =- assert!(mem::align_of::<OutOfMemory>() == mem::align_of::<crate::Error>());+ assert!(mem::align_of::<OutOfMemory>() == mem::align_of::<Error>());/// Construct a new `OutOfMemory` error.///@@ -77,7 +77,7 @@ impl OutOfMemory {/// # Example////// ```rust- /// # use wasmtime_internal_error::OutOfMemory;+ /// # use wasmtime_internal_core::error::OutOfMemory;/// # extern crate alloc;/// use alloc::alloc::{Layout, alloc};/// use core::ptr::NonNull;@@ -118,7 +118,7 @@ impl OutOfMemory {/// # Example////// ```rust- /// # use wasmtime_internal_error::OutOfMemory;+ /// # use wasmtime_internal_core::error::OutOfMemory;/// let oom = OutOfMemory::new(8192);/// assert_eq!(oom.requested_allocation_size(), 8192);/// ```diff --git a/crates/error/src/ptr.rs b/crates/core/src/error/ptr.rssimilarity index 99%rename from crates/error/src/ptr.rsrename to crates/core/src/error/ptr.rsindex a68901a59d..2854395005 100644--- a/crates/error/src/ptr.rs+++ b/crates/core/src/error/ptr.rs@@ -2,8 +2,8 @@//! various places instead of safe references because our type-punning would//! trigger UB otherwise.-use alloc::boxed::Box;use core::{marker::PhantomData, ptr::NonNull};+use std_alloc::boxed::Box;/// A raw, owned pointer.///diff --git a/crates/error/src/to_wasmtime_result.rs b/crates/core/src/error/to_wasmtime_result.rssimilarity index 90%rename from crates/error/src/to_wasmtime_result.rsrename to crates/core/src/error/to_wasmtime_result.rsindex 07cf3a2ca8..13b33d63de 100644--- a/crates/error/src/to_wasmtime_result.rs+++ b/crates/core/src/error/to_wasmtime_result.rs@@ -1,4 +1,4 @@-use crate::Result;+use crate::error::{Error, Result};/// Extension trait for easily converting `anyhow::Result`s into/// `wasmtime::Result`s.@@ -14,7 +14,7 @@ use crate::Result;/// ```/// # fn _foo() {/// #![cfg(feature = "anyhow")]-/// # use wasmtime_internal_error as wasmtime;+/// # use wasmtime_internal_core::error as wasmtime;/// use wasmtime::ToWasmtimeResult as _;////// fn returns_anyhow_result() -> anyhow::Result<u32> {@@ -45,7 +45,7 @@ impl<T> ToWasmtimeResult<T> for anyhow::Result<T> {fn to_wasmtime_result(self) -> Result<T> {match self {Ok(x) => Ok(x),- Err(e) => Err(crate::Error::from_anyhow(e)),+ Err(e) => Err(Error::from_anyhow(e)),}}}diff --git a/crates/error/src/vtable.rs b/crates/core/src/error/vtable.rssimilarity index 96%rename from crates/error/src/vtable.rsrename to crates/core/src/error/vtable.rsindex a46d3d415d..7e8e64d22b 100644--- a/crates/error/src/vtable.rs+++ b/crates/core/src/error/vtable.rs@@ -1,7 +1,9 @@-use super::{ConcreteError, DynError, ErrorExt, OomOrDynErrorMut, OomOrDynErrorRef, OutOfMemory};-use crate::ptr::{MutPtr, OwnedPtr, SharedPtr};-use alloc::boxed::Box;+use crate::error::ptr::{MutPtr, OwnedPtr, SharedPtr};+use crate::error::{+ ConcreteError, DynError, ErrorExt, OomOrDynErrorMut, OomOrDynErrorRef, OutOfMemory,+};use core::{any::TypeId, fmt, ptr::NonNull};+use std_alloc::boxed::Box;/// A vtable containing the `ErrorExt` methods for some type `T`.///diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rsindex 60cbb99344..1ac1378193 100644--- a/crates/core/src/lib.rs+++ b/crates/core/src/lib.rs@@ -9,6 +9,9 @@#![deny(missing_docs)]#![cfg_attr(arc_try_new, allow(unstable_features))]#![cfg_attr(arc_try_new, feature(allocator_api))]+#![cfg_attr(docsrs, feature(doc_cfg))]+#![doc(test(attr(deny(warnings))))]+#![doc(test(attr(allow(dead_code, unused_variables, unused_mut))))]extern crate alloc as std_alloc;@@ -16,5 +19,6 @@ extern crate alloc as std_alloc;extern crate std;pub mod alloc;+pub mod error;pub mod math;pub mod slab;diff --git a/crates/core/src/slab.rs b/crates/core/src/slab.rsindex eba9848cc0..2b733dba48 100644--- a/crates/core/src/slab.rs+++ b/crates/core/src/slab.rs@@ -14,7 +14,7 @@//! # Example//!//! ```-//! use wasmtime_internal_core::slab::{Id, Slab};+//! use wasmtime_internal_core::slab::Slab;//!//! let mut slab = Slab::new();//!diff --git a/crates/error/tests/tests.rs b/crates/core/tests/tests.rssimilarity index 99%rename from crates/error/tests/tests.rsrename to crates/core/tests/tests.rsindex b8f73928b0..39a5b1666d 100644--- a/crates/error/tests/tests.rs+++ b/crates/core/tests/tests.rs@@ -13,7 +13,9 @@ use core::{};#[cfg(feature = "std")]use std::backtrace::BacktraceStatus;-use wasmtime_internal_error::{Context, Error, OutOfMemory, Result, bail, ensure, format_err};+use wasmtime_internal_core::error::{+ Context, Error, OutOfMemory, Result, bail, ensure, format_err,+};#[derive(Debug)]struct TestError(u32);diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.tomlindex 1cccb96322..daffb47cd5 100644--- a/crates/environ/Cargo.toml+++ b/crates/environ/Cargo.toml@@ -36,7 +36,6 @@ wasm-encoder = { workspace = true, optional = true }wasmprinter = { workspace = true, optional = true }wasmtime-component-util = { workspace = true, optional = true }wasmtime-core = { workspace = true }-wasmtime-error = { workspace = true }semver = { workspace = true, optional = true, features = ['serde'] }smallvec = { workspace = true, features = ['serde'] }@@ -57,8 +56,8 @@ name = "factc"required-features = ['component-model', 'compile'][features]-anyhow = ["wasmtime-error/anyhow"]-backtrace = ["std", "wasmtime-error/backtrace"]+anyhow = ["wasmtime-core/anyhow"]+backtrace = ["std", "wasmtime-core/backtrace"]component-model = ["dep:wasmtime-component-util","dep:semver",@@ -83,5 +82,5 @@ std = ['object/std','wasmparser/std','indexmap/std',- 'wasmtime-error/std',+ 'wasmtime-core/std',]diff --git a/crates/environ/src/collections/entity_set.rs b/crates/environ/src/collections/entity_set.rsindex 3fbef14ac1..5eac9c2438 100644--- a/crates/environ/src/collections/entity_set.rs+++ b/crates/environ/src/collections/entity_set.rs@@ -1,5 +1,5 @@use cranelift_entity::{EntityRef, Keys, SetIter};-use wasmtime_error::OutOfMemory;+use wasmtime_core::error::OutOfMemory;/// Like `cranelift_entity::EntitySet` but enforces fallible allocation for all/// methods that allocate.diff --git a/crates/environ/src/collections/primary_map.rs b/crates/environ/src/collections/primary_map.rsindex a3778d428e..5b46458f1c 100644--- a/crates/environ/src/collections/primary_map.rs+++ b/crates/environ/src/collections/primary_map.rs@@ -1,6 +1,6 @@use core::ops::{Index, IndexMut};use cranelift_entity::EntityRef;-use wasmtime_error::OutOfMemory;+use wasmtime_core::error::OutOfMemory;/// Like [`cranelift_entity::PrimaryMap`] but enforces fallible allocation for/// all methods that allocate.diff --git a/crates/environ/src/lib.rs b/crates/environ/src/lib.rsindex 2694f78b6b..b37dd9dd91 100644--- a/crates/environ/src/lib.rs+++ b/crates/environ/src/lib.rs@@ -81,12 +81,12 @@ pub mod fact;// one of three and making sure you're using the right one.pub use cranelift_entity::*;-// Reexport the error crate as a submodule for convenience.+// Reexport the error module for convenience.#[doc(inline)]-pub use wasmtime_error as error;+pub use wasmtime_core::error;#[cfg(feature = "anyhow")]-pub use wasmtime_error::ToWasmtimeResult;+pub use self::error::ToWasmtimeResult;// Only for use with `bindgen!`-generated code.#[doc(hidden)]diff --git a/crates/error/Cargo.toml b/crates/error/Cargo.tomldeleted file mode 100644index b900cd2542..0000000000--- a/crates/error/Cargo.toml+++ /dev/null@@ -1,23 +0,0 @@-[package]-authors.workspace = true-description = "INTERNAL: Wasmtime's universal error type's implementation"-edition.workspace = true-license = "Apache-2.0 WITH LLVM-exception"-name = "wasmtime-internal-error"-rust-version.workspace = true-version.workspace = true--[dependencies]-anyhow = { workspace = true, optional = true }--[lints]-workspace = true--[features]-# Enable the use of the `std` crate.-std = []-# Enable backtraces.-backtrace = ["std"]-# Enable the `From<Error> for anyhow::Error` implementation and-# `Error::from_anyhow` constructor.-anyhow = ["dep:anyhow"]diff --git a/crates/fuzzing/Cargo.toml b/crates/fuzzing/Cargo.tomlindex ad631c6cc4..148c01b3f2 100644--- a/crates/fuzzing/Cargo.toml+++ b/crates/fuzzing/Cargo.toml@@ -28,7 +28,7 @@ wasmparser = { workspace = true }wasmprinter = { workspace = true }wasmtime-wast = { workspace = true, features = ['component-model'] }wasmtime = { workspace = true, features = ['default', 'winch'] }-wasmtime-error = { workspace = true, features = ['backtrace'] }+wasmtime-core = { workspace = true, features = ['backtrace'] }wasm-encoder = { workspace = true }wasm-smith = { workspace = true, features = ['serde'] }wasm-mutate = { workspace = true }diff --git a/crates/fuzzing/src/oom.rs b/crates/fuzzing/src/oom.rsindex bd367adbff..b8741563b6 100644--- a/crates/fuzzing/src/oom.rs+++ b/crates/fuzzing/src/oom.rs@@ -5,7 +5,7 @@use backtrace::Backtrace;use std::{alloc::GlobalAlloc, cell::Cell, mem, ptr, time};-use wasmtime_error::{Error, OutOfMemory, Result, bail};+use wasmtime_core::error::{Error, OutOfMemory, Result, bail};/// An allocator for use with `OomTest`.#[non_exhaustive]@@ -161,7 +161,7 @@ impl OomTest {// NB: `std::backtrace::Backtrace` doesn't have ways to handle// OOM. Ideally we would just disable the `"backtrace"` cargo feature,// but workspace feature resolution doesn't play nice with that.- wasmtime_error::disable_backtrace();+ wasmtime_core::error::disable_backtrace();OomTest {max_iters: None,diff --git a/scripts/publish.rs b/scripts/publish.rsindex f44871fe80..3bbb1cdc1d 100644--- a/scripts/publish.rs+++ b/scripts/publish.rs@@ -17,10 +17,9 @@ use std::time::Duration;// note that this list must be topologically sorted by dependenciesconst CRATES_TO_PUBLISH: &[&str] = &[- // pulley- "wasmtime-internal-error","wasmtime-internal-core","cranelift-bitset",+ // pulley"pulley-macros","pulley-interpreter",// craneliftdiff --git a/supply-chain/config.toml b/supply-chain/config.tomlindex 52a82f1a6c..16dcf6f3fa 100644--- a/supply-chain/config.toml+++ b/supply-chain/config.toml@@ -148,9 +148,6 @@ audit-as-crates-io = true[policy.wasmtime-internal-debugger]audit-as-crates-io = true-[policy.wasmtime-internal-error]-audit-as-crates-io = true-[policy.wasmtime-internal-explorer]audit-as-crates-io = truediff --git a/supply-chain/imports.lock b/supply-chain/imports.lockindex 64abe8c8be..4e6b138468 100644--- a/supply-chain/imports.lock+++ b/supply-chain/imports.lock@@ -1311,13 +1311,6 @@ version = "41.0.0"when = "2026-01-20"trusted-publisher = "github:bytecodealliance/wasmtime"-[[publisher.wasmtime-internal-error]]-version = "0.0.0"-when = "2025-12-16"-user-id = 696-user-login = "fitzgen"-user-name = "Nick Fitzgerald"-[[publisher.wasmtime-internal-explorer]]version = "40.0.1"when = "2026-01-07"