Skip to content

Suggest joining two identifiers if the grammer is invalid and they would form a keyword #89640

Closed
@Noratrieb

Description

@Noratrieb

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9adebfa3cae4c99b1fa5c0c9f25e154a

fn main() {
    l et x = 5;
}

The current output is:

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `et`
 --> src/main.rs:2:7
  |
2 |     l et x = 5;
  |       ^^ expected one of 8 possible tokens

Ideally the output should look like:

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `et`
 --> src/main.rs:2:7
  |
2 |     l et x = 5;
  |       ^^ expected one of 8 possible tokens

     hint: did you accidentally put a space inside the keyword `let`?

Sometimes you accidentally insert whitespace inside a keyword, and might not notice it immediately. This minimal case is pretty obvious, but it might not actually always be that obvious if a lot is going on.

This could even be extended to cover all names in scope.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions