Skip to content

There's no flag to allow assert_eq to format as multi-line results #80787

@gilescope

Description

@gilescope

I think this is a bug, rather than a feature request, but maybe others will disagree - it certainly feels like a UX missed opportunitiy.

Looking at the assert_eq code, we always debug format on one line despite us having the ability to nicely format as multi-line.

https://doc.rust-lang.org/src/core/macros/mod.rs.html#48-49

Given that IDEs like intellirust have really nice diff viewers to show the difference between expected and actual it would be great if a flag could be set to allow expected and actual to be printed using the mutliline debug formatter.
(I've shown how TeamCity can show similar test output diffs on their website using a crate I rolled called cargo-service-message)

It's a small change but it would greatly improve the usability in more complex situations. I would keep single line as default, but having a multiline option would really improve test reporting.

Ultimately nothing building on top can do anything nice unless we find a way to format as {:#?}, so we really need to find a way to enable this as an option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-error-handlingArea: Error handlingA-fmtArea: `core::fmt`C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions