2018-08-31 07:20:59 -05:00
|
|
|
// run-pass
|
2015-06-05 16:42:51 -05:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2015-06-12 12:49:39 -05:00
|
|
|
#![allow(warnings)]
|
2015-06-09 00:45:47 -05:00
|
|
|
|
2015-12-02 19:07:29 -06:00
|
|
|
use std::iter::{empty, once, repeat};
|
2015-06-05 16:42:51 -05:00
|
|
|
|
|
|
|
fn is_sync<T>(_: T) where T: Sync {}
|
|
|
|
fn is_send<T>(_: T) where T: Send {}
|
|
|
|
|
|
|
|
macro_rules! all_sync_send {
|
2015-06-09 00:45:47 -05:00
|
|
|
($ctor:expr, $iter:ident) => ({
|
|
|
|
let mut x = $ctor;
|
|
|
|
is_sync(x.$iter());
|
|
|
|
let mut y = $ctor;
|
|
|
|
is_send(y.$iter());
|
|
|
|
});
|
|
|
|
($ctor:expr, $iter:ident($($param:expr),+)) => ({
|
|
|
|
let mut x = $ctor;
|
|
|
|
is_sync(x.$iter($( $param ),+));
|
|
|
|
let mut y = $ctor;
|
|
|
|
is_send(y.$iter($( $param ),+));
|
|
|
|
});
|
|
|
|
($ctor:expr, $iter:ident, $($rest:tt)*) => ({
|
|
|
|
all_sync_send!($ctor, $iter);
|
|
|
|
all_sync_send!($ctor, $($rest)*);
|
|
|
|
});
|
|
|
|
($ctor:expr, $iter:ident($($param:expr),+), $($rest:tt)*) => ({
|
|
|
|
all_sync_send!($ctor, $iter($( $param ),+));
|
|
|
|
all_sync_send!($ctor, $($rest)*);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! all_sync_send_mutable_ref {
|
2015-06-05 16:42:51 -05:00
|
|
|
($ctor:expr, $($iter:ident),+) => ({
|
|
|
|
$(
|
|
|
|
let mut x = $ctor;
|
2015-06-09 00:45:47 -05:00
|
|
|
is_sync((&mut x).$iter());
|
2015-06-05 16:42:51 -05:00
|
|
|
let mut y = $ctor;
|
2015-06-09 00:45:47 -05:00
|
|
|
is_send((&mut y).$iter());
|
2015-06-05 16:42:51 -05:00
|
|
|
)+
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-06-09 00:45:47 -05:00
|
|
|
macro_rules! is_sync_send {
|
|
|
|
($ctor:expr) => ({
|
|
|
|
let x = $ctor;
|
|
|
|
is_sync(x);
|
|
|
|
let y = $ctor;
|
|
|
|
is_send(y);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-06-05 16:42:51 -05:00
|
|
|
fn main() {
|
|
|
|
// for char.rs
|
2016-07-27 05:10:31 -05:00
|
|
|
all_sync_send!("Я", escape_debug, escape_default, escape_unicode);
|
2015-06-05 16:42:51 -05:00
|
|
|
|
|
|
|
// for iter.rs
|
2015-06-09 00:45:47 -05:00
|
|
|
all_sync_send_mutable_ref!([1], iter);
|
|
|
|
|
|
|
|
// Bytes implements DoubleEndedIterator
|
|
|
|
all_sync_send!("a".bytes(), rev);
|
|
|
|
|
|
|
|
let a = [1];
|
|
|
|
let b = [2];
|
|
|
|
all_sync_send!(a.iter(),
|
|
|
|
cloned,
|
|
|
|
cycle,
|
|
|
|
chain([2].iter()),
|
|
|
|
zip([2].iter()),
|
|
|
|
map(|_| 1),
|
|
|
|
filter(|_| true),
|
|
|
|
filter_map(|_| Some(1)),
|
|
|
|
enumerate,
|
|
|
|
peekable,
|
|
|
|
skip_while(|_| true),
|
|
|
|
take_while(|_| true),
|
|
|
|
skip(1),
|
|
|
|
take(1),
|
|
|
|
scan(1, |_, _| Some(1)),
|
|
|
|
flat_map(|_| b.iter()),
|
|
|
|
fuse,
|
|
|
|
inspect(|_| ()));
|
|
|
|
|
|
|
|
is_sync_send!((1..).step_by(2));
|
|
|
|
is_sync_send!((1..2).step_by(2));
|
|
|
|
is_sync_send!((1..2));
|
|
|
|
is_sync_send!((1..));
|
|
|
|
is_sync_send!(repeat(1));
|
|
|
|
is_sync_send!(empty::<usize>());
|
2019-01-16 17:07:22 -06:00
|
|
|
is_sync_send!(empty::<*mut i32>());
|
2015-06-09 00:45:47 -05:00
|
|
|
is_sync_send!(once(1));
|
2015-06-05 16:42:51 -05:00
|
|
|
|
|
|
|
// for option.rs
|
2015-06-05 20:18:23 -05:00
|
|
|
// FIXME
|
2015-06-05 16:42:51 -05:00
|
|
|
|
|
|
|
// for result.rs
|
2015-06-05 20:18:23 -05:00
|
|
|
// FIXME
|
2015-06-05 16:42:51 -05:00
|
|
|
|
|
|
|
// for slice.rs
|
2015-06-05 20:18:23 -05:00
|
|
|
// FIXME
|
2015-06-05 16:42:51 -05:00
|
|
|
|
|
|
|
// for str/mod.rs
|
2015-06-05 20:18:23 -05:00
|
|
|
// FIXME
|
2015-06-05 16:42:51 -05:00
|
|
|
}
|