From e897b4ea51835a9fae8bb12766363e7b55b41838 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 20 Mar 2026 20:56:17 +0100 Subject: [PATCH] tests/ui/async-await/drop-option-future.rs: New regression test The test began compiling with `nightly-2022-11-25`, and more specifically 9f36f988ad873f5. The test fails to compile with `nightly-2022-11-24`: $ rustc +nightly-2022-11-24 --edition 2018 tests/ui/async-await/drop-option-future.rs error[E0597]: `value` does not live long enough --> tests/ui/async-await/drop-option-future.rs:12:22 | 12 | f = Some(async { value }); | --^^^^^-- | | | | | borrowed value does not live long enough | value captured here by generator 13 | core::mem::drop(f); 14 | } | - | | | `value` dropped here while still borrowed | borrow might be used here, when `f` is dropped and runs the destructor for type `Option>` The fix 9f36f988ad873f5 does not appear to affect or include a regression test for our issue, so let's add that test. --- tests/ui/async-await/drop-option-future.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/ui/async-await/drop-option-future.rs diff --git a/tests/ui/async-await/drop-option-future.rs b/tests/ui/async-await/drop-option-future.rs new file mode 100644 index 0000000000000..155b1d76e44ae --- /dev/null +++ b/tests/ui/async-await/drop-option-future.rs @@ -0,0 +1,16 @@ +//! Regression test for . + +//@ edition:2018 +//@ check-pass + +#![allow(dead_code)] +#![allow(unused_assignments)] + +async fn foo() { + let mut f = None; + let value = 0; + f = Some(async { value }); + core::mem::drop(f); +} + +fn main() { }