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
Closed

Wrong block referenced when emitting E0728 #63398

Nashenas88 opened this issue Aug 9, 2019 · 0 comments

Comments

@Nashenas88
Copy link
Contributor

@Nashenas88 Nashenas88 commented Aug 9, 2019

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.

@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.
@bors bors closed this in #63509 Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants