]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/terminate-in-initializer.rs
Imported Upstream version 1.0.0~beta.3
[rustc.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
16 use std::thread;
17
18 fn test_break() { loop { let _x: Box<isize> = break; } }
19
20 fn test_cont() { let mut i = 0; while i < 1 { i += 1; let _x: Box<isize> = continue; } }
21
22 fn test_ret() { let _x: Box<isize> = return; }
23
24 fn test_panic() {
25 fn f() { let _x: Box<isize> = panic!(); }
26 thread::spawn(move|| f() ).join().err().unwrap();
27 }
28
29 fn test_panic_indirect() {
30 fn f() -> ! { panic!(); }
31 fn g() { let _x: Box<isize> = f(); }
32 thread::spawn(move|| g() ).join().err().unwrap();
33 }
34
35 pub fn main() {
36 test_break();
37 test_cont();
38 test_ret();
39 test_panic();
40 test_panic_indirect();
41 }