]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/panic-safe.rs
New upstream version 1.12.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>>();
5bcae85e
SL
39 assert::<&Mutex<i32>>();
40 assert::<&RwLock<i32>>();
9cc50fc6
SL
41 assert::<Rc<i32>>();
42 assert::<Arc<i32>>();
43
44 fn bar<T>() {
45 assert::<Mutex<T>>();
46 assert::<RwLock<T>>();
47 }
54a0048b 48 fn baz<T: UnwindSafe>() {
9cc50fc6
SL
49 assert::<Box<T>>();
50 assert::<Vec<T>>();
51 assert::<RefCell<T>>();
54a0048b
SL
52 assert::<AssertUnwindSafe<T>>();
53 assert::<&AssertUnwindSafe<T>>();
54 assert::<Rc<AssertUnwindSafe<T>>>();
55 assert::<Arc<AssertUnwindSafe<T>>>();
9cc50fc6
SL
56 }
57}