Skip to content

Commit 6437bc8

Browse files
committed
---
yaml --- r: 232271 b: refs/heads/try c: a0d5181 h: refs/heads/master i: 232269: 275c646 232267: 8d27129 232263: 4013f21 232255: 6c34593 v: v3
1 parent 4fd2018 commit 6437bc8

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 93bb57e765bf7b3dcb8d3ac4e29d6ddf8df8f091
4+
refs/heads/try: a0d51819c382c50658cbda6440050473f306f705
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/libstd/collections/hash/table.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,9 @@ pub struct Iter<'a, K: 'a, V: 'a> {
818818
elems_left: usize,
819819
}
820820

821+
unsafe impl<'a, K: Sync, V: Sync> Sync for Iter<'a, K, V> {}
822+
unsafe impl<'a, K: Sync, V: Sync> Send for Iter<'a, K, V> {}
823+
821824
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
822825
impl<'a, K, V> Clone for Iter<'a, K, V> {
823826
fn clone(&self) -> Iter<'a, K, V> {
@@ -835,18 +838,29 @@ pub struct IterMut<'a, K: 'a, V: 'a> {
835838
elems_left: usize,
836839
}
837840

841+
unsafe impl<'a, K: Sync, V: Sync> Sync for IterMut<'a, K, V> {}
842+
// Both K: Sync and K: Send are correct for IterMut's Send impl,
843+
// but Send is the more useful bound
844+
unsafe impl<'a, K: Send, V: Send> Send for IterMut<'a, K, V> {}
845+
838846
/// Iterator over the entries in a table, consuming the table.
839847
pub struct IntoIter<K, V> {
840848
table: RawTable<K, V>,
841849
iter: RawBuckets<'static, K, V>
842850
}
843851

852+
unsafe impl<K: Sync, V: Sync> Sync for IntoIter<K, V> {}
853+
unsafe impl<K: Send, V: Send> Send for IntoIter<K, V> {}
854+
844855
/// Iterator over the entries in a table, clearing the table.
845856
pub struct Drain<'a, K: 'a, V: 'a> {
846857
table: &'a mut RawTable<K, V>,
847858
iter: RawBuckets<'static, K, V>,
848859
}
849860

861+
unsafe impl<'a, K: Sync, V: Sync> Sync for Drain<'a, K, V> {}
862+
unsafe impl<'a, K: Send, V: Send> Send for Drain<'a, K, V> {}
863+
850864
impl<'a, K, V> Iterator for Iter<'a, K, V> {
851865
type Item = (&'a K, &'a V);
852866

branches/try/src/test/run-pass/sync-send-iterators-in-libcollections.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ use collections::String;
2525
use collections::Vec;
2626
use collections::VecDeque;
2727
use collections::VecMap;
28+
use std::collections::HashMap;
29+
use std::collections::HashSet;
2830

2931
use collections::Bound::Included;
3032
use collections::enum_set::CLike;
@@ -77,6 +79,13 @@ fn main() {
7779
is_sync_send!(BTreeSet::<usize>::new(), intersection(&BTreeSet::<usize>::new()));
7880
is_sync_send!(BTreeSet::<usize>::new(), union(&BTreeSet::<usize>::new()));
7981

82+
all_sync_send!(HashMap::<usize, usize>::new(), iter, iter_mut, drain, into_iter, keys, values);
83+
all_sync_send!(HashSet::<usize>::new(), iter, drain, into_iter);
84+
is_sync_send!(HashSet::<usize>::new(), difference(&HashSet::<usize>::new()));
85+
is_sync_send!(HashSet::<usize>::new(), symmetric_difference(&HashSet::<usize>::new()));
86+
is_sync_send!(HashSet::<usize>::new(), intersection(&HashSet::<usize>::new()));
87+
is_sync_send!(HashSet::<usize>::new(), union(&HashSet::<usize>::new()));
88+
8089
all_sync_send!(LinkedList::<usize>::new(), iter, iter_mut, into_iter);
8190

8291
#[derive(Copy, Clone)]

0 commit comments

Comments
 (0)