-
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
Add map unwrap or lint for Result #4822
Conversation
hmm. why following errors? I can build locally.
|
clippy build with the latest master is currently broken, it's not your fault. |
This is blocked on the stabilization of |
☔ The latest upstream changes (presumably #4839) made this pull request unmergeable. Please resolve the merge conflicts. |
rust-lang/rust#66570 merged. This could be continued. |
Thank you @lzutao for the headsup, will work on the conflicts. |
a2dad55
to
cf1e28e
Compare
conflicts resolved, could you please help review again? |
12a47b7
to
2ecaf8f
Compare
@lzutao could you please help review again? Thanks! |
☔ The latest upstream changes (presumably #4930) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Sorry for the late reply, I was on vacation. The formatting of the lint message, note and help can still be improved.
"called `map(f).unwrap_or(a)` on a Result value. \ | ||
This can be done more directly by calling `map_or(a, f)` instead" |
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.
Can you do this by using the function
span_lint_and_then(
..,
|db| {
db.note("this can be done more directly by calling `map_or(a, f)` instead");
if multiline {
db.span_help(.., format!("replace `map({}).unwrap_or({})` with `{}`", ..);
}
},
);
☔ The latest upstream changes (presumably #4962) made this pull request unmergeable. Please resolve the merge conflicts. |
Can we suggest with Result::ok().map_or case too? |
Thanks for contributing to Clippy! Sadly this PR was not updated in quite some time. If you waited on input from a reviewer, we're sorry that this fell under the radar. If you want to continue to work on this, just reopen the PR and/or ping a reviewer. |
with the introduction of
map_or()
inResult
by @lzutao , we should add the similar lint.changelog: none