1#![warn(rust_2018_idioms)]
2#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi does not support panic recovery
3
4use std::panic::{RefUnwindSafe, UnwindSafe};
5
6#[test]
7fn notify_is_unwind_safe() {
8 is_unwind_safe::<tokio::sync::Notify>();
9}
10
11#[test]
12fn join_handle_is_unwind_safe() {
13 is_unwind_safe::<tokio::task::JoinHandle<()>>();
14}
15
16#[test]
17fn net_types_are_unwind_safe() {
18 is_unwind_safe::<tokio::net::TcpListener>();
19 is_unwind_safe::<tokio::net::TcpSocket>();
20 is_unwind_safe::<tokio::net::TcpStream>();
21 is_unwind_safe::<tokio::net::UdpSocket>();
22}
23
24#[test]
25#[cfg(unix)]
26fn unix_net_types_are_unwind_safe() {
27 is_unwind_safe::<tokio::net::UnixDatagram>();
28 is_unwind_safe::<tokio::net::UnixListener>();
29 is_unwind_safe::<tokio::net::UnixStream>();
30}
31
32#[test]
33#[cfg(windows)]
34fn windows_net_types_are_unwind_safe() {
35 use tokio::net::windows::named_pipe::NamedPipeClient;
36 use tokio::net::windows::named_pipe::NamedPipeServer;
37
38 is_unwind_safe::<NamedPipeClient>();
39 is_unwind_safe::<NamedPipeServer>();
40}
41
42fn is_unwind_safe<T: UnwindSafe + RefUnwindSafe>() {}
43