diff options
| author | Alexis Bourget <alexis.bourget@gmail.com> | 2020-09-10 15:15:30 +0200 |
|---|---|---|
| committer | Alexis Bourget <alexis.bourget@gmail.com> | 2020-09-21 21:50:26 +0200 |
| commit | ac39debeba2b63a39a3833e2d7451f0b1f95b5f2 (patch) | |
| tree | 4e02eb9012072d41444e0eafc3ebcdff5f3b69d7 | |
| parent | ed52c7bb7516f12f74704e20457d5046378a49fc (diff) | |
Move panic safety traits tests
| -rw-r--r-- | library/core/tests/lib.rs | 1 | ||||
| -rw-r--r-- | library/core/tests/panic_safe.rs (renamed from src/test/ui/panics/panic-safe.rs) | 19 |
2 files changed, 13 insertions, 7 deletions
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 4db391f3e56..4211d0e95a9 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -78,6 +78,7 @@ mod nonzero; mod num; mod ops; mod option; +mod panic_safe; mod pattern; mod ptr; mod result; diff --git a/src/test/ui/panics/panic-safe.rs b/library/core/tests/panic_safe.rs index 9867cc56406..3104ba539c3 100644 --- a/src/test/ui/panics/panic-safe.rs +++ b/library/core/tests/panic_safe.rs @@ -1,16 +1,18 @@ -// run-pass #![allow(dead_code)] -use std::panic::{UnwindSafe, AssertUnwindSafe}; use std::cell::RefCell; -use std::sync::{Mutex, RwLock, Arc}; +use std::panic::{AssertUnwindSafe, UnwindSafe}; use std::rc::Rc; +use std::sync::{Arc, Mutex, RwLock}; -struct Foo { a: i32 } +struct Foo { + a: i32, +} fn assert<T: UnwindSafe + ?Sized>() {} -fn main() { +#[test] +fn test_panic_safety_traits() { assert::<i32>(); assert::<&i32>(); assert::<*mut i32>(); @@ -32,13 +34,16 @@ fn main() { assert::<Arc<i32>>(); assert::<Box<[u8]>>(); - trait Trait: UnwindSafe {} - assert::<Box<dyn Trait>>(); + { + trait Trait: UnwindSafe {} + assert::<Box<dyn Trait>>(); + } fn bar<T>() { assert::<Mutex<T>>(); assert::<RwLock<T>>(); } + fn baz<T: UnwindSafe>() { assert::<Box<T>>(); assert::<Vec<T>>(); |
