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. |
flip1995
left a comment
There was a problem hiding this comment.
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.
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()inResultby @lzutao , we should add the similar lint.changelog: none