]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unique/unique-send-2.rs
Pin panic-in-drop=abort test to old pass manager
[rust.git] / src / test / ui / unique / unique-send-2.rs
1 // run-pass
2 #![allow(unused_must_use)]
3 // ignore-emscripten no threads support
4
5 #![feature(box_syntax)]
6
7 use std::sync::mpsc::{channel, Sender};
8 use std::thread;
9
10 fn child(tx: &Sender<Box<usize>>, i: usize) {
11     tx.send(box i).unwrap();
12 }
13
14 pub fn main() {
15     let (tx, rx) = channel();
16     let n = 100;
17     let mut expected = 0;
18     let ts = (0..n).map(|i| {
19         expected += i;
20         let tx = tx.clone();
21         thread::spawn(move|| {
22             child(&tx, i)
23         })
24     }).collect::<Vec<_>>();
25
26     let mut actual = 0;
27     for _ in 0..n {
28         let j = rx.recv().unwrap();
29         actual += *j;
30     }
31
32     assert_eq!(expected, actual);
33
34     for t in ts { t.join(); }
35 }