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

Suggest adding ' for incorrect loop labels #49240

Closed
varkor opened this issue Mar 21, 2018 · 1 comment
Closed

Suggest adding ' for incorrect loop labels #49240

varkor opened this issue Mar 21, 2018 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@varkor
Copy link
Member

varkor commented Mar 21, 2018

fn main() {
    label: loop {}
	//     ^^^^ error: expected identifier, found keyword `loop`
}

In situations like these, a more helpful suggestion would be to change label to 'label. I imagine this error could be special cased to look at the identifier and suggest something different for loop/while/for.

@varkor varkor added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints labels Mar 21, 2018
@jonas-schievink jonas-schievink added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-parser Area: The parsing of Rust source code to an AST labels Apr 20, 2020
@ehuss
Copy link
Contributor

ehuss commented Mar 13, 2021

This appears to be resolved by #81236.

error: malformed loop label
 --> src/main.rs:2:5
  |
2 |     label: loop {}
  |     ^^^^^ help: use the correct loop label format: `'label`

@ehuss ehuss closed this as completed Mar 13, 2021
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 A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants