Move panic safety traits tests

This commit is contained in:
Alexis Bourget 2020-09-10 15:15:30 +02:00
parent ed52c7bb75
commit ac39debeba
2 changed files with 13 additions and 7 deletions

View File

@ -78,6 +78,7 @@ mod nonzero;
mod num;
mod ops;
mod option;
mod panic_safe;
mod pattern;
mod ptr;
mod result;

View File

@ -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>>();