summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorBadel2 <2badel2@gmail.com>2022-01-07 17:04:33 +0100
committerBadel2 <2badel2@gmail.com>2022-01-08 00:57:59 +0100
commit8ef3ce866e2f20bdcc567e2f7012f81ce2e60298 (patch)
tree1764db087c7b3bb38aa060ba67b985d4ec63f975 /library/alloc
parent8bdf5c3de6c6e4e01f7f6241cd0f2a606c7486df (diff)
downloadrust-8ef3ce866e2f20bdcc567e2f7012f81ce2e60298.tar.gz
rust-8ef3ce866e2f20bdcc567e2f7012f81ce2e60298.zip
Change panic::update_hook to simplify usage
And to remove possibility of panics while changing the panic handler,
because that resulted in a double panic.
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/tests/slice.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs
index a02f7b1f277..b93d7938bc9 100644
--- a/library/alloc/tests/slice.rs
+++ b/library/alloc/tests/slice.rs
@@ -1783,12 +1783,10 @@ thread_local!(static SILENCE_PANIC: Cell<bool> = Cell::new(false));
 #[test]
 #[cfg_attr(target_os = "emscripten", ignore)] // no threads
 fn panic_safe() {
-    panic::update_hook(|prev| {
-        Box::new(move |info| {
-            if !SILENCE_PANIC.with(|s| s.get()) {
-                prev(info);
-            }
-        })
+    panic::update_hook(move |prev, info| {
+        if !SILENCE_PANIC.with(|s| s.get()) {
+            prev(info);
+        }
     });
 
     let mut rng = thread_rng();