Skip to content

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

Open
Enselic wants to merge 1 commit intorust-lang:mainfrom
Enselic:async-test
Open

tests/ui/async-await/drop-option-future.rs: New regression test#154155
Enselic wants to merge 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.
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.
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