Skip to content

Commit 6a7aaf9

Browse files
Rollup merge of rust-lang#154155 - Enselic:async-test, r=mati865
tests/ui/async-await/drop-option-future.rs: New regression test The test began compiling with `nightly-2022-11-25`. I bisected it further, and the commit that made it compile was 9f36f98 (rust-lang#104321). 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<impl Future<Output = i32>>` The fix 9f36f98 does not appear to affect or include a regression test for the rust-lang#98077 case, so let's add that test. Closes rust-lang#98077 since we add the test from that issue.
2 parents edf808b + e897b4e commit 6a7aaf9

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/98077>.
2+
3+
//@ edition:2018
4+
//@ check-pass
5+
6+
#![allow(dead_code)]
7+
#![allow(unused_assignments)]
8+
9+
async fn foo() {
10+
let mut f = None;
11+
let value = 0;
12+
f = Some(async { value });
13+
core::mem::drop(f);
14+
}
15+
16+
fn main() { }

0 commit comments

Comments
 (0)