External Publication
Visit Post

Change error message of a failing `assert_eq!`

Rust Internals [Unofficial] April 1, 2026
Source

ekuber:

which would provide 4 ways of opting into the change of wording without too much additional verbosity.

Come to think of it, the macro could just optionally accept any ident, defaulting to the current left/right.

Thus if you want

assert_eq!(calculated = x.sqrt(), reference = 1.3049523047);

you can do that too.

Or use translated labels, or whatever.

While that's technically breaking, any assert_eq! with an assignment as the expression is useless today because assignment has unit type and asserting unit equality is pointless.

Discussion in the ATmosphere

Loading comments...