Skip to content

tests/ui/async-await/drop-option-future.rs: New regression test#154155

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Enselic:async-test
Mar 21, 2026
Merged

tests/ui/async-await/drop-option-future.rs: New regression test#154155
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Enselic:async-test

Conversation

@Enselic
Copy link
Member

@Enselic Enselic commented Mar 20, 2026

The test began compiling with nightly-2022-11-25. I bisected it further, and the commit that made it compile was 9f36f98 (#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 #98077 case, so let's add that test.

Closes #98077 since we add the test from that issue.

The test began compiling with `nightly-2022-11-25`, and more
specifically 9f36f98. 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 our issue, so let's add that test.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 20, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 20, 2026

r? @mati865

rustbot has assigned @mati865.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 13 candidates

@mati865
Copy link
Member

mati865 commented Mar 20, 2026

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 20, 2026

📌 Commit e897b4e has been approved by mati865

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 20, 2026
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.
rust-bors bot pushed a commit that referenced this pull request Mar 21, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #154154 (Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings)
 - #154155 (tests/ui/async-await/drop-option-future.rs: New regression test)
 - #146961 (Allow passing `expr` metavariable as `cfg` predicate)
 - #154118 (don't suggest non-deriveable traits for unions)
 - #154120 (Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`)
 - #154156 (Moving issue-52049 to borrowck)
rust-bors bot pushed a commit that referenced this pull request Mar 21, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #154154 (Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings)
 - #154155 (tests/ui/async-await/drop-option-future.rs: New regression test)
 - #146961 (Allow passing `expr` metavariable as `cfg` predicate)
 - #154118 (don't suggest non-deriveable traits for unions)
 - #154120 (Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`)
 - #154156 (Moving issue-52049 to borrowck)
@rust-bors rust-bors bot merged commit 6a7aaf9 into rust-lang:main Mar 21, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable lifetime is wrongly tracked in async fn

3 participants