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