Skip to content

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

Merged

Conversation

inquisitivecrystal
Copy link
Contributor

Currently, if someone tries to pass value that does not implement Debug or Display to a formatting macro, they get a very verbose and confusing error message. This PR changes the error messages for missing Debug and Display 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 or Display 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 for Debug and Display, 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.

@rust-highfive
Copy link
Contributor

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 16, 2021
@estebank
Copy link
Contributor

r? @estebank
@bors r+

@bors
Copy link
Collaborator

bors commented Jun 23, 2021

📌 Commit 20ea5fe has been approved by estebank

@rust-highfive rust-highfive assigned estebank and unassigned jackh726 Jun 23, 2021
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 23, 2021
@bors
Copy link
Collaborator

bors commented Jun 23, 2021

⌛ Testing commit 20ea5fe with merge 8cb207a...

@bors
Copy link
Collaborator

bors commented Jun 23, 2021

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 8cb207a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 23, 2021
@bors bors merged commit 8cb207a into rust-lang:master Jun 23, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce verbosity of E0277 for Debug and Display
7 participants