]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/sync-send-iterators-in-libcore.rs
Account for --remap-path-prefix in save-analysis
[rust.git] / src / test / run-pass / sync-send-iterators-in-libcore.rs
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)]
17 #![feature(str_escape)]
18
19 use std::iter::{empty, once, repeat};
20
21 fn is_sync<T>(_: T) where T: Sync {}
22 fn is_send<T>(_: T) where T: Send {}
23
24 macro_rules! all_sync_send {
25     ($ctor:expr, $iter:ident) => ({
26         let mut x = $ctor;
27         is_sync(x.$iter());
28         let mut y = $ctor;
29         is_send(y.$iter());
30     });
31     ($ctor:expr, $iter:ident($($param:expr),+)) => ({
32         let mut x = $ctor;
33         is_sync(x.$iter($( $param ),+));
34         let mut y = $ctor;
35         is_send(y.$iter($( $param ),+));
36     });
37     ($ctor:expr, $iter:ident, $($rest:tt)*) => ({
38         all_sync_send!($ctor, $iter);
39         all_sync_send!($ctor, $($rest)*);
40     });
41     ($ctor:expr, $iter:ident($($param:expr),+), $($rest:tt)*) => ({
42         all_sync_send!($ctor, $iter($( $param ),+));
43         all_sync_send!($ctor, $($rest)*);
44     });
45 }
46
47 macro_rules! all_sync_send_mutable_ref {
48     ($ctor:expr, $($iter:ident),+) => ({
49         $(
50             let mut x = $ctor;
51             is_sync((&mut x).$iter());
52             let mut y = $ctor;
53             is_send((&mut y).$iter());
54         )+
55     })
56 }
57
58 macro_rules! is_sync_send {
59     ($ctor:expr) => ({
60         let x = $ctor;
61         is_sync(x);
62         let y = $ctor;
63         is_send(y);
64     })
65 }
66
67 fn main() {
68     // for char.rs
69     all_sync_send!("Я", escape_debug, escape_default, escape_unicode);
70
71     // for iter.rs
72     all_sync_send_mutable_ref!([1], iter);
73
74     // Bytes implements DoubleEndedIterator
75     all_sync_send!("a".bytes(), rev);
76
77     let a = [1];
78     let b = [2];
79     all_sync_send!(a.iter(),
80                    cloned,
81                    cycle,
82                    chain([2].iter()),
83                    zip([2].iter()),
84                    map(|_| 1),
85                    filter(|_| true),
86                    filter_map(|_| Some(1)),
87                    enumerate,
88                    peekable,
89                    skip_while(|_| true),
90                    take_while(|_| true),
91                    skip(1),
92                    take(1),
93                    scan(1, |_, _| Some(1)),
94                    flat_map(|_| b.iter()),
95                    fuse,
96                    inspect(|_| ()));
97
98     is_sync_send!((1..).step_by(2));
99     is_sync_send!((1..2).step_by(2));
100     is_sync_send!((1..2));
101     is_sync_send!((1..));
102     is_sync_send!(repeat(1));
103     is_sync_send!(empty::<usize>());
104     is_sync_send!(once(1));
105
106     // for option.rs
107     // FIXME
108
109     // for result.rs
110     // FIXME
111
112     // for slice.rs
113     // FIXME
114
115     // for str/mod.rs
116     // FIXME
117 }