Skip to content

Suggest remove extra semicolon in a trait def #159542

Description

@chenyukang

Found this issue in investigating #159492

Code

trait Factory {
    fn create() -> u32;;
    fn second() -> u32;
}

fn main() {}

Current output

error: non-item in item list
 --> src/main.rs:2:24
  |
1 | trait Factory {
  |               - item list starts here
2 |     fn create() -> u32;;
  |                        ^ non-item starts here
3 |     fn second() -> u32;
4 | }
  | - item list ends here

Desired output

error: non-item in item list
 --> src/main.rs:2:24
  |
1 | trait Factory {
  |               - item list starts here
2 |     fn create() -> u32;;
  |                        ^ non-item starts here
3 |     fn second() -> u32;
4 | }
  | - item list ends here

help: remove this semicolon
  |
2 -     fn create() -> u32;;
2 +     fn create() -> u32;

Rationale and extra context

No response

Other cases

Rust Version

rustc 1.95.0 (59807616e 2026-04-14)
binary: rustc
commit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860
commit-date: 2026-04-14
host: aarch64-apple-darwin
release: 1.95.0
LLVM version: 22.1.2

Anything else?

No response

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

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions