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

#7594: Adding new 'while_let_some_result' linting #7608

Merged
merged 6 commits into from
Sep 28, 2021

Conversation

andrewpollack
Copy link
Member

@andrewpollack andrewpollack commented Aug 30, 2021

Excited for the opportunity to contribute to Clippy! Since the latest Bay Area Rust Meetup, I've been looking for an opportunity and found it 😄

Please let me know how I can improve this PR! Much of it is similar to [`if_let_some_result`], but I followed the description in the issue to create its own linting rules. Looking forward to feedback, and continuing to work on Clippy in the future!

changelog: Renamed Lint: if_let_some_result is now called [match_result_ok]. Now also handles while let case.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 30, 2021
Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

Looks really good, thanks!

clippy_lints/src/while_let_some_result.rs Outdated Show resolved Hide resolved
clippy_lints/src/while_let_some_result.rs Outdated Show resolved Hide resolved
clippy_lints/src/while_let_some_result.rs Outdated Show resolved Hide resolved
tests/ui/while_let_some_result.rs Outdated Show resolved Hide resolved
clippy_lints/src/lib.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Sep 2, 2021

☔ The latest upstream changes (presumably #7604) made this pull request unmergeable. Please resolve the merge conflicts.

@andrewpollack
Copy link
Member Author

@Manishearth @camsteffen Thank you for the suggestion to rename and add functionality to match_result_ok!

Although functioning, I know the syntax can be improved. After some time, I tried to do some clever if statements to pull out the small differences to the top and have them go down the same if path. Unfortunately, I struggled a bit with Rust syntax and was unsuccessful in doing so. Happy to look into fixing the syntax if some tips can be given on syntax around how to merge this statement:

if let Some(higher::WhileLet { let_pat, let_expr, .. }) = higher::WhileLet::hir(expr);
and
if let Some(higher::IfLet { let_pat, let_expr, .. }) = higher::IfLet::hir(cx, expr);

I tried if let Some(higher::WhileLet { let_pat, let_expr, .. }) = higher::WhileLet::hir(expr) | if let Some(higher::IfLet { let_pat, let_expr, .. }) = higher::IfLet::hir(cx, expr);, but the compiler did not like this formatting

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

progress, some issues left

CHANGELOG.md Outdated Show resolved Hide resolved
clippy_lints/src/match_result_ok.rs Outdated Show resolved Hide resolved
@Manishearth
Copy link
Member

@andrewpollack yeah, there's no fancy syntax, just use a match there instead, it's the first condition in the if chains. If you need you can factor out the stuff inside it into a different function to make it easier

@bors
Copy link
Contributor

bors commented Sep 24, 2021

☔ The latest upstream changes (presumably #7715) made this pull request unmergeable. Please resolve the merge conflicts.

@Manishearth Manishearth force-pushed the 7594/while_let_some_result branch from ae672b7 to baec67e Compare September 28, 2021 05:24
@Manishearth
Copy link
Member

I pushed a commit making this change, and also rebased it

(for future reference, please rebase instead of merging when there are merge conflicts, it makes it harder to do further rebases if merges are used)

@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 28, 2021

📌 Commit 17155c8 has been approved by Manishearth

@bors
Copy link
Contributor

bors commented Sep 28, 2021

⌛ Testing commit 17155c8 with merge 7a4e25c...

bors added a commit that referenced this pull request Sep 28, 2021
…ishearth

#7594: Adding new 'while_let_some_result' linting

Excited for the opportunity to contribute to Clippy! Since the latest Bay Area Rust Meetup, I've been looking for an opportunity and found it 😄

Please let me know how I can improve this PR! Much of it is similar to ``[`if_let_some_result`]``, but I followed the description in the issue to create its own linting rules. Looking forward to feedback, and continuing to work on Clippy in the future!

changelog:
- Renamed Lint: `if_let_some_result` is now called [`match_result_ok`]. Now also handles `while let` case.
@bors
Copy link
Contributor

bors commented Sep 28, 2021

💔 Test failed - checks-action_test

@Manishearth
Copy link
Member

@bors retry

(PR body changelong not in right format)

@bors
Copy link
Contributor

bors commented Sep 28, 2021

⌛ Testing commit 17155c8 with merge a2a9b1d...

bors added a commit that referenced this pull request Sep 28, 2021
…ishearth

#7594: Adding new 'while_let_some_result' linting

Excited for the opportunity to contribute to Clippy! Since the latest Bay Area Rust Meetup, I've been looking for an opportunity and found it 😄

Please let me know how I can improve this PR! Much of it is similar to ``[`if_let_some_result`]``, but I followed the description in the issue to create its own linting rules. Looking forward to feedback, and continuing to work on Clippy in the future!

changelog: Renamed Lint: `if_let_some_result` is now called [`match_result_ok`]. Now also handles `while let` case.
@bors
Copy link
Contributor

bors commented Sep 28, 2021

💔 Test failed - checks-action_dev_test

@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 28, 2021

📌 Commit 13834e6 has been approved by Manishearth

@bors
Copy link
Contributor

bors commented Sep 28, 2021

⌛ Testing commit 13834e6 with merge cbf27d0...

@bors
Copy link
Contributor

bors commented Sep 28, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Manishearth
Pushing cbf27d0 to master...

@bors bors merged commit cbf27d0 into rust-lang:master Sep 28, 2021
@andrewpollack
Copy link
Member Author

andrewpollack commented Sep 28, 2021 via email

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.

6 participants