File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ mod nonzero;
78
78
mod num;
79
79
mod ops;
80
80
mod option;
81
+ mod panic_safe;
81
82
mod pattern;
82
83
mod ptr;
83
84
mod result;
Original file line number Diff line number Diff line change
1
+ #![ allow( dead_code) ]
2
+
3
+ use std:: cell:: RefCell ;
4
+ use std:: panic:: { AssertUnwindSafe , UnwindSafe } ;
5
+ use std:: rc:: Rc ;
6
+ use std:: sync:: { Arc , Mutex , RwLock } ;
7
+
8
+ struct Foo {
9
+ a : i32 ,
10
+ }
11
+
12
+ fn assert < T : UnwindSafe + ?Sized > ( ) { }
13
+
14
+ #[ test]
15
+ fn test_panic_safety_traits ( ) {
16
+ assert :: < i32 > ( ) ;
17
+ assert :: < & i32 > ( ) ;
18
+ assert :: < * mut i32 > ( ) ;
19
+ assert :: < * const i32 > ( ) ;
20
+ assert :: < usize > ( ) ;
21
+ assert :: < str > ( ) ;
22
+ assert :: < & str > ( ) ;
23
+ assert :: < Foo > ( ) ;
24
+ assert :: < & Foo > ( ) ;
25
+ assert :: < Vec < i32 > > ( ) ;
26
+ assert :: < String > ( ) ;
27
+ assert :: < RefCell < i32 > > ( ) ;
28
+ assert :: < Box < i32 > > ( ) ;
29
+ assert :: < Mutex < i32 > > ( ) ;
30
+ assert :: < RwLock < i32 > > ( ) ;
31
+ assert :: < & Mutex < i32 > > ( ) ;
32
+ assert :: < & RwLock < i32 > > ( ) ;
33
+ assert :: < Rc < i32 > > ( ) ;
34
+ assert :: < Arc < i32 > > ( ) ;
35
+ assert :: < Box < [ u8 ] > > ( ) ;
36
+
37
+ {
38
+ trait Trait : UnwindSafe { }
39
+ assert :: < Box < dyn Trait > > ( ) ;
40
+ }
41
+
42
+ fn bar < T > ( ) {
43
+ assert :: < Mutex < T > > ( ) ;
44
+ assert :: < RwLock < T > > ( ) ;
45
+ }
46
+
47
+ fn baz < T : UnwindSafe > ( ) {
48
+ assert :: < Box < T > > ( ) ;
49
+ assert :: < Vec < T > > ( ) ;
50
+ assert :: < RefCell < T > > ( ) ;
51
+ assert :: < AssertUnwindSafe < T > > ( ) ;
52
+ assert :: < & AssertUnwindSafe < T > > ( ) ;
53
+ assert :: < Rc < AssertUnwindSafe < T > > > ( ) ;
54
+ assert :: < Arc < AssertUnwindSafe < T > > > ( ) ;
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments