-
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
Lint *Error types that don't implement core::error::Error #14291
base: master
Are you sure you want to change the base?
Lint *Error types that don't implement core::error::Error #14291
Conversation
6511d2f
to
f75282e
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.
Very good first patch! I have some comments. Thanks for the contribution and sorry for the delay. I didn't see that you were a first-time contributor, I like to prioritize first-timers here 🤠
94495fc
to
3d42fe0
Compare
d56dea7
to
db050cc
Compare
Thanks for the review ❤️ Noticed this suggestion, should I add that too?
|
Hey, just wanted to chime in as a user: thanks a ton for implementing and reviewing this! |
// Identify types which likely represent errors | ||
&& { | ||
let name: &str = item.ident.name.as_str(); | ||
name.ends_with("Error") && name != "Error" |
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.
There should be a comment here about why an item named "Error" shouldn't be caught by this lint.
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.
Originally added that because I didn't want clippy to recommend a change that triggers another lint, but thinking about it I'll remove that check.
use rustc_session::impl_lint_pass; | ||
use rustc_span::sym; | ||
|
||
declare_clippy_lint! { |
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.
Should the docs for this lint link back to the error-impl-error lint?
I can see how this would be very useful, but there can also exist error types unrelated. An associated |
I also want to add a check that skips the lint if there's a |
For that, you can use
|
fixes #1291
See the linked issue.
Running linkcheck, this lint triggered
63 times3 of which are triggered because the crate supports Rust 1.80 or olderI could see this lint generating a false positives if there is e.g. a
pub struct CalcError(f32);
that describes the amount of error in some calculation, but I that's the exception.changelog: [
missing_error_implementations
]: New lint that checks for exported types that should likely implementError
, but don't.