Skip to content

Unhelpful error when array elements aren't separated by commas #92089

Closed
@adamchalmers

Description

@adamchalmers

Given the following code (playground):

fn main() {
    let all_tests = [
        ("C200B40A82", 3)
        ("C200B40A82", 3)
    ];
}

The current output is:

error[E0618]: expected function, found `(&'static str, {integer})`
 --> src/main.rs:3:9
  |
3 |           ("C200B40A82", 3)
  |  _________-^^^^^^^^^^^^^^^^
4 | |         ("C200B40A82", 3)
  | |_________________________- call expression requires function

For more information about this error, try `rustc --explain E0618`.
error: could not compile `playground` due to previous error

Ideally the output should look like:

Items in arrays, vec![] or tuples need to be separated by commas

and the compiler would preview the fix, by adding the commas in green.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTT-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