Skip to content

Commit

Permalink
feat(allocator): add Send + Sync to HashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jan 18, 2025
1 parent 6c4081e commit 3d64cef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/oxc_allocator/src/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ type FxHashMap<'alloc, K, V> = hashbrown::HashMap<K, V, FxBuildHasher, &'alloc B
/// [`FxHasher`]: rustc_hash::FxHasher
pub struct HashMap<'alloc, K, V>(ManuallyDrop<FxHashMap<'alloc, K, V>>);

/// SAFETY: Not actually safe, but for enabling `Send` for downstream crates.
unsafe impl<K, V> Send for HashMap<'_, K, V> {}
/// SAFETY: Not actually safe, but for enabling `Sync` for downstream crates.
unsafe impl<K, V> Sync for HashMap<'_, K, V> {}

// TODO: `IntoIter`, `Drain`, and other consuming iterators provided by `hashbrown` are `Drop`.
// Wrap them in `ManuallyDrop` to prevent that.

Expand Down

0 comments on commit 3d64cef

Please sign in to comment.