A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Adjust Wasmtime's prelude/hash collections (#12509)
Alex Crichton40215f214e48
diff --git a/Cargo.lock b/Cargo.lockindex a27e9dd5e0..45a53650b3 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4518,8 +4518,6 @@ dependencies = ["futures","fxprof-processed-profile","gimli 0.33.0",- "hashbrown 0.15.2",- "indexmap 2.11.4","ittapi","libc","libtest-mimic",diff --git a/crates/environ/src/collections.rs b/crates/environ/src/collections.rsindex 9041071f49..aca49a2bd7 100644--- a/crates/environ/src/collections.rs+++ b/crates/environ/src/collections.rs@@ -10,3 +10,18 @@ pub use hash_set::HashSet;pub use primary_map::PrimaryMap;pub use secondary_map::SecondaryMap;pub use wasmtime_core::alloc::{TryNew, Vec, try_new};++/// Collections which abort on OOM.+//+// FIXME(#12069) this is just here for Wasmtime at this time. Ideally+// collections would only be fallible in this module and would handle OOM. We're+// in a bit of a transition period though.+pub mod oom_abort {+ #[cfg(not(feature = "std"))]+ pub use hashbrown::{hash_map, hash_set};+ #[cfg(feature = "std")]+ pub use std::collections::{hash_map, hash_set};++ pub use self::hash_map::HashMap;+ pub use self::hash_set::HashSet;+}diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.tomlindex f57ff712e0..7ff8525958 100644--- a/crates/wasmtime/Cargo.toml+++ b/crates/wasmtime/Cargo.toml@@ -45,7 +45,6 @@ serde = { workspace = true }serde_derive = { workspace = true }serde_json = { workspace = true, optional = true }postcard = { workspace = true }-indexmap = { workspace = true }once_cell = { version = "1.12.0", optional = true }rayon = { workspace = true, optional = true }object = { workspace = true, features = ['unaligned'] }@@ -57,7 +56,6 @@ gimli = { workspace = true, optional = true }addr2line = { workspace = true, optional = true }semver = { workspace = true, optional = true }smallvec = { workspace = true, optional = true }-hashbrown = { workspace = true, features = ["default-hasher"] }bitflags = { workspace = true }futures = { workspace = true, features = ["alloc"], optional = true }bytes = { workspace = true, optional = true }diff --git a/crates/wasmtime/src/lib.rs b/crates/wasmtime/src/lib.rsindex 3eaa8fddaf..809f21fbb4 100644--- a/crates/wasmtime/src/lib.rs+++ b/crates/wasmtime/src/lib.rs@@ -409,12 +409,15 @@extern crate std;extern crate alloc;-pub(crate) mod prelude {- pub use crate::error::{Context, Error, Result, bail, ensure, format_err};- pub use wasmtime_environ::prelude::*;-}+// Internal `use` statement which isn't used in this module but enable+// `use crate::prelude::*;` everywhere else within this crate, for example.+use wasmtime_environ::prelude;-pub(crate) use hashbrown::{hash_map, hash_set};+// FIXME(#12069) should transition to OOM-handling versions of these collections+// for all internal usage instead of using abort-on-OOM versions. Once that's+// done this can be removed and the collections should be directly imported from+// `wasmtime_environ::collections::*`.+use wasmtime_environ::collections::oom_abort::{hash_map, hash_set};/// A helper macro to safely map `MaybeUninit<T>` to `MaybeUninit<U>` where `U`/// is a field projection within `T`.