Skip to content

Account for async closures when pointing at lifetime in return type#159256

Open
estebank wants to merge 1 commit into
rust-lang:mainfrom
estebank:coroutine-ret-ty
Open

Account for async closures when pointing at lifetime in return type#159256
estebank wants to merge 1 commit into
rust-lang:mainfrom
estebank:coroutine-ret-ty

Conversation

@estebank

Copy link
Copy Markdown
Contributor
error: lifetime may not live long enough
  --> $DIR/higher-ranked-return.rs:11:46
   |
LL |           let x = async move |x: &str| -> &str {
   |  ________________________________-________-____^
   | |                                |        |
   | |                                |        let's call the lifetime of this reference `'2`
   | |                                let's call the lifetime of this reference `'1`
LL | |             x
LL | |         };
   | |_________^ returning this value requires that `'1` must outlive `'2`

instead of

error: lifetime may not live long enough
  --> $DIR/higher-ranked-return.rs:11:46
   |
LL |           let x = async move |x: &str| -> &str {
   |  ________________________________-________----_^
   | |                                |        |
   | |                                |        return type of async closure `{async closure body@$DIR/higher-ranked-return.rs:11:46: 13:10}` contains a lifetime `'2`
   | |                                let's call the lifetime of this reference `'1`
LL | |             x
LL | |         };
   | |_________^ returning this value requires that `'1` must outlive `'2`

```
error: lifetime may not live long enough
  --> $DIR/higher-ranked-return.rs:11:46
   |
LL |           let x = async move |x: &str| -> &str {
   |  ________________________________-________-____^
   | |                                |        |
   | |                                |        let's call the lifetime of this reference `'2`
   | |                                let's call the lifetime of this reference `'1`
LL | |             x
LL | |         };
   | |_________^ returning this value requires that `'1` must outlive `'2`
```

instead of

```
error: lifetime may not live long enough
  --> $DIR/higher-ranked-return.rs:11:46
   |
LL |           let x = async move |x: &str| -> &str {
   |  ________________________________-________----_^
   | |                                |        |
   | |                                |        return type of async closure `{async closure body@$DIR/higher-ranked-return.rs:11:46: 13:10}` contains a lifetime `'2`
   | |                                let's call the lifetime of this reference `'1`
LL | |             x
LL | |         };
   | |_________^ returning this value requires that `'1` must outlive `'2`
```
@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 Jul 13, 2026
@rustbot

rustbot commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

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 75 candidates
  • Random selection from 18 candidates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants