Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard to read assert_eq!() custom message output #94005

Closed
nyurik opened this issue Feb 14, 2022 · 4 comments · Fixed by #111071
Closed

Hard to read assert_eq!() custom message output #94005

nyurik opened this issue Feb 14, 2022 · 4 comments · Fixed by #111071
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@nyurik
Copy link
Contributor

nyurik commented Feb 14, 2022

The custom message in assert_eq!(...) macro is shown right after the right:. This is hard to read because the value strings could be very long. I think it is better to print the custom message (if available) on a separate line.

fn main() {
    let a = 10;
    let b = 20;
    assert_eq!(a, b, "Values {a} and {b}");
}

The above code (playground) prints this:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `10`,
 right: `20`: Values 10 and 20', src/main.rs:4:5

Suggested output

thread 'main' panicked at 'assertion failed: `(left == right)`
   left: `10`,
  right: `20`,
context: Values 10 and 20', src/main.rs:4:5

Note that custom message and the location in source are still on the same line

@MakitaToki
Copy link
Contributor

I will try it. @rustbot claim

@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints T-libs Relevant to the library team, which will review and decide on the PR/issue. E-help-wanted Call for participation: Help is requested to fix this issue. labels Apr 26, 2023
@jyn514
Copy link
Member

jyn514 commented Apr 26, 2023

Note that the linked PR, #94016, has a lot of review comments. I think rebasing that PR and addressing the comments would already be very close to landing this change.

@jyn514 jyn514 added the E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. label Apr 26, 2023
@nyurik
Copy link
Contributor Author

nyurik commented May 1, 2023

(taking over due to inactivity) @rustbot claim

@nyurik
Copy link
Contributor Author

nyurik commented Aug 16, 2023

🎉 Horray! It only took 548 days (1.5+ years) since I created #94005 on Feb 14th, 2022. Numerous commits. Tens of people. 4 PRs... 100s of files. All to change a few lines of output :)

Special thanks to @m-ou-se for all the support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
3 participants