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 removing let if const let or let const is used #99910

Closed
Rageking8 opened this issue Jul 29, 2022 · 1 comment · Fixed by #100115
Closed

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

Rageking8 opened this issue Jul 29, 2022 · 1 comment · Fixed by #100115
Assignees
Labels
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.

Comments

@Rageking8
Copy link
Contributor

Rageking8 commented Jul 29, 2022

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.

@Rageking8 Rageking8 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. labels Jul 29, 2022
@obeis
Copy link
Contributor

obeis commented Jul 30, 2022

@rustbot claim

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 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.

2 participants