Skip to content

Add missing semicolon suggestion for global variable declarations #100533

@Rageking8

Description

@Rageking8
Contributor

Given the following code: link

const x: i32 = 123

fn main() {

}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected one of `.`, `;`, `?`, or an operator, found keyword `fn`
 --> src/main.rs:3:1
  |
1 | const x: i32 = 123
  |                   - expected one of `.`, `;`, `?`, or an operator
2 |
3 | fn main() {
  | ^^ unexpected token

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

Ideally the output should suggest putting a semicolon at the end of the declaration, since that suggestion is present if that declaration is placed in the main function.

Activity

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 14, 2022
chenyukang

chenyukang commented on Aug 14, 2022

@chenyukang
Member

@rustbot claim

removed their assignment
on Aug 14, 2022
self-assigned this
on Aug 15, 2022
added 2 commits that reference this issue on Aug 23, 2022
b9bc9e0
54d0f50
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

    Participants

    @chenyukang@TaKO8Ki@Rageking8

    Issue actions

      Add missing semicolon suggestion for global variable declarations · Issue #100533 · rust-lang/rust