Skip to content

Suggest removing let if const let or let const is used #99910

Closed
@Rageking8

Description

@Rageking8

Given the following code:

fn main() {
    const let foo = 123;
}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected identifier, found keyword `let`
 --> src/main.rs:2:11
  |
2 |     const let foo = 123;
  |           ^^^ expected identifier, found keyword

error: expected one of `:`, `;`, or `=`, found `foo`
 --> src/main.rs:2:15
  |
2 |     const let foo = 123;
  |               ^^^ expected one of `:`, `;`, or `=`

error: missing type for `const` item
 --> src/main.rs:2:11
  |
2 |     const let foo = 123;
  |           ^^^ help: provide a type for the item: `r#let: <type>`

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

Ideally the output should inform the user that let and const are mutually exclusive and suggest the user remove the let.

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