diff --git a/tokio/src/io/poll_evented.rs b/tokio/src/io/poll_evented.rs index 44e68a2a9a0..ce4c1426acc 100644 --- a/tokio/src/io/poll_evented.rs +++ b/tokio/src/io/poll_evented.rs @@ -4,6 +4,7 @@ use mio::event::Source; use std::fmt; use std::io; use std::ops::Deref; +use std::panic::{RefUnwindSafe, UnwindSafe}; cfg_io_driver! { /// Associates an I/O resource that implements the [`std::io::Read`] and/or @@ -185,6 +186,10 @@ feature! { } } +impl UnwindSafe for PollEvented {} + +impl RefUnwindSafe for PollEvented {} + impl Deref for PollEvented { type Target = E; diff --git a/tokio/tests/net_types_unwind.rs b/tokio/tests/net_types_unwind.rs new file mode 100644 index 00000000000..4eb4a87fd7a --- /dev/null +++ b/tokio/tests/net_types_unwind.rs @@ -0,0 +1,32 @@ +#![warn(rust_2018_idioms)] +#![cfg(feature = "full")] + +use std::panic::{RefUnwindSafe, UnwindSafe}; + +#[test] +fn net_types_are_unwind_safe() { + is_unwind_safe::(); + is_unwind_safe::(); + is_unwind_safe::(); + is_unwind_safe::(); +} + +#[test] +#[cfg(unix)] +fn unix_net_types_are_unwind_safe() { + is_unwind_safe::(); + is_unwind_safe::(); + is_unwind_safe::(); +} + +#[test] +#[cfg(windows)] +fn windows_net_types_are_unwind_safe() { + use tokio::net::windows::named_pipe::NamedPipeClient; + use tokio::net::windows::named_pipe::NamedPipeServer; + + is_unwind_safe::(); + is_unwind_safe::(); +} + +fn is_unwind_safe() {}