]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issues/issue-13494.rs
Auto merge of #60171 - matthewjasper:full-nll-compare-mode, r=pnkfelix
[rust.git] / src / test / run-pass / issues / issue-13494.rs
1 // run-pass
2 #![allow(unused_must_use)]
3 // ignore-emscripten no threads support
4
5 // This test may not always fail, but it can be flaky if the race it used to
6 // expose is still present.
7
8 #![feature(mpsc_select)]
9 #![allow(deprecated)]
10
11 use std::sync::mpsc::{channel, Sender, Receiver};
12 use std::thread;
13
14 fn helper(rx: Receiver<Sender<()>>) {
15     for tx in rx.iter() {
16         let _ = tx.send(());
17     }
18 }
19
20 fn main() {
21     let (tx, rx) = channel();
22     let t = thread::spawn(move|| { helper(rx) });
23     let (snd, rcv) = channel::<isize>();
24     for _ in 1..100000 {
25         snd.send(1).unwrap();
26         let (tx2, rx2) = channel();
27         tx.send(tx2).unwrap();
28         select! {
29             _ = rx2.recv() => (),
30             _ = rcv.recv() => ()
31         }
32     }
33     drop(tx);
34     t.join();
35 }