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

break inside async closure has incorrect span for enclosing closure #124496

Closed
dtolnay opened this issue Apr 28, 2024 · 0 comments · Fixed by #125078
Closed

break inside async closure has incorrect span for enclosing closure #124496

dtolnay opened this issue Apr 28, 2024 · 0 comments · Fixed by #125078
Labels
A-diagnostics Area: Messages for errors, warnings, and lints F-async_closure `#![feature(async_closure)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Apr 28, 2024

Code

#![feature(async_closure)]

fn main() {
    let _ = || break;
    let _ = async || break;
}

Current output

error[E0267]: `break` inside of a closure
 --> src/main.rs:4:16
  |
4 |     let _ = || break;
  |             -- ^^^^^ cannot `break` inside of a closure
  |             |
  |             enclosing closure

error[E0267]: `break` inside of a closure
 --> src/main.rs:5:22
  |
5 |     let _ = async || break;
  |                      ^^^^^
  |                      |
  |                      cannot `break` inside of a closure
  |                      enclosing closure

Desired output

...

error[E0267]: `break` inside of a closure
 --> src/main.rs:5:13
  |
5 |     let _ = async || break;
  |             -------- ^^^^^
  |             |        cannot `break` inside of a closure
  |             |
  |             enclosing closure

Rust Version

rustc 1.79.0-nightly (aed2187d5 2024-04-27)
binary: rustc
commit-hash: aed2187d53b8789e3a37f50ae36f894a2a679077
commit-date: 2024-04-27
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.4
@dtolnay dtolnay added 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. F-async_closure `#![feature(async_closure)]` requires-nightly This issue requires a nightly compiler in some way. labels Apr 28, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 19, 2024
…errors

fix: break inside async closure has incorrect span for enclosing closure

Fixes rust-lang#124496
@bors bors closed this as completed in c9a9d5c Jun 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 19, 2024
Rollup merge of rust-lang#125078 - linyihai:issue-124496, r=compiler-errors

fix: break inside async closure has incorrect span for enclosing closure

Fixes rust-lang#124496
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints F-async_closure `#![feature(async_closure)]` requires-nightly This issue requires a nightly compiler in some way. 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.

1 participant