]> git.lizzy.rs Git - rust.git/blob - src/test/ui/terminate-in-initializer.rs
Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
[rust.git] / src / test / ui / terminate-in-initializer.rs
1 // run-pass
2 // ignore-emscripten no threads support
3
4 // Issue #787
5 // Don't try to clean up uninitialized locals
6
7
8 use std::thread;
9
10 fn test_break() { loop { let _x: Box<isize> = break; } }
11
12 fn test_cont() { let mut i = 0; while i < 1 { i += 1; let _x: Box<isize> = continue; } }
13
14 fn test_ret() { let _x: Box<isize> = return; }
15
16 fn test_panic() {
17     fn f() { let _x: Box<isize> = panic!(); }
18     thread::spawn(move|| f() ).join().unwrap_err();
19 }
20
21 fn test_panic_indirect() {
22     fn f() -> ! { panic!(); }
23     fn g() { let _x: Box<isize> = f(); }
24     thread::spawn(move|| g() ).join().unwrap_err();
25 }
26
27 pub fn main() {
28     test_break();
29     test_cont();
30     test_ret();
31     test_panic();
32     test_panic_indirect();
33 }