Skip to content

Slightly improve error message for invalid identifer  #104088

Closed
@Rageking8

Description

@Rageking8

Given the following code: link

fn main() {
    let 1x = 123;
}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: invalid suffix `x` for number literal
 --> src/main.rs:2:9
  |
2 |     let 1x = 123;
  |         ^^ invalid suffix `x`
  |
  = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)

error: could not compile `playground` due to previous error

Ideally the output should inform the user that an identifier cannot start with a digit and not that the proceeding characters is an invalid suffix (since a literal in that place is invalid in the first place). Thanks.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-papercutDiagnostics: An error or lint that needs small tweaks.T-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