summaryrefslogtreecommitdiffstats
path: root/library/std/src/panic
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /library/std/src/panic
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/std/src/panic')
-rw-r--r--library/std/src/panic/tests.rs56
1 files changed, 56 insertions, 0 deletions
diff --git a/library/std/src/panic/tests.rs b/library/std/src/panic/tests.rs
new file mode 100644
index 000000000..b37d74011
--- /dev/null
+++ b/library/std/src/panic/tests.rs
@@ -0,0 +1,56 @@
+#![allow(dead_code)]
+
+use crate::cell::RefCell;
+use crate::panic::{AssertUnwindSafe, UnwindSafe};
+use crate::rc::Rc;
+use crate::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>>>();
+ }
+}