From 3d64cefe100f5ccc96e45c92004e76bdc0664e2a Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 18 Jan 2025 14:23:52 +0800 Subject: [PATCH] feat(allocator): add `Send` + `Sync` to `HashMap` --- crates/oxc_allocator/src/hash_map.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/oxc_allocator/src/hash_map.rs b/crates/oxc_allocator/src/hash_map.rs index acc5ce8bf..094284968 100644 --- a/crates/oxc_allocator/src/hash_map.rs +++ b/crates/oxc_allocator/src/hash_map.rs @@ -50,6 +50,11 @@ type FxHashMap<'alloc, K, V> = hashbrown::HashMap(ManuallyDrop>); +/// SAFETY: Not actually safe, but for enabling `Send` for downstream crates. +unsafe impl Send for HashMap<'_, K, V> {} +/// SAFETY: Not actually safe, but for enabling `Sync` for downstream crates. +unsafe impl Sync for HashMap<'_, K, V> {} + // TODO: `IntoIter`, `Drain`, and other consuming iterators provided by `hashbrown` are `Drop`. // Wrap them in `ManuallyDrop` to prevent that.