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

Extra semicolon inside trait definition gives nonideal error message #99822

Closed
jdahlstrom opened this issue Jul 27, 2022 · 0 comments · Fixed by #100446
Closed

Extra semicolon inside trait definition gives nonideal error message #99822

jdahlstrom opened this issue Jul 27, 2022 · 0 comments · Fixed by #100446
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

@jdahlstrom
Copy link

Given the following code: (playground)

trait Foo {
    fn bar() {};
}

The current output is:

error: non-item in item list
 --> src/lib.rs:2:16
  |
1 | trait Foo {
  |           - item list starts here
2 |     fn bar() {};
  |                ^ non-item starts here
3 | }
  | - item list ends here

(In both stable 1.62.1 and nightly)

Ideally the output could be less generic and use more precise terms like "an unexpected semicolon" rather than "non-item" and "trait definition" rather than "item list", as well have a note that suggests removing the semicolon and provide rationale. I originally hit this error message after I added a default definition to a trait function and forgot to remove the semicolon.

@jdahlstrom jdahlstrom 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 Jul 27, 2022
@TaKO8Ki TaKO8Ki self-assigned this Jul 28, 2022
@bors bors closed this as completed in 86e1d1e Aug 14, 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