diff --git a/tokio/src/runtime/task/join.rs b/tokio/src/runtime/task/join.rs index 6c4e600b12c..400154abc7c 100644 --- a/tokio/src/runtime/task/join.rs +++ b/tokio/src/runtime/task/join.rs @@ -182,8 +182,8 @@ impl JoinHandle { /// ```rust /// use tokio::time; /// - /// #[tokio::main] - /// async fn main() { + /// # #[tokio::main(flavor = "current_thread")] + /// # async fn main() { /// # tokio::time::pause(); /// let mut handles = Vec::new(); /// @@ -204,7 +204,7 @@ impl JoinHandle { /// for handle in handles { /// assert!(handle.await.unwrap_err().is_cancelled()); /// } - /// } + /// # } /// ``` /// [cancelled]: method@super::error::JoinError::is_cancelled pub fn abort(&self) { @@ -261,9 +261,9 @@ impl JoinHandle { /// ```rust /// use tokio::{time, task}; /// - /// #[tokio::main] - /// async fn main() { - /// # tokio::time::pause(); + /// # #[tokio::main(flavor = "current_thread")] + /// # async fn main() { + /// # time::pause(); /// let mut handles = Vec::new(); /// /// handles.push(tokio::spawn(async { @@ -285,7 +285,7 @@ impl JoinHandle { /// for handle in handles { /// assert!(handle.await.unwrap_err().is_cancelled()); /// } - /// } + /// # } /// ``` /// [cancelled]: method@super::error::JoinError::is_cancelled pub fn abort_handle(&self) -> super::AbortHandle {