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

For global variable declaration, suggest const if let is used instead #100394

Closed
Rageking8 opened this issue Aug 11, 2022 · 2 comments
Closed

For global variable declaration, suggest const if let is used instead #100394

Rageking8 opened this issue Aug 11, 2022 · 2 comments
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 Aug 11, 2022

Given the following code : link

let X: i32 = 12;

fn main() {

}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected item, found keyword `let`
 --> src/main.rs:1:1
  |
1 | let X: i32 = 12;
  | ^^^ expected item

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

Ideally the output should inform the user that let cannot be used to create global variables and suggest using const instead. (Might need a little rephrasing).

@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 Aug 11, 2022
@chenyukang
Copy link
Member

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 12, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 12, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 12, 2022
@Rageking8
Copy link
Contributor Author

Completed by #100396

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

No branches or pull requests

2 participants