Skip to content
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

Lint simple expressions in manual_filter_map, manual_find_map #8958

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

Alexendoo
Copy link
Member

changelog: Lint simple expressions in [manual_filter_map], [manual_find_map]

The current comparison rules out .find(|a| a.is_some()).map(|b| b.unwrap()) because a being a reference can effect more complicated expressions, this adds a simple check for that case and adds the necessary derefs

There's some overlap with option_filter_map so lint_filter_some_map_unwrap now returns a bool to indicate it linted

@rust-highfive
Copy link

r? @giraffate

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 6, 2022
Copy link
Contributor

@giraffate giraffate left a 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 reviewing.

Overall looks good, thanks! I made one comment.

@@ -58,15 +59,15 @@ fn lint_filter_some_map_unwrap(
map_arg: &hir::Expr<'_>,
target_span: Span,
methods_span: Span,
) {
) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would be better to separate function into one that check and return bool and one that just emit the lint. I was confused that the function name lint_filter_some_map_unwrap return bool.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed it to be an is_ function

@giraffate
Copy link
Contributor

@bors r+

Thanks!

@bors
Copy link
Collaborator

bors commented Jul 7, 2022

📌 Commit 307b8cd has been approved by giraffate

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 7, 2022

⌛ Testing commit 307b8cd with merge 54feac1...

@bors
Copy link
Collaborator

bors commented Jul 7, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing 54feac1 to master...

@bors bors merged commit 54feac1 into rust-lang:master Jul 7, 2022
@Alexendoo Alexendoo deleted the simple_filter_map branch July 8, 2022 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants