Skip to content

Commit 3d64cef

Browse files
committed
feat(allocator): add Send + Sync to HashMap
1 parent 6c4081e commit 3d64cef

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

crates/oxc_allocator/src/hash_map.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ type FxHashMap<'alloc, K, V> = hashbrown::HashMap<K, V, FxBuildHasher, &'alloc B
5050
/// [`FxHasher`]: rustc_hash::FxHasher
5151
pub struct HashMap<'alloc, K, V>(ManuallyDrop<FxHashMap<'alloc, K, V>>);
5252

53+
/// SAFETY: Not actually safe, but for enabling `Send` for downstream crates.
54+
unsafe impl<K, V> Send for HashMap<'_, K, V> {}
55+
/// SAFETY: Not actually safe, but for enabling `Sync` for downstream crates.
56+
unsafe impl<K, V> Sync for HashMap<'_, K, V> {}
57+
5358
// TODO: `IntoIter`, `Drain`, and other consuming iterators provided by `hashbrown` are `Drop`.
5459
// Wrap them in `ManuallyDrop` to prevent that.
5560

0 commit comments

Comments
 (0)