Skip to content

Extra semicolon inside trait definition gives nonideal error message #99822

Closed
@jdahlstrom

Description

@jdahlstrom

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.

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