1#![warn(rust_2018_idioms)]
2#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery
3
4struct PanicsOnDrop;
5
6impl Drop for PanicsOnDrop {
7 fn drop(&mut self) {
8 panic!("I told you so");
9 }
10}
11
12#[cfg(panic = "unwind")]
13#[tokio::test]
14async fn test_panics_do_not_propagate_when_dropping_join_handle() {
15 let join_handle = tokio::spawn(async move { PanicsOnDrop });
16
17 // only drop the JoinHandle when the task has completed
18 // (which is difficult to synchronize precisely)
19 tokio::time::sleep(std::time::Duration::from_millis(3)).await;
20 drop(join_handle);
21}
22