-
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
use of Result::unwrap_or_else over Result::map_or_else #7363
use of Result::unwrap_or_else over Result::map_or_else #7363
Conversation
r? @llogiq (rust-highfive has picked a reviewer for you, use r? to override) |
Hey there! I see you have put the basic structure together, now you may want to start fleshing out the test, then implement the actual lint. Let me know if you need any help. |
Thank you. I definitely would reach out when I need help |
@llogiq can you please help me with review |
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 feel the example suggestion is worse than the code it replaces. Ultimately I don't understand the reasoning behind this lint.
Both map_or_else
and unwrap_or_else
are about getting the return value, yet your examples only ever return ()
. Worse, process::exit
for control flow is not generally applicable and in most cases misguided.
Having read the underlying issue, I think the lint was meant to catch an |
I've updated the doc and test to give a clearer picture to the lint usage |
I'm still not happy about the example. Things I would consider lint-worthy:
Note that both are expressions that return some value (of the As soon as the |
Thanks for that. I'm kind of new to contributing, so how do I check if the map part performs any form of operation? |
For that you need to match on the second argument expression of the |
With #7330 you can do this with the function |
Any thoughts on enhancing |
Thanks for this. In my case, I checked if it was an |
As @flip1995 said, we already have a utils function to find identities. You can simply use that one. And @camsteffen is right, we should extend existing lints that fit before creating a new one. |
Not sure how the extending should work. Since map_identity matches for just |
You can just edit the implementation of |
ping from triage @Valentine-Mario. Can you have any update on this? |
☔ The latest upstream changes (presumably #7516) made this pull request unmergeable. Please resolve the merge conflicts. |
ping from triage @Valentine-Mario. According to the triage procedure, I'm closing this because 2 weeks have passed with no activity. If you have more time to work on this, feel free to reopen this. |
This PR is the lint suggested in #7328