]> git.lizzy.rs Git - rust.git/commitdiff
Move panic safety traits tests
authorAlexis Bourget <alexis.bourget@gmail.com>
Thu, 10 Sep 2020 13:15:30 +0000 (15:15 +0200)
committerAlexis Bourget <alexis.bourget@gmail.com>
Mon, 21 Sep 2020 19:50:26 +0000 (21:50 +0200)
library/core/tests/lib.rs
library/core/tests/panic_safe.rs [new file with mode: 0644]
src/test/ui/panics/panic-safe.rs [deleted file]

index 4db391f3e567eb69c962c40b7c53264320c5057e..4211d0e95a9bd8a592d6cbcca38767649c8a98eb 100644 (file)
@@ -78,6 +78,7 @@
 mod num;
 mod ops;
 mod option;
+mod panic_safe;
 mod pattern;
 mod ptr;
 mod result;
diff --git a/library/core/tests/panic_safe.rs b/library/core/tests/panic_safe.rs
new file mode 100644 (file)
index 0000000..3104ba5
--- /dev/null
@@ -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 test_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>>>();
+    }
+}
diff --git a/src/test/ui/panics/panic-safe.rs b/src/test/ui/panics/panic-safe.rs
deleted file mode 100644 (file)
index 9867cc5..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-use std::panic::{UnwindSafe, AssertUnwindSafe};
-use std::cell::RefCell;
-use std::sync::{Mutex, RwLock, Arc};
-use std::rc::Rc;
-
-struct Foo { a: i32 }
-
-fn assert<T: UnwindSafe + ?Sized>() {}
-
-fn main() {
-    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>>>();
-    }
-}