]>
Commit | Line | Data |
---|---|---|
62682a34 SL |
1 | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | // pretty-expanded FIXME #23616 | |
12 | ||
13 | #![allow(warnings)] | |
14 | #![feature(iter_empty)] | |
15 | #![feature(iter_once)] | |
16 | #![feature(iter_unfold)] | |
62682a34 SL |
17 | #![feature(step_by)] |
18 | #![feature(str_escape)] | |
19 | ||
9cc50fc6 | 20 | use std::iter::{empty, once, repeat}; |
62682a34 SL |
21 | |
22 | fn is_sync<T>(_: T) where T: Sync {} | |
23 | fn is_send<T>(_: T) where T: Send {} | |
24 | ||
25 | macro_rules! all_sync_send { | |
26 | ($ctor:expr, $iter:ident) => ({ | |
27 | let mut x = $ctor; | |
28 | is_sync(x.$iter()); | |
29 | let mut y = $ctor; | |
30 | is_send(y.$iter()); | |
31 | }); | |
32 | ($ctor:expr, $iter:ident($($param:expr),+)) => ({ | |
33 | let mut x = $ctor; | |
34 | is_sync(x.$iter($( $param ),+)); | |
35 | let mut y = $ctor; | |
36 | is_send(y.$iter($( $param ),+)); | |
37 | }); | |
38 | ($ctor:expr, $iter:ident, $($rest:tt)*) => ({ | |
39 | all_sync_send!($ctor, $iter); | |
40 | all_sync_send!($ctor, $($rest)*); | |
41 | }); | |
42 | ($ctor:expr, $iter:ident($($param:expr),+), $($rest:tt)*) => ({ | |
43 | all_sync_send!($ctor, $iter($( $param ),+)); | |
44 | all_sync_send!($ctor, $($rest)*); | |
45 | }); | |
46 | } | |
47 | ||
48 | macro_rules! all_sync_send_mutable_ref { | |
49 | ($ctor:expr, $($iter:ident),+) => ({ | |
50 | $( | |
51 | let mut x = $ctor; | |
52 | is_sync((&mut x).$iter()); | |
53 | let mut y = $ctor; | |
54 | is_send((&mut y).$iter()); | |
55 | )+ | |
56 | }) | |
57 | } | |
58 | ||
59 | macro_rules! is_sync_send { | |
60 | ($ctor:expr) => ({ | |
61 | let x = $ctor; | |
62 | is_sync(x); | |
63 | let y = $ctor; | |
64 | is_send(y); | |
65 | }) | |
66 | } | |
67 | ||
68 | fn main() { | |
69 | // for char.rs | |
5bcae85e | 70 | all_sync_send!("Я", escape_debug, escape_default, escape_unicode); |
62682a34 SL |
71 | |
72 | // for iter.rs | |
73 | all_sync_send_mutable_ref!([1], iter); | |
74 | ||
75 | // Bytes implements DoubleEndedIterator | |
76 | all_sync_send!("a".bytes(), rev); | |
77 | ||
78 | let a = [1]; | |
79 | let b = [2]; | |
80 | all_sync_send!(a.iter(), | |
81 | cloned, | |
82 | cycle, | |
83 | chain([2].iter()), | |
84 | zip([2].iter()), | |
85 | map(|_| 1), | |
86 | filter(|_| true), | |
87 | filter_map(|_| Some(1)), | |
88 | enumerate, | |
89 | peekable, | |
90 | skip_while(|_| true), | |
91 | take_while(|_| true), | |
92 | skip(1), | |
93 | take(1), | |
94 | scan(1, |_, _| Some(1)), | |
95 | flat_map(|_| b.iter()), | |
96 | fuse, | |
97 | inspect(|_| ())); | |
98 | ||
62682a34 | 99 | is_sync_send!((1..).step_by(2)); |
62682a34 SL |
100 | is_sync_send!((1..2).step_by(2)); |
101 | is_sync_send!((1..2)); | |
102 | is_sync_send!((1..)); | |
103 | is_sync_send!(repeat(1)); | |
104 | is_sync_send!(empty::<usize>()); | |
105 | is_sync_send!(once(1)); | |
106 | ||
107 | // for option.rs | |
108 | // FIXME | |
109 | ||
110 | // for result.rs | |
111 | // FIXME | |
112 | ||
113 | // for slice.rs | |
114 | // FIXME | |
115 | ||
116 | // for str/mod.rs | |
117 | // FIXME | |
118 | } |