]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/terminate-in-initializer.rs
rustdoc: Replace no-pretty-expanded with pretty-expanded
[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 // pretty-expanded FIXME #23616
16
17 use std::thread;
18
19 fn test_break() { loop { let _x: Box<int> = break; } }
20
21 fn test_cont() { let mut i = 0; while i < 1 { i += 1; let _x: Box<int> = continue; } }
22
23 fn test_ret() { let _x: Box<int> = return; }
24
25 fn test_panic() {
26     fn f() { let _x: Box<int> = panic!(); }
27     thread::spawn(move|| f() ).join().err().unwrap();
28 }
29
30 fn test_panic_indirect() {
31     fn f() -> ! { panic!(); }
32     fn g() { let _x: Box<int> = f(); }
33     thread::spawn(move|| g() ).join().err().unwrap();
34 }
35
36 pub fn main() {
37     test_break();
38     test_cont();
39     test_ret();
40     test_panic();
41     test_panic_indirect();
42 }