]> git.lizzy.rs Git - rust.git/blob - src/test/ui/unwind-resource.rs
Auto merge of #87284 - Aaron1011:remove-paren-special, r=petrochenkov
[rust.git] / src / test / ui / unwind-resource.rs
1 // run-pass
2
3 #![allow(non_camel_case_types)]
4 // ignore-emscripten no threads support
5
6 use std::sync::mpsc::{channel, Sender};
7 use std::thread;
8
9 struct complainer {
10     tx: Sender<bool>,
11 }
12
13 impl Drop for complainer {
14     fn drop(&mut self) {
15         println!("About to send!");
16         self.tx.send(true).unwrap();
17         println!("Sent!");
18     }
19 }
20
21 fn complainer(tx: Sender<bool>) -> complainer {
22     println!("Hello!");
23     complainer {
24         tx: tx
25     }
26 }
27
28 fn f(tx: Sender<bool>) {
29     let _tx = complainer(tx);
30     panic!();
31 }
32
33 pub fn main() {
34     let (tx, rx) = channel();
35     let t = thread::spawn(move|| f(tx.clone()));
36     println!("hiiiiiiiii");
37     assert!(rx.recv().unwrap());
38     drop(t.join());
39 }