Skip to content

Terse error message on tuple struct looking like regular struct #144595

@ada4a

Description

@ada4a

Code

struct Foo(a: u8, b: u8);

Current output

error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `:`
 --> src/lib.rs:4:13
  |
4 | struct Foo(a: u8, b: u8)
  |             ^ expected one of 7 possible tokens

Desired output

error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `:`
 --> src/lib.rs:4:13
  |
4 | struct Foo(a: u8, b: u8);
  |             ^ expected one of 7 possible tokens

help: if you wanted to create a tuple struct, remove field names:
 --> src/lib.rs:4:13
  |
4 ~ struct Foo(a: u8, b: u8);
  |            ---    ---

help: if you wanted to create a regular struct, use curly braces:
 --> src/lib.rs:4:13
  |
4 - struct Foo(a: u8, b: u8);
4 + struct Foo{a: u8, b: u8}

Rationale and extra context

Context: I was writing a quick reproducer, and made this silly grammatical mistake. But the error message completely threw me off

Other cases

Rust Version

(playground, stable 1.88.0 / beta 1.89.0-beta.7 / nightly 2025-07-28)

Anything else?

@rustbot label +D-terse

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-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