From 9e38ebcaa957d5422a0946ae8536509fe0d76d94 Mon Sep 17 00:00:00 2001 From: Jamie Date: Mon, 24 Jan 2022 11:07:37 +0100 Subject: [PATCH] task: mark `JoinHandle` as `UnwindSafe` (#4418) --- tokio/src/runtime/task/join.rs | 4 ++++ tokio/tests/{net_types_unwind.rs => unwindsafe.rs} | 5 +++++ 2 files changed, 9 insertions(+) rename tokio/tests/{net_types_unwind.rs => unwindsafe.rs} (89%) diff --git a/tokio/src/runtime/task/join.rs b/tokio/src/runtime/task/join.rs index 0abbff20e29..cfb2214ca01 100644 --- a/tokio/src/runtime/task/join.rs +++ b/tokio/src/runtime/task/join.rs @@ -3,6 +3,7 @@ use crate::runtime::task::RawTask; use std::fmt; use std::future::Future; use std::marker::PhantomData; +use std::panic::{RefUnwindSafe, UnwindSafe}; use std::pin::Pin; use std::task::{Context, Poll}; @@ -150,6 +151,9 @@ cfg_rt! { unsafe impl Send for JoinHandle {} unsafe impl Sync for JoinHandle {} +impl UnwindSafe for JoinHandle {} +impl RefUnwindSafe for JoinHandle {} + impl JoinHandle { pub(super) fn new(raw: RawTask) -> JoinHandle { JoinHandle { diff --git a/tokio/tests/net_types_unwind.rs b/tokio/tests/unwindsafe.rs similarity index 89% rename from tokio/tests/net_types_unwind.rs rename to tokio/tests/unwindsafe.rs index 4eb4a87fd7a..09fe8394565 100644 --- a/tokio/tests/net_types_unwind.rs +++ b/tokio/tests/unwindsafe.rs @@ -3,6 +3,11 @@ use std::panic::{RefUnwindSafe, UnwindSafe}; +#[test] +fn join_handle_is_unwind_safe() { + is_unwind_safe::>(); +} + #[test] fn net_types_are_unwind_safe() { is_unwind_safe::();