Skip to content

Terse diagnostic "unexpected end of macro invocation" when misusing assert_eq! #103238

Open
@jruderman

Description

@jruderman

Given the following code (playground):

fn main() {
    assert_eq!(1 + 2 == 3);
}

Current output: terse

error: unexpected end of macro invocation
 --> src/main.rs:2:26
  |
2 |     assert_eq!(1 + 2 == 3);
  |                          ^ missing tokens in macro arguments

Better output: show macro correspondence

note:          This expression was treated as the $left argument to assert_eq!
  |
2 |     assert_eq!(1 + 2 == 3);
  |                ^^^^^^^^^^

note:          Following $left, assert_eq! expects ","

(See also #97108, which also asks for more verbose "missing tokens in macro arguments" errors.)

Ideal output: fix my mistake

help: To assert equality, separate the two expressions with a comma:
  |
2 |     assert_eq!(1 + 2, 3);
  |                     ^

(See also #57507, which asks for specific diagnostics when making a similar mistake with the assert! macro.)

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