Skip to content

Extend invalid keyword usage help diagnostic #101627

Open
@Rageking8

Description

@Rageking8

Given the following code: link

trait Trait { }

module test {
    pub constant X: i32 = 123;
    pub immutable Y: i32 = 234;
}

implement Trait for () { }

external "Rust" fn foo() { }

fn main() {
    let mutable a = 0;
}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: expected one of `!` or `::`, found `test`
 --> src/main.rs:3:8
  |
3 | module test {
  |        ^^^^ expected one of `!` or `::`

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

There are multiple similar issues and all of them are merged (#99903 #99751 #100140). Hence, I think we should extend such behavior to all relevant rust keywords. Additional details are listed below:

  1. module -> mod
  2. constant -> const
  3. immutable -> const
  4. implement -> impl
  5. external -> extern
  6. mutable -> mut

Any of the wrong keywords on the lhs that is used in place of the right one on the rhs, should suggest changing said invalid keyword with the respective valid ones.

Metadata

Metadata

Assignees

No one assigned

    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