1 #![warn(rust_2018_idioms)] 2 #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery 3 #![cfg(panic = "unwind")] 4 5 struct PanicsOnDrop; 6 7 impl Drop for PanicsOnDrop { drop(&mut self)8 fn drop(&mut self) { 9 panic!("I told you so"); 10 } 11 } 12 13 #[tokio::test] test_panics_do_not_propagate_when_dropping_join_handle()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