Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/environ/src/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod secondary_map;
pub use btree_map::BTreeMap;
pub use entity_set::TryEntitySet;
pub use hash_map::TryHashMap;
pub use hash_set::HashSet;
pub use hash_set::TryHashSet;
pub use index_map::IndexMap;
pub use primary_map::PrimaryMap;
pub use secondary_map::SecondaryMap;
Expand Down
18 changes: 9 additions & 9 deletions crates/environ/src/collections/hash_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use hashbrown::{DefaultHashBuilder, hash_set as inner};

/// A wrapper type around [`hashbrown::hash_set::HashSet`] that only exposes
/// fallible allocation.
pub struct HashSet<T, S = DefaultHashBuilder> {
pub struct TryHashSet<T, S = DefaultHashBuilder> {
inner: inner::HashSet<T, S>,
}

impl<T, S> Default for HashSet<T, S>
impl<T, S> Default for TryHashSet<T, S>
where
S: Default,
{
Expand All @@ -28,7 +28,7 @@ where
}
}

impl<T, S> PartialEq for HashSet<T, S>
impl<T, S> PartialEq for TryHashSet<T, S>
where
T: Eq + Hash,
S: BuildHasher,
Expand All @@ -38,14 +38,14 @@ where
}
}

impl<T, S> Eq for HashSet<T, S>
impl<T, S> Eq for TryHashSet<T, S>
where
T: Eq + Hash,
S: BuildHasher,
{
}

impl<T, S> fmt::Debug for HashSet<T, S>
impl<T, S> fmt::Debug for TryHashSet<T, S>
where
T: fmt::Debug,
{
Expand All @@ -54,7 +54,7 @@ where
}
}

impl<T> HashSet<T, DefaultHashBuilder> {
impl<T> TryHashSet<T, DefaultHashBuilder> {
/// Same as [`hashbrown::hash_set::HashSet::new`].
pub fn new() -> Self {
Self {
Expand All @@ -63,7 +63,7 @@ impl<T> HashSet<T, DefaultHashBuilder> {
}
}

impl<T> HashSet<T, DefaultHashBuilder>
impl<T> TryHashSet<T, DefaultHashBuilder>
where
T: Eq + Hash,
{
Expand All @@ -76,7 +76,7 @@ where
}
}

impl<T, S> HashSet<T, S> {
impl<T, S> TryHashSet<T, S> {
/// Same as [`hashbrown::hash_set::HashSet::with_hasher`].
pub const fn with_hasher(hasher: S) -> Self {
Self {
Expand Down Expand Up @@ -131,7 +131,7 @@ impl<T, S> HashSet<T, S> {
}
}

impl<T, S> HashSet<T, S>
impl<T, S> TryHashSet<T, S>
where
T: Eq + Hash,
S: BuildHasher,
Expand Down
4 changes: 2 additions & 2 deletions crates/environ/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
//! and then `use crate::*` works as usual.

pub use crate::collections::{
TryClone, TryCollect, TryEntitySet, TryExtend, TryFromIterator, TryHashMap, TryNew, TryString,
TryToOwned, TryVec, try_new, try_vec,
TryClone, TryCollect, TryEntitySet, TryExtend, TryFromIterator, TryHashMap, TryHashSet, TryNew,
TryString, TryToOwned, TryVec, try_new, try_vec,
};
pub use crate::error::{Context, Error, Result, bail, ensure, format_err};
pub use alloc::borrow::ToOwned;
Expand Down
12 changes: 6 additions & 6 deletions crates/fuzzing/tests/oom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,26 +213,26 @@ fn try_entity_set_insert() -> Result<()> {
}

#[test]
fn hash_set_with_capacity() -> Result<()> {
fn try_hash_set_with_capacity() -> Result<()> {
OomTest::new().test(|| {
let _s = HashSet::<usize>::with_capacity(100)?;
let _s = TryHashSet::<usize>::with_capacity(100)?;
Ok(())
})
}

#[test]
fn hash_set_reserve() -> Result<()> {
fn try_hash_set_reserve() -> Result<()> {
OomTest::new().test(|| {
let mut set = HashSet::<usize>::new();
let mut set = TryHashSet::<usize>::new();
set.reserve(100)?;
Ok(())
})
}

#[test]
fn hash_set_insert() -> Result<()> {
fn try_hash_set_insert() -> Result<()> {
OomTest::new().test(|| {
let mut set = HashSet::<usize>::new();
let mut set = TryHashSet::<usize>::new();
for i in 0..1024 {
set.insert(i)?;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmtime/src/runtime/type_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use wasmtime_core::slab::{Id as SlabId, Slab};
use wasmtime_environ::{
EngineOrModuleTypeIndex, EntityRef, GcLayout, ModuleInternedTypeIndex, ModuleTypes, TypeTrace,
Undo, VMSharedTypeIndex, WasmRecGroup, WasmSubType,
collections::{HashSet, PrimaryMap, SecondaryMap, TryCow},
collections::{PrimaryMap, SecondaryMap, TryCow},
iter_entity_range,
packed_option::{PackedOption, ReservedValue},
};
Expand Down Expand Up @@ -592,7 +592,7 @@ struct TypeRegistryInner {
// registered. Before registering new rec groups, we first check this map to
// see if we've already registered an identical rec group that we should
// reuse instead.
hash_consing_map: HashSet<RecGroupEntry>,
hash_consing_map: TryHashSet<RecGroupEntry>,

// A map from `VMSharedTypeIndex::bits()` to the type index's associated
// Wasm type.
Expand Down