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