rayon/compile_fail/
no_send_par_iter.rs

1// Check that `!Send` types fail early.
2
3/** ```compile_fail,E0277
4
5use rayon::prelude::*;
6use std::ptr::null;
7
8#[derive(Copy, Clone)]
9struct NoSend(*const ());
10
11unsafe impl Sync for NoSend {}
12
13fn main() {
14    let x = Some(NoSend(null()));
15
16    x.par_iter()
17        .map(|&x| x) //~ ERROR
18        .count(); //~ ERROR
19}
20
21``` */
22mod map {}
23
24/** ```compile_fail,E0277
25
26use rayon::prelude::*;
27use std::ptr::null;
28
29#[derive(Copy, Clone)]
30struct NoSend(*const ());
31
32unsafe impl Sync for NoSend {}
33
34fn main() {
35    let x = Some(NoSend(null()));
36
37    x.par_iter()
38        .filter_map(|&x| Some(x)) //~ ERROR
39        .count(); //~ ERROR
40}
41
42``` */
43mod filter_map {}
44
45/** ```compile_fail,E0277
46
47use rayon::prelude::*;
48use std::ptr::null;
49
50#[derive(Copy, Clone)]
51struct NoSend(*const ());
52
53unsafe impl Sync for NoSend {}
54
55fn main() {
56    let x = Some(NoSend(null()));
57
58    x.par_iter()
59        .cloned() //~ ERROR
60        .count(); //~ ERROR
61}
62
63``` */
64mod cloned {}