Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ mod nonzero;
mod num;
mod ops;
mod option;
mod panic_safe;
mod pattern;
mod ptr;
mod result;
Expand Down
Original file line number Diff line number Diff line change
@@ -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>();
Expand All @@ -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>>();
Expand Down