Skip to content

Commit 55dc386

Browse files
authored
Rollup merge of rust-lang#58369 - nox:sync-hash-map-entry, r=Amanieu
Make the Entry API of HashMap<K, V> Sync and Send Fixes rust-lang#45219
2 parents bf7b502 + 1fec8c2 commit 55dc386

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/libstd/collections/hash/map.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,11 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
23412341
elem: FullBucket<K, V, &'a mut RawTable<K, V>>,
23422342
}
23432343

2344+
#[stable(feature = "rust1", since = "1.0.0")]
2345+
unsafe impl<'a, K: 'a + Send, V: 'a + Send> Send for OccupiedEntry<'a, K, V> {}
2346+
#[stable(feature = "rust1", since = "1.0.0")]
2347+
unsafe impl<'a, K: 'a + Sync, V: 'a + Sync> Sync for OccupiedEntry<'a, K, V> {}
2348+
23442349
#[stable(feature= "debug_hash_map", since = "1.12.0")]
23452350
impl<K: Debug, V: Debug> Debug for OccupiedEntry<'_, K, V> {
23462351
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -2362,6 +2367,11 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> {
23622367
elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
23632368
}
23642369

2370+
#[stable(feature = "rust1", since = "1.0.0")]
2371+
unsafe impl<'a, K: 'a + Send, V: 'a + Send> Send for VacantEntry<'a, K, V> {}
2372+
#[stable(feature = "rust1", since = "1.0.0")]
2373+
unsafe impl<'a, K: 'a + Sync, V: 'a + Sync> Sync for VacantEntry<'a, K, V> {}
2374+
23652375
#[stable(feature= "debug_hash_map", since = "1.12.0")]
23662376
impl<K: Debug, V> Debug for VacantEntry<'_, K, V> {
23672377
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ fn main() {
5353
is_sync_send!(BTreeSet::<usize>::new(), union(&BTreeSet::<usize>::new()));
5454

5555
all_sync_send!(HashMap::<usize, usize>::new(), iter, iter_mut, drain, into_iter, keys, values);
56+
is_sync_send!(HashMap::<usize, usize>::new(), entry(0));
5657
all_sync_send!(HashSet::<usize>::new(), iter, drain, into_iter);
5758
is_sync_send!(HashSet::<usize>::new(), difference(&HashSet::<usize>::new()));
5859
is_sync_send!(HashSet::<usize>::new(), symmetric_difference(&HashSet::<usize>::new()));

0 commit comments

Comments
 (0)