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

Improve diagnostic for `break` in `async { ... }` block #63391

Closed
Centril opened this issue Aug 8, 2019 · 3 comments

Comments

@Centril
Copy link
Member

commented Aug 8, 2019

With:

#![feature(async_await)]

fn foo() {
    async {
        break;
    };
}

you get:

error[E0267]: `break` inside of a closure
 --> src/lib.rs:5:9
  |
5 |         break;
  |         ^^^^^ cannot break inside of a closure

Note how it references "a closure" which seems confusing for a user who doesn't presume the implementation.

@gilescope

This comment has been minimized.

Copy link
Contributor

commented Aug 17, 2019

@rustbot claim

@gilescope

This comment has been minimized.

Copy link
Contributor

commented Aug 18, 2019

I'm assuming its ok to leave this as the same error code of E0267 - in essence it's the same error, just more specific text.

@Centril

This comment has been minimized.

Copy link
Member Author

commented Aug 18, 2019

Yeah I think it's fine.

Centril added a commit to Centril/rust that referenced this issue Aug 18, 2019

Rollup merge of rust-lang#63659 - gilescope:async-in-closure, r=Centril
Improved error message for break in async block

Fixes rust-lang#63391

@bors bors closed this in 4cf7673 Aug 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.