2019-07-27 00:54:25 +03:00
|
|
|
// run-pass
|
2021-12-03 15:32:51 +00:00
|
|
|
// needs-unwind
|
2016-02-11 12:34:41 +01:00
|
|
|
// ignore-emscripten no threads support
|
2013-10-23 04:49:18 -04:00
|
|
|
|
2011-08-23 15:45:24 -07:00
|
|
|
// Issue #787
|
2012-03-10 20:38:03 -08:00
|
|
|
// Don't try to clean up uninitialized locals
|
2011-08-23 15:45:24 -07:00
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2015-02-17 15:24:34 -08:00
|
|
|
use std::thread;
|
2013-05-24 19:35:29 -07:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn test_break() { loop { let _x: Box<isize> = break; } }
|
2011-08-23 15:45:24 -07:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn test_cont() { let mut i = 0; while i < 1 { i += 1; let _x: Box<isize> = continue; } }
|
2011-08-23 15:45:24 -07:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn test_ret() { let _x: Box<isize> = return; }
|
2011-08-23 15:45:24 -07:00
|
|
|
|
2014-10-09 15:17:22 -04:00
|
|
|
fn test_panic() {
|
2015-03-25 17:06:52 -07:00
|
|
|
fn f() { let _x: Box<isize> = panic!(); }
|
2016-05-06 19:32:18 -04:00
|
|
|
thread::spawn(move|| f() ).join().unwrap_err();
|
2011-08-23 15:45:24 -07:00
|
|
|
}
|
|
|
|
|
2014-10-09 15:17:22 -04:00
|
|
|
fn test_panic_indirect() {
|
|
|
|
fn f() -> ! { panic!(); }
|
2015-03-25 17:06:52 -07:00
|
|
|
fn g() { let _x: Box<isize> = f(); }
|
2016-05-06 19:32:18 -04:00
|
|
|
thread::spawn(move|| g() ).join().unwrap_err();
|
2011-08-23 15:45:24 -07:00
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2011-08-23 15:45:24 -07:00
|
|
|
test_break();
|
|
|
|
test_cont();
|
|
|
|
test_ret();
|
2014-10-09 15:17:22 -04:00
|
|
|
test_panic();
|
|
|
|
test_panic_indirect();
|
2011-09-02 15:34:58 -07:00
|
|
|
}
|