Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong block referenced when emitting E0728 #63398

Closed
Nashenas88 opened this issue Aug 9, 2019 · 0 comments · Fixed by #63509
Closed

Wrong block referenced when emitting E0728 #63398

Nashenas88 opened this issue Aug 9, 2019 · 0 comments · Fixed by #63509
Assignees
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Nashenas88
Copy link
Contributor

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.

@Centril Centril added A-async-await Area: Async & Await C-bug Category: This is a bug. A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. labels Aug 9, 2019
@estebank estebank self-assigned this Aug 13, 2019
Centril added a commit to Centril/rust that referenced this issue Aug 14, 2019
Point at the right enclosing scope when using `await` in non-async fn

Fix rust-lang#63398.
Centril added a commit to Centril/rust that referenced this issue Aug 14, 2019
Point at the right enclosing scope when using `await` in non-async fn

Fix rust-lang#63398.
Centril added a commit to Centril/rust that referenced this issue Aug 14, 2019
Point at the right enclosing scope when using `await` in non-async fn

Fix rust-lang#63398.
Centril added a commit to Centril/rust that referenced this issue Aug 14, 2019
Point at the right enclosing scope when using `await` in non-async fn

Fix rust-lang#63398.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants