diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-01-17 09:39:09 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-01-26 10:28:04 +0000 |
| commit | 09c4dbf7fbb545c0b861ea2473dcb84023f494c4 (patch) | |
| tree | 4ea2145e83c8e2e60e21280590213ba345870c08 /library/std/tests/panic.rs | |
| parent | 9baeb453095bc74966e0c99a6eeddefed5ed9eaa (diff) | |
| download | rust-09c4dbf7fbb545c0b861ea2473dcb84023f494c4.tar.gz rust-09c4dbf7fbb545c0b861ea2473dcb84023f494c4.zip | |
Move std::panic unit tests to integration tests
Diffstat (limited to 'library/std/tests/panic.rs')
| -rw-r--r-- | library/std/tests/panic.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/library/std/tests/panic.rs b/library/std/tests/panic.rs new file mode 100644 index 00000000000..f13b931dd22 --- /dev/null +++ b/library/std/tests/panic.rs @@ -0,0 +1,56 @@ +#![allow(dead_code)] + +use std::cell::RefCell; +use std::panic::{AssertUnwindSafe, UnwindSafe}; +use std::rc::Rc; +use std::sync::{Arc, Mutex, RwLock}; + +struct Foo { + a: i32, +} + +fn assert<T: UnwindSafe + ?Sized>() {} + +#[test] +fn panic_safety_traits() { + assert::<i32>(); + assert::<&i32>(); + assert::<*mut i32>(); + assert::<*const i32>(); + assert::<usize>(); + assert::<str>(); + assert::<&str>(); + assert::<Foo>(); + assert::<&Foo>(); + assert::<Vec<i32>>(); + assert::<String>(); + assert::<RefCell<i32>>(); + assert::<Box<i32>>(); + assert::<Mutex<i32>>(); + assert::<RwLock<i32>>(); + assert::<&Mutex<i32>>(); + assert::<&RwLock<i32>>(); + assert::<Rc<i32>>(); + assert::<Arc<i32>>(); + assert::<Box<[u8]>>(); + + { + 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>>(); + assert::<RefCell<T>>(); + assert::<AssertUnwindSafe<T>>(); + assert::<&AssertUnwindSafe<T>>(); + assert::<Rc<AssertUnwindSafe<T>>>(); + assert::<Arc<AssertUnwindSafe<T>>>(); + } +} |
