diff --git a/compiler/collections/src/all.rs b/compiler/collections/src/all.rs index a50a8febcb..6e33aaaa5a 100644 --- a/compiler/collections/src/all.rs +++ b/compiler/collections/src/all.rs @@ -30,6 +30,26 @@ pub type SendSet = im::hashset::HashSet; pub type BumpMap<'a, K, V> = hashbrown::HashMap>; +pub trait BumpMapDefault<'a> { + fn new_in(arena: &'a bumpalo::Bump) -> Self; + + fn with_capacity_in(capacity: usize, arena: &'a bumpalo::Bump) -> Self; +} + +impl<'a, K, V> BumpMapDefault<'a> for BumpMap<'a, K, V> { + fn new_in(arena: &'a bumpalo::Bump) -> Self { + hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(arena)) + } + + fn with_capacity_in(capacity: usize, arena: &'a bumpalo::Bump) -> Self { + hashbrown::HashMap::with_capacity_and_hasher_in( + capacity, + default_hasher(), + hashbrown::BumpWrapper(arena), + ) + } +} + pub fn arena_join<'a, I>(arena: &'a Bump, strings: &mut I, join_str: &str) -> String<'a> where I: Iterator, diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index a04da8c89d..a6f8fdf6e8 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -6,7 +6,7 @@ use crate::layout::{ }; use bumpalo::collections::Vec; use bumpalo::Bump; -use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet}; +use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap, MutSet}; use roc_module::ident::{ForeignSymbol, Lowercase, TagName}; use roc_module::low_level::LowLevel; use roc_module::symbol::{IdentIds, ModuleId, Symbol}; @@ -1833,8 +1833,7 @@ fn specialize_external<'a>( let host_exposed_layouts = if host_exposed_variables.is_empty() { HostExposedLayouts::NotHostExposed } else { - let mut aliases = - hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(env.arena)); + let mut aliases = BumpMap::new_in(env.arena); for (symbol, variable) in host_exposed_variables { let layout = layout_cache