Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Rageking8 opened this issue Sep 14, 2022 · 1 comment · Fixed by #101843
Closed

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

Rageking8 opened this issue Sep 14, 2022 · 1 comment · Fixed by #101843
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Rageking8
Copy link
Contributor

Rageking8 commented Sep 14, 2022

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.

@Rageking8 Rageking8 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 14, 2022
@chenyukang
Copy link
Member

@rustbot claim

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 16, 2022
Suggest associated const for incorrect use of let in traits

Fixes rust-lang#101797
@bors bors closed this as completed in 98e20c0 Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants