Skip to content

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

Closed
@Centril

Description

@Centril

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.

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-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions