Skip to content

For const variable declaration, if type is left dangling, also suggest type #100146

Closed
@Rageking8

Description

@Rageking8

Given the following code:

fn main() {
    const b: = 123;
}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected type, found `=`
 --> src/main.rs:2:14
  |
2 |     const b: = 123;
  |              ^ expected type

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

Since the compiler suggests the type needed for the following:

fn main() {
    const b = 123;
}
   Compiling playground v0.0.1 (/playground)
error: missing type for `const` item
 --> src/main.rs:2:11
  |
2 |     const b = 123;
  |           ^ help: provide a type for the constant: `b: i32`

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

The output ideally should also suggest the type if its left dangling.

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