Skip to content

Wrong block referenced when emitting E0728 #63398

Closed
@Nashenas88

Description

@Nashenas88

The following code (Playground link)

#![feature(async_await)]
async fn do_the_thing() -> u8 {
    8
}

fn main() {
    let x = move || {};
    let y = do_the_thing().await;
}

Emits the incorrect error:

   Compiling playground v0.0.1 (/playground)
error[E0728]: `await` is only allowed inside `async` functions and blocks
 --> src/main.rs:8:13
  |
7 |     let x = move || {};
  |             ------- this is not `async`
8 |     let y = do_the_thing().await;
  |             ^^^^^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks

error: aborting due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

It should point to the block belonging to fn main and not the closure from the line above the usage of await.

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions