]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/terminate-in-initializer.rs
bef9efa9eb68dc47b99cc01393ab056366732d59
[rust.git] / src / test / run-pass / terminate-in-initializer.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11
12 // Issue #787
13 // Don't try to clean up uninitialized locals
14
15 use std::thread;
16
17 fn test_break() { loop { let _x: Box<int> = break; } }
18
19 fn test_cont() { let mut i = 0; while i < 1 { i += 1; let _x: Box<int> = continue; } }
20
21 fn test_ret() { let _x: Box<int> = return; }
22
23 fn test_panic() {
24     fn f() { let _x: Box<int> = panic!(); }
25     thread::spawn(move|| f() ).join().err().unwrap();
26 }
27
28 fn test_panic_indirect() {
29     fn f() -> ! { panic!(); }
30     fn g() { let _x: Box<int> = f(); }
31     thread::spawn(move|| g() ).join().err().unwrap();
32 }
33
34 pub fn main() {
35     test_break();
36     test_cont();
37     test_ret();
38     test_panic();
39     test_panic_indirect();
40 }