Skip to content

Commit 6973686

Browse files
---
yaml --- r: 227198 b: refs/heads/auto c: f2f4a5c h: refs/heads/master v: v3
1 parent 9a5c84d commit 6973686

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: a4e4233828f0a8cb30278245d53dcb25b2e26a01
11+
refs/heads/auto: f2f4a5c8621811c81d98f567e2505017aea94bce
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/libstd/collections/hash/set.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use borrow::Borrow;
1212
use clone::Clone;
1313
use cmp::{Eq, PartialEq};
14-
use core::marker::{Sized, Send, Sync};
14+
use core::marker::Sized;
1515
use default::Default;
1616
use fmt::Debug;
1717
use fmt;
@@ -764,27 +764,18 @@ pub struct Iter<'a, K: 'a> {
764764
iter: Keys<'a, K, ()>
765765
}
766766

767-
unsafe impl<'a, K: Send> Send for Iter<'a, K> {}
768-
unsafe impl<'a, K: Sync> Sync for Iter<'a, K> {}
769-
770767
/// HashSet move iterator
771768
#[stable(feature = "rust1", since = "1.0.0")]
772769
pub struct IntoIter<K> {
773770
iter: Map<map::IntoIter<K, ()>, fn((K, ())) -> K>
774771
}
775772

776-
unsafe impl<K: Send> Send for IntoIter<K> {}
777-
unsafe impl<K: Sync> Sync for IntoIter<K> {}
778-
779773
/// HashSet drain iterator
780774
#[stable(feature = "rust1", since = "1.0.0")]
781775
pub struct Drain<'a, K: 'a> {
782776
iter: Map<map::Drain<'a, K, ()>, fn((K, ())) -> K>,
783777
}
784778

785-
unsafe impl<'a, K: Send> Send for Drain<'a, K> {}
786-
unsafe impl<'a, K: Sync> Sync for Drain<'a, K> {}
787-
788779
/// Intersection iterator
789780
#[stable(feature = "rust1", since = "1.0.0")]
790781
pub struct Intersection<'a, T: 'a, S: 'a> {
@@ -794,9 +785,6 @@ pub struct Intersection<'a, T: 'a, S: 'a> {
794785
other: &'a HashSet<T, S>,
795786
}
796787

797-
unsafe impl<'a, K: Send, S: Send> Send for Intersection<'a, K, S> {}
798-
unsafe impl<'a, K: Sync, S: Send> Sync for Intersection<'a, K, S> {}
799-
800788
/// Difference iterator
801789
#[stable(feature = "rust1", since = "1.0.0")]
802790
pub struct Difference<'a, T: 'a, S: 'a> {
@@ -806,27 +794,18 @@ pub struct Difference<'a, T: 'a, S: 'a> {
806794
other: &'a HashSet<T, S>,
807795
}
808796

809-
unsafe impl<'a, K: Send, S: Send> Send for Difference<'a, K, S> {}
810-
unsafe impl<'a, K: Sync, S: Send> Sync for Difference<'a, K, S> {}
811-
812797
/// Symmetric difference iterator.
813798
#[stable(feature = "rust1", since = "1.0.0")]
814799
pub struct SymmetricDifference<'a, T: 'a, S: 'a> {
815800
iter: Chain<Difference<'a, T, S>, Difference<'a, T, S>>
816801
}
817802

818-
unsafe impl<'a, K: Send, S: Send> Send for SymmetricDifference<'a, K, S> {}
819-
unsafe impl<'a, K: Sync, S: Send> Sync for SymmetricDifference<'a, K, S> {}
820-
821803
/// Set union iterator.
822804
#[stable(feature = "rust1", since = "1.0.0")]
823805
pub struct Union<'a, T: 'a, S: 'a> {
824806
iter: Chain<Iter<'a, T>, Difference<'a, T, S>>
825807
}
826808

827-
unsafe impl<'a, K: Send, S: Send> Send for Union<'a, K, S> {}
828-
unsafe impl<'a, K: Sync, S: Send> Sync for Union<'a, K, S> {}
829-
830809
#[stable(feature = "rust1", since = "1.0.0")]
831810
impl<'a, T, S> IntoIterator for &'a HashSet<T, S>
832811
where T: Eq + Hash, S: HashState

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,6 @@ struct RawBuckets<'a, K, V> {
741741
marker: marker::PhantomData<&'a ()>,
742742
}
743743

744-
unsafe impl<'a, K: Send, V: Send> Send for RawBuckets<'a, K, V> {}
745-
unsafe impl<'a, K: Sync, V: Sync> Sync for RawBuckets<'a, K, V> {}
746-
747744
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
748745
impl<'a, K, V> Clone for RawBuckets<'a, K, V> {
749746
fn clone(&self) -> RawBuckets<'a, K, V> {
@@ -821,6 +818,9 @@ pub struct Iter<'a, K: 'a, V: 'a> {
821818
elems_left: usize,
822819
}
823820

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+
824824
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
825825
impl<'a, K, V> Clone for Iter<'a, K, V> {
826826
fn clone(&self) -> Iter<'a, K, V> {
@@ -838,18 +838,29 @@ pub struct IterMut<'a, K: 'a, V: 'a> {
838838
elems_left: usize,
839839
}
840840

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+
841846
/// Iterator over the entries in a table, consuming the table.
842847
pub struct IntoIter<K, V> {
843848
table: RawTable<K, V>,
844849
iter: RawBuckets<'static, K, V>
845850
}
846851

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+
847855
/// Iterator over the entries in a table, clearing the table.
848856
pub struct Drain<'a, K: 'a, V: 'a> {
849857
table: &'a mut RawTable<K, V>,
850858
iter: RawBuckets<'static, K, V>,
851859
}
852860

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+
853864
impl<'a, K, V> Iterator for Iter<'a, K, V> {
854865
type Item = (&'a K, &'a V);
855866

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use collections::Vec;
2626
use collections::VecDeque;
2727
use collections::VecMap;
2828
use std::collections::HashMap;
29+
use std::collections::HashSet;
2930

3031
use collections::Bound::Included;
3132
use collections::enum_set::CLike;
@@ -78,7 +79,12 @@ fn main() {
7879
is_sync_send!(BTreeSet::<usize>::new(), intersection(&BTreeSet::<usize>::new()));
7980
is_sync_send!(BTreeSet::<usize>::new(), union(&BTreeSet::<usize>::new()));
8081

81-
all_sync_send!(HashMap::<usize, usize>::new(), keys, values, iter, iter_mut);
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()));
8288

8389
all_sync_send!(LinkedList::<usize>::new(), iter, iter_mut, into_iter);
8490

0 commit comments

Comments
 (0)