-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Better errors for Debug and Display traits #86386
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
Better errors for Debug and Display traits #86386
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jackh726 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
📌 Commit 20ea5fe has been approved by |
☀️ Test successful - checks-actions |
Currently, if someone tries to pass value that does not implement
Debug
orDisplay
to a formatting macro, they get a very verbose and confusing error message. This PR changes the error messages for missingDebug
andDisplay
impls to be less overwhelming in this case, as suggested by #85844. I was a little less aggressive in changing the error message than that issue proposed. Still, this implementation would be enough to reduce the number of messages to be much more manageable.After this PR, information on the cause of an error involving a
Debug
orDisplay
implementation would suppressed if the requirement originated within a standard library macro. My reasoning was that errors originating from within a macro are confusing when they mention details that the programmer can't see, and this is particularly problematic forDebug
andDisplay
, which are most often used via macros. It is possible that either a broader or a narrower criterion would be better. I'm quite open to any feedback.Fixes #85844.