Skip to content

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

Closed

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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 28, 2025
  2. added
    D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.
    on Jul 28, 2025
  3. added
    A-parserArea: The lexing & parsing of Rust source code to an AST
    on Jul 29, 2025
  4. bb1yd commented on Apr 9, 2026

    @bb1yd
    Contributor

    I would like to try working on it. @rustbot claim

  5. added a commit that references this issue on May 26, 2026
  6. added a commit that references this issue on May 26, 2026
  7. added 2 commits that reference this issue on May 26, 2026
  8. bb1yd commented on May 29, 2026

    @bb1yd
    Contributor

    I think this issue should now be closed?

  9. ada4a commented on May 29, 2026

    @ada4a
    ContributorAuthor

    Thank you for working on this, @bb1yd! Yes, looks like this can be closed:)

    Btw, if you add Fixes #144595 to a PR description, then GitHub will automatically close the issue once the PR is merged. See here for more information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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