Skip to content

Suggest associated const for incorrect use of let in traits #101797

Closed

Description

@Rageking8

Given the following code: link

trait Trait {
    let x: i32;
}

fn main() {

}

The current output is:

   Compiling playground v0.0.1 (/playground)
error: non-item in item list
 --> src/main.rs:2:5
  |
1 | trait Trait {
  |             - item list starts here
2 |     let x: i32;
  |     ^^^ non-item starts here
3 | }
  | - item list ends here

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

Ideally the output should suggest changing the let to a const for associated const. Thanks.

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 Sep 14, 2022
  2. chenyukang commented on Sep 15, 2022

    @chenyukang
    Member

    @rustbot claim

  3. added a commit that references this issue on Sep 15, 2022
    98e20c0
  4. added a commit that references this issue on Sep 16, 2022
    72d9e08
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