Skip to content

Writing array type with , instead of ; could have a friendlier error #143828

Open
@scottmcm

Description

@scottmcm

Code

struct Simd<T, const N: usize>([T; N]);

fn into_array<T, const N: usize>(v: Simd<T, N>) -> [T, N] {
    todo!()
}

Current output

error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
 --> src/lib.rs:3:54
  |
3 | fn into_array<T, const N: usize>(v: Simd<T, N>) -> [T, N] {
  |                                                      ^ expected one of 7 possible tokens

Desired output

Something noting that I probably meant to write `[T; N]` there.

Rationale and extra context

No response

Other cases

Rust Version

Nightly version: 1.90.0-nightly

(2025-07-11 855e0fe46e68d94e9f61)

Anything else?

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=ba333e09e302bf343ffdc7739581d2d7

Metadata

Metadata

Assignees

No one assigned

    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