2018-08-31 07:20:59 -05:00
|
|
|
// run-pass
|
|
|
|
|
2015-06-10 15:33:52 -05:00
|
|
|
#![allow(warnings)]
|
2018-07-22 21:14:42 -05:00
|
|
|
#![feature(drain, collections_bound, btree_range)]
|
2015-02-25 06:52:18 -06:00
|
|
|
|
2017-06-13 17:52:59 -05:00
|
|
|
use std::collections::BinaryHeap;
|
|
|
|
use std::collections::{BTreeMap, BTreeSet};
|
|
|
|
use std::collections::LinkedList;
|
|
|
|
use std::collections::VecDeque;
|
2015-08-09 14:04:22 -05:00
|
|
|
use std::collections::HashMap;
|
2015-08-09 16:38:04 -05:00
|
|
|
use std::collections::HashSet;
|
2015-02-25 06:52:18 -06:00
|
|
|
|
|
|
|
use std::mem;
|
2018-03-19 03:01:17 -05:00
|
|
|
use std::ops::Bound::Included;
|
2015-02-25 06:52:18 -06:00
|
|
|
|
|
|
|
fn is_sync<T>(_: T) where T: Sync {}
|
|
|
|
fn is_send<T>(_: T) where T: Send {}
|
|
|
|
|
|
|
|
macro_rules! all_sync_send {
|
|
|
|
($ctor:expr, $($iter:ident),+) => ({
|
|
|
|
$(
|
|
|
|
let mut x = $ctor;
|
|
|
|
is_sync(x.$iter());
|
|
|
|
let mut y = $ctor;
|
|
|
|
is_send(y.$iter());
|
|
|
|
)+
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! is_sync_send {
|
|
|
|
($ctor:expr, $iter:ident($($param:expr),+)) => ({
|
|
|
|
let mut x = $ctor;
|
|
|
|
is_sync(x.$iter($( $param ),+));
|
|
|
|
let mut y = $ctor;
|
|
|
|
is_send(y.$iter($( $param ),+));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// The iterator "generator" list should exhaust what corresponding
|
|
|
|
// implementations have where `Sync` and `Send` semantics apply.
|
|
|
|
all_sync_send!(BinaryHeap::<usize>::new(), iter, drain, into_iter);
|
|
|
|
|
|
|
|
all_sync_send!(BTreeMap::<usize, usize>::new(), iter, iter_mut, into_iter, keys, values);
|
2016-12-26 05:44:23 -06:00
|
|
|
is_sync_send!(BTreeMap::<usize, usize>::new(), range((Included(&0), Included(&9))));
|
|
|
|
is_sync_send!(BTreeMap::<usize, usize>::new(), range_mut((Included(&0), Included(&9))));
|
2015-02-25 06:52:18 -06:00
|
|
|
|
|
|
|
all_sync_send!(BTreeSet::<usize>::new(), iter, into_iter);
|
2016-12-26 05:44:23 -06:00
|
|
|
is_sync_send!(BTreeSet::<usize>::new(), range((Included(&0), Included(&9))));
|
2015-02-25 06:52:18 -06:00
|
|
|
is_sync_send!(BTreeSet::<usize>::new(), difference(&BTreeSet::<usize>::new()));
|
|
|
|
is_sync_send!(BTreeSet::<usize>::new(), symmetric_difference(&BTreeSet::<usize>::new()));
|
|
|
|
is_sync_send!(BTreeSet::<usize>::new(), intersection(&BTreeSet::<usize>::new()));
|
|
|
|
is_sync_send!(BTreeSet::<usize>::new(), union(&BTreeSet::<usize>::new()));
|
|
|
|
|
2015-08-09 16:38:04 -05:00
|
|
|
all_sync_send!(HashMap::<usize, usize>::new(), iter, iter_mut, drain, into_iter, keys, values);
|
2019-02-10 10:54:56 -06:00
|
|
|
is_sync_send!(HashMap::<usize, usize>::new(), entry(0));
|
2015-08-09 16:38:04 -05:00
|
|
|
all_sync_send!(HashSet::<usize>::new(), iter, drain, into_iter);
|
|
|
|
is_sync_send!(HashSet::<usize>::new(), difference(&HashSet::<usize>::new()));
|
|
|
|
is_sync_send!(HashSet::<usize>::new(), symmetric_difference(&HashSet::<usize>::new()));
|
|
|
|
is_sync_send!(HashSet::<usize>::new(), intersection(&HashSet::<usize>::new()));
|
|
|
|
is_sync_send!(HashSet::<usize>::new(), union(&HashSet::<usize>::new()));
|
2015-08-09 14:04:22 -05:00
|
|
|
|
2015-02-25 06:52:18 -06:00
|
|
|
all_sync_send!(LinkedList::<usize>::new(), iter, iter_mut, into_iter);
|
|
|
|
|
2015-09-24 17:19:23 -05:00
|
|
|
all_sync_send!(VecDeque::<usize>::new(), iter, iter_mut, into_iter);
|
|
|
|
is_sync_send!(VecDeque::<usize>::new(), drain(..));
|
2015-02-25 06:52:18 -06:00
|
|
|
|
2015-04-27 12:37:13 -05:00
|
|
|
all_sync_send!(Vec::<usize>::new(), into_iter);
|
|
|
|
is_sync_send!(Vec::<usize>::new(), drain(..));
|
2015-05-01 08:34:25 -05:00
|
|
|
is_sync_send!(String::new(), drain(..));
|
2015-02-25 06:52:18 -06:00
|
|
|
}
|