-
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
New lint: manual_ok_err #13740
base: master
Are you sure you want to change the base?
New lint: manual_ok_err #13740
Conversation
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
302f535
to
e9ea195
Compare
|
0e256f7
to
3826c02
Compare
69d6a3b
to
a5d134c
Compare
(the latest push is a rebase on master) |
ef3cb7d
to
c43abbf
Compare
r? @y21 |
More maintainer roulette r? @blyxyas |
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.
Everything seems to be correct, and it seems to be a very useful lint. I think it has some bright future! (Some clarity nits were found)
&& let Some((idx, is_ok)) = arms.iter().enumerate().find_map(|(arm_idx, arm)| { | ||
if let Some((is_ok, ident)) = is_ok_or_err(cx, arm.pat) | ||
&& is_some_ident(cx, arm.body, ident) | ||
{ | ||
Some((arm_idx, is_ok)) | ||
} else { | ||
None | ||
} | ||
}) |
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.
A refactoring or comment would help the clarity of this fragment!
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.
Comment added
c43abbf
to
7e3a863
Compare
The FCP just opened, we'll wait a few days and check that everything's alright. I like the idea of this lint 👍 |
Does the current implementation consider const code? It probably shouldn't lint in those cases. |
7e3a863
to
3a88396
Compare
It doesn't lint in const code (checked in |
changelog: [
manual_ok_err
]: new lintDetect manual implementations of
.ok()
or.err()
, as inwhich can be replaced by
This pattern was detected in the wild in the Rust reimplementation of coreutils: uutils/coreutils#6886 (review)