-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Don't trigger use_debug lint in Debug impl #5047
Conversation
clippy_lints/src/write.rs
Outdated
.ident | ||
.name | ||
.as_str(); | ||
if trait_name == "Debug" { |
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 will also stop linting in user defined traits, named Debug
. But I guess this is a FN, we can live with.
2a3aa5e
to
b335e8d
Compare
clippy_lints/src/write.rs
Outdated
if !self.in_debug_impl && arg.format.ty == "?" { | ||
// FIXME: modify rustc's fmt string parser to give us the current span | ||
span_lint(cx, USE_DEBUG, parser.prev_span, "use of `Debug`-based formatting"); | ||
} |
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 the only change in this function, everything else is just indented once more.
2b36bd4
to
8dd3e16
Compare
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.
LGTM with one nit (this PR is just waiting for review, I'm not a reviewer though.)
☔ The latest upstream changes (presumably #5029) made this pull request unmergeable. Please resolve the merge conflicts. |
8bba9d1
to
4987e65
Compare
.expect("path has at least one segment") | ||
.ident | ||
.name; | ||
if trait_name == sym!(Debug) { |
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.
Hm, to avoid the FN, couldn't we compare the full path here instead of just the last segment? i.e if it's core::fmt::Debug
or std::fmt::Debug
?
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 think we would need to turn it in a LatePassLint
for that. I think we can live with this FN though, since it shouldn't be that common that someone defines a Debug
trait
☔ The latest upstream changes (presumably #5247) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors r+ |
📌 Commit a540b5c has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes #5039
changelog: Don't trigger [
use_debug
] lint in Debug impl