net: add UnwindSafe impl to PollEvented (#4384)

This commit is contained in:
Jamie
2022-01-08 13:58:26 +01:00
committed by GitHub
parent 553cc3b194
commit ac2343d984
2 changed files with 37 additions and 0 deletions
+5
View File
@@ -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<E: Source> UnwindSafe for PollEvented<E> {}
impl<E: Source> RefUnwindSafe for PollEvented<E> {}
impl<E: Source> Deref for PollEvented<E> {
type Target = E;
+32
View File
@@ -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::<tokio::net::TcpListener>();
is_unwind_safe::<tokio::net::TcpSocket>();
is_unwind_safe::<tokio::net::TcpStream>();
is_unwind_safe::<tokio::net::UdpSocket>();
}
#[test]
#[cfg(unix)]
fn unix_net_types_are_unwind_safe() {
is_unwind_safe::<tokio::net::UnixDatagram>();
is_unwind_safe::<tokio::net::UnixListener>();
is_unwind_safe::<tokio::net::UnixStream>();
}
#[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::<NamedPipeClient>();
is_unwind_safe::<NamedPipeServer>();
}
fn is_unwind_safe<T: UnwindSafe + RefUnwindSafe>() {}