-
Notifications
You must be signed in to change notification settings - Fork 13.3k
improve custom message format in assert_eq macro #94016
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
426c85b
optimize panic message format in assert_eq macro
MakitaToki fa00953
align colons in assert_failed_inner
MakitaToki e575215
change message format in 'assert_failed_inner' function
MakitaToki 108f87e
delete trailing whitespaces
1ef6ba5
stringify original tokens
MakitaToki a1aed4a
resolve merged conflict
MakitaToki 099818b
accept local changes
MakitaToki 024f125
stringify original tokens in related macros
MakitaToki 657a52b
Merge branch 'issue-94005-fix' of github.com:Mizobrook-kan/rust into …
MakitaToki ded501c
clean up output format
MakitaToki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the intent here was to align left: and right: with each other along the
:
- probably we want to do the same with context: if we do this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated as suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I continue to submit more commits according to yaahc's suggestions, or close this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go ahead and update the format as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
panicking.rs
in core package and that one in std remains the same as the latter makes more failed tests.The current output format is like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my mistake. I definitely misunderstood your original comment. Do you want to stringify parameter names? @yaahc
Is it like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not exactly,
stringify!
stringifies exactly whatever you pass into it, so callingstringify!(op)
will just give you "op". Instead you'd need to callstringify!
from inside of theassert_eq!
macro_rules definition where you still have access to the original tokens, then you'd have to add arguments toassert_failed
andassert_failed_inner
to pass the strings all the way to the inner function that formats them, so it would look something like this:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried my best to find some code snippets that needs to be updated. Is there anything else I'm missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this looks perfect! We just need to get the exact output sorted and update the test UI files so everything passes. Right now looking at the failed test in CI the output looks like this:
So we probably want to clean this up a bit, and we may want to rethink how many times we repeat the stringified version of the expression. Here's my suggestion for what we should aim for:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated my commit