Skip to content

async-block diagnostics do not suggest async move when it may be needed #66107

Closed

Description

(playground)

//* f hits lifetime errors
fn f(a: &usize) -> (impl '_ + Future<Output = ()>, &usize) {
    (async { *a; }, a)
}
// */

// g compiles as expected
fn g(a: &usize) -> (impl '_ + Future<Output = ()>, &usize) {
    async fn h(a: &usize) { *a; }
    (h(a), a)
}
error[E0515]: cannot return value referencing function parameter `a`
 --> src/main.rs:5:5
  |
5 |     (async { *a; }, a)
  |     ^^^^^^^^^^-^^^^^^^
  |     |         |
  |     |         `a` is borrowed here
  |     returns a value referencing data owned by the current function

This issue has been assigned to @gizmondo via this comment.

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

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.

Type

No type

Projects

  • Status

    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions