about summary refs log tree commit diff
path: root/library/alloc/tests
diff options
context:
space:
mode:
authorBadel2 <2badel2@gmail.com>2022-01-05 22:42:21 +0100
committerBadel2 <2badel2@gmail.com>2022-01-07 17:28:20 +0100
commit8bdf5c3de6c6e4e01f7f6241cd0f2a606c7486df (patch)
tree795cf4e3727479f3f82c0ee6eba205b91d9fee6d /library/alloc/tests
parente012a191d768adeda1ee36a99ef8b92d51920154 (diff)
downloadrust-8bdf5c3de6c6e4e01f7f6241cd0f2a606c7486df.tar.gz
rust-8bdf5c3de6c6e4e01f7f6241cd0f2a606c7486df.zip
Implement panic::update_hook
Diffstat (limited to 'library/alloc/tests')
-rw-r--r--library/alloc/tests/lib.rs1
-rw-r--r--library/alloc/tests/slice.rs13
2 files changed, 8 insertions, 6 deletions
diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs
index eec24a5c3f7..7b8eeb90b5a 100644
--- a/library/alloc/tests/lib.rs
+++ b/library/alloc/tests/lib.rs
@@ -38,6 +38,7 @@
 #![feature(const_trait_impl)]
 #![feature(const_str_from_utf8)]
 #![feature(nonnull_slice_from_raw_parts)]
+#![feature(panic_update_hook)]
 
 use std::collections::hash_map::DefaultHasher;
 use std::hash::{Hash, Hasher};
diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs
index 18ea6a21413..a02f7b1f277 100644
--- a/library/alloc/tests/slice.rs
+++ b/library/alloc/tests/slice.rs
@@ -1783,12 +1783,13 @@ thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
 #[test]
 #[cfg_attr(target_os = "emscripten", ignore)] // no threads
 fn panic_safe() {
-    let prev = panic::take_hook();
-    panic::set_hook(Box::new(move |info| {
-        if !SILENCE_PANIC.with(|s| s.get()) {
-            prev(info);
-        }
-    }));
+    panic::update_hook(|prev| {
+        Box::new(move |info| {
+            if !SILENCE_PANIC.with(|s| s.get()) {
+                prev(info);
+            }
+        })
+    });
 
     let mut rng = thread_rng();