-
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
Fix option_if_let_else
#7573
Fix option_if_let_else
#7573
Conversation
r? @giraffate (rust-highfive has picked a reviewer for you, use r? to override) |
* `break` and `continue` statments local to the would-be closure are allowed * don't lint in const contexts * don't lint when yield expressions are used * don't lint when the captures made by the would-be closure conflict with the other branch * don't lint when a field of a local is used when the type could be pontentially moved from * in some cases, don't lint when scrutinee expression conflicts with the captures of the would-be closure
3e28fb1
to
8b3ca9a
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.
Sorry for the late review.
changelog: don't lint when yield expressions are used in
option_if_let_else
What kind of case is this? Is there a test for this?
Additionally, it would be helpful if you split the PR or commits for each issue next time. I'm okay with that this time. |
ecda51a
to
3e5dcba
Compare
yield expressions (used in async await) can't be moved into a closure. There is a test now. |
@bors r+ Thanks! |
📌 Commit 3e5dcba has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes: #5822
fixes: #6737
fixes: #7567
The inference from #6137 still exists so I'm not sure if this should be moved from the nursery. Before doing that though I'd almost want to see this split into two lints. One suggesting
map_or
and the other suggestingmap_or_else
.map_or_else
tends to have longer expressions for both branches so it doesn't end up much shorter than a match expression in practice. It also seems most people find it harder to read.map_or
at least has the terseness benefit of being on one line most of the time, especially when theNone
branch is just a literal or path expression.changelog:
break
andcontinue
statments local to the would-be closure are allowed inoption_if_let_else
changelog: don't lint in const contexts in
option_if_let_else
changelog: don't lint when yield expressions are used in
option_if_let_else
changelog: don't lint when the captures made by the would-be closure conflict with the other branch in
option_if_let_else
changelog: don't lint when a field of a local is used when the type could be pontentially moved from in
option_if_let_else
changelog: in some cases, don't lint when scrutinee expression conflicts with the captures of the would-be closure in
option_if_let_else