Skip to content

Commit 66949b8

Browse files
authored
Don't double panic in futures-test::test::panic_waker::wake_panic (#2236)
This function can get called during Drop, so it's important not to panic if the thread is already panicking. Doing so makes debugging panics much harder.
1 parent f605139 commit 66949b8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

futures-test/src/task/panic_waker.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ unsafe fn clone_panic_waker(_data: *const ()) -> RawWaker {
99
unsafe fn noop(_data: *const ()) {}
1010

1111
unsafe fn wake_panic(_data: *const ()) {
12-
panic!("should not be woken");
12+
if ! std::thread::panicking() {
13+
panic!("should not be woken");
14+
}
1315
}
1416

1517
const PANIC_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(

0 commit comments

Comments
 (0)