]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/panic-safe.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / run-pass / panic-safe.rs
CommitLineData
9cc50fc6
SL
1// Copyright 2015 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#![allow(dead_code)]
12#![feature(recover)]
13
54a0048b 14use std::panic::{UnwindSafe, AssertUnwindSafe};
9cc50fc6
SL
15use std::cell::RefCell;
16use std::sync::{Mutex, RwLock, Arc};
17use std::rc::Rc;
18
19struct Foo { a: i32 }
20
54a0048b 21fn assert<T: UnwindSafe + ?Sized>() {}
9cc50fc6
SL
22
23fn main() {
24 assert::<i32>();
25 assert::<&i32>();
26 assert::<*mut i32>();
27 assert::<*const i32>();
28 assert::<usize>();
29 assert::<str>();
30 assert::<&str>();
31 assert::<Foo>();
32 assert::<&Foo>();
33 assert::<Vec<i32>>();
34 assert::<String>();
35 assert::<RefCell<i32>>();
36 assert::<Box<i32>>();
37 assert::<Mutex<i32>>();
38 assert::<RwLock<i32>>();
39 assert::<Rc<i32>>();
40 assert::<Arc<i32>>();
41
42 fn bar<T>() {
43 assert::<Mutex<T>>();
44 assert::<RwLock<T>>();
45 }
54a0048b 46 fn baz<T: UnwindSafe>() {
9cc50fc6
SL
47 assert::<Box<T>>();
48 assert::<Vec<T>>();
49 assert::<RefCell<T>>();
54a0048b
SL
50 assert::<AssertUnwindSafe<T>>();
51 assert::<&AssertUnwindSafe<T>>();
52 assert::<Rc<AssertUnwindSafe<T>>>();
53 assert::<Arc<AssertUnwindSafe<T>>>();
9cc50fc6
SL
54 }
55}