diff --git a/backtrace/Cargo.toml b/backtrace/Cargo.toml index ad4a9a3..7402237 100644 --- a/backtrace/Cargo.toml +++ b/backtrace/Cargo.toml @@ -18,7 +18,7 @@ static_assertions = "1.1.0" [dev-dependencies] core_affinity = "0.5.10" criterion = { version = "0.3.4", features = ["html_reports"] } -futures = "0.3.21" +futures = "0.3.25" pretty_assertions = "1.3.0" regex = "1.6.0" smol = "1.2.5" diff --git a/backtrace/examples/taskdump.rs b/backtrace/examples/taskdump.rs index f609183..0803532 100644 --- a/backtrace/examples/taskdump.rs +++ b/backtrace/examples/taskdump.rs @@ -26,7 +26,7 @@ async fn foo() { #[async_backtrace::framed] async fn bar() { - tokio::join!(Box::pin(fiz()), Box::pin(buz())); + futures::join!(fiz(), buz()); } #[async_backtrace::framed] diff --git a/backtrace/src/lib.rs b/backtrace/src/lib.rs index ebd82b7..9f9b295 100644 --- a/backtrace/src/lib.rs +++ b/backtrace/src/lib.rs @@ -6,7 +6,15 @@ //! ```rust //! #[tokio::main] //! async fn main() { -//! foo().await; +//! tokio::select! { +//! _ = tokio::spawn(pending()) => {} +//! _ = foo() => {} +//! }; +//! } +//! +//! #[async_backtrace::framed] +//! async fn pending() { +//! std::future::pending::<()>().await //! } //! //! #[async_backtrace::framed] @@ -16,7 +24,7 @@ //! //! #[async_backtrace::framed] //! async fn bar() { -//! tokio::join!(Box::pin(fiz()), Box::pin(buz())); +//! futures::join!(fiz(), buz()); //! } //! //! #[async_backtrace::framed] @@ -26,7 +34,7 @@ //! //! #[async_backtrace::framed] //! async fn buz() { -//! println!("{}", tokio::spawn(baz()).await.unwrap()); +//! println!("{}", baz().await); //! } //! //! #[async_backtrace::framed] @@ -36,10 +44,12 @@ //! ``` //! The above program, when run, prints something like: //! ```text -//! ╼ taskdump::foo::{{closure}} at backtrace/examples/taskdump.rs:6:1 -//! └╼ taskdump::bar::{{closure}} at backtrace/examples/taskdump.rs:11:1 -//! └╼ taskdump::buz::{{closure}} at backtrace/examples/taskdump.rs:21:1 -//! ╼ taskdump::baz::{{closure}} at backtrace/examples/taskdump.rs:26:1 +//! ╼ taskdump::foo::{{closure}} at backtrace/examples/taskdump.rs:14:1 +//! └╼ taskdump::bar::{{closure}} at backtrace/examples/taskdump.rs:19:1 +//! ├╼ taskdump::buz::{{closure}} at backtrace/examples/taskdump.rs:29:1 +//! │ └╼ taskdump::baz::{{closure}} at backtrace/examples/taskdump.rs:34:1 +//! └╼ taskdump::fiz::{{closure}} at backtrace/examples/taskdump.rs:24:1 +//! ╼ taskdump::pending::{{closure}} at backtrace/examples/taskdump.rs:9:1 //! ``` pub(crate) mod frame;