Skip to content

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

Closed

Description

@Rageking8

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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Aug 11, 2022
  2. chenyukang commented on Aug 11, 2022

    @chenyukang
    Member

    @rustbot claim

  3. added 3 commits that reference this issue on Aug 12, 2022
  4. Rageking8 commented on Aug 13, 2022

    @Rageking8
    ContributorAuthor

    Completed by #100396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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