Add error_format_without_sources lint#16772
Draft
sruggier wants to merge 1 commit intorust-lang:masterfrom
Draft
Add error_format_without_sources lint#16772sruggier wants to merge 1 commit intorust-lang:masterfrom
sruggier wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
Lintcheck changes for 3f0913a
This comment will be updated if you push new changes |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds a new lint that triggers whenever a formatting operation (Display or Debug) is directly invoked on an instance of an
std::error::Errortype that may provide cause information. It ignores Error types that don't provide a non-default implementation of thesourcefunction.To catch bad uses of logging related macros, I chose to make the lint trigger on code within proc macros. Because of that, the implementation isn't able to use FormatArgsStorage unless FormatArgsCollector is updated to collect instances from inside proc macro expansions.
I'm opening this in a draft state to see if there's openness to updating FormatArgsCollector, and solicit feedback in general. For what it's worth, I've used the lint in a large codebase, and it works quite well, so I think it's worth adding in some form.
Fixes #10076.
Review checklist:
.stderrfile)cargo testpasses locally (dogfood fails because of a few warnings from the new lint)cargo dev update_lintscargo dev fmtMy own checklist of possible improvements:
changelog: [
error_format_without_sources]: new lint added