]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/panic-safe.rs
Auto merge of #30272 - tshepang:doc-drain, r=bluss
[rust.git] / src / test / run-pass / panic-safe.rs
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
14 use std::panic::RecoverSafe;
15 use std::cell::RefCell;
16 use std::sync::{Mutex, RwLock, Arc};
17 use std::rc::Rc;
18
19 struct Foo { a: i32 }
20
21 fn assert<T: RecoverSafe + ?Sized>() {}
22
23 fn 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     }
46     fn baz<T: RecoverSafe>() {
47         assert::<Box<T>>();
48         assert::<Vec<T>>();
49         assert::<RefCell<T>>();
50     }
51 }