From 7e4077805bf2b2edd0493a481c71ea3d136482bd Mon Sep 17 00:00:00 2001 From: MediosZ Date: Fri, 18 Nov 2022 12:45:05 +0800 Subject: [PATCH] doc: add a comment in cancel_during_run. (#5267) Signed-off-by: Tricster Signed-off-by: Tricster --- tests/all/async_functions.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/all/async_functions.rs b/tests/all/async_functions.rs index 7d8a389b31..f2c5e74ec7 100644 --- a/tests/all/async_functions.rs +++ b/tests/all/async_functions.rs @@ -269,6 +269,9 @@ async fn cancel_during_run() { *caller.data_mut() = 1; let dtor = SetOnDrop(caller); Box::new(async move { + // SetOnDrop is not destroyed when dropping the reference of it + // here. Instead, it is moved into the future where it's forced + // to live in and will be destroyed at the end of the future. drop(&dtor); tokio::task::yield_now().await; Ok(())