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

Fix 8128 #8133

Merged
merged 1 commit into from
Dec 26, 2021
Merged

Fix 8128 #8133

merged 1 commit into from
Dec 26, 2021

Conversation

surechen
Copy link
Contributor

Fixes #8128

changelog: Fix error suggestion of skip(..).next() for immutable variable.

@rust-highfive
Copy link

r? @flip1995

(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 Dec 17, 2021
@surechen
Copy link
Contributor Author

surechen commented Dec 17, 2021

I want to add a counter example. It runs correctly in playground. link
But the CI failed

Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

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

The tests are failing, because rustfix can only apply suggestions produces by span_lint_and_sugg/span_suggestion. So you probably have to create a separate test file, that doesn't have the // run rustfix comment at the top.

clippy_lints/src/methods/iter_skip_next.rs Outdated Show resolved Hide resolved
@surechen surechen force-pushed the fix_8128 branch 2 times, most recently from d3fe52f to 0a1d532 Compare December 17, 2021 15:42
@surechen surechen requested a review from flip1995 December 17, 2021 16:04
@surechen
Copy link
Contributor Author

Hi, could you help me see this? Is it consistent with your modification suggestion? Thanks.
r? @xFrednet

@rust-highfive rust-highfive assigned xFrednet and unassigned flip1995 Dec 24, 2021
Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Hi, could you help me see this? Is it consistent with your modification suggestion?

Sure, this is what I had in mind. I again looked into a way to check this differently, but I don't see a viable solution to get the information from the type of the self argument of skip. And I think this is fine, since @flip1995 didn't mention another solution in his first review.

I have two suggestions how the output could be a bit more readable, but otherwise this looks good to me. Thank you for the work 🙃

clippy_lints/src/methods/iter_skip_next.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/iter_skip_next.rs Show resolved Hide resolved
tests/ui/iter_skip_next_unfixable.rs Show resolved Hide resolved
@surechen surechen requested a review from xFrednet December 25, 2021 06:29
@surechen
Copy link
Contributor Author

Hi, could you help me see this? Is it consistent with your modification suggestion?

Sure, this is what I had in mind. I again looked into a way to check this differently, but I don't see a viable solution to get the information from the type of the self argument of skip. And I think this is fine, since @flip1995 didn't mention another solution in his first review.

I have two suggestions how the output could be a bit more readable, but otherwise this looks good to me. Thank you for the work 🙃

Done. Thanks.

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Looks good to me! 👍

Could you please squash your commits before the merge? If you want to keep the messages, you can squash the fix #8128 commits into one and all review commits into another one.

A related note: In Rust we usually avoid mentioning the issue in commit messages as that creates a new link in the issue with every rebase. I do see the advantage of mentioning it and use that feature in other projects as well. I think the idea is more to use a descriptive commit message that can be understood without opening an issue. We can also merge commits with such messages, and I'm happy to do so if you want to keep the messages. Just something I wanted to mention, this also depends on your personal style 🙃

changelog: Fix error suggestion of skip(..).next() for immutable variable.
@surechen
Copy link
Contributor Author

Looks good to me! 👍

Could you please squash your commits before the merge? If you want to keep the messages, you can squash the fix #8128 commits into one and all review commits into another one.

A related note: In Rust we usually avoid mentioning the issue in commit messages as that creates a new link in the issue with every rebase. I do see the advantage of mentioning it and use that feature in other projects as well. I think the idea is more to use a descriptive commit message that can be understood without opening an issue. We can also merge commits with such messages, and I'm happy to do so if you want to keep the messages. Just something I wanted to mention, this also depends on your personal style 🙃

Done. Thank you very much.

@surechen surechen requested a review from xFrednet December 26, 2021 13:49
@xFrednet
Copy link
Member

LGTM, thank you for the update and quick replies! 👍

@bors r+

@bors
Copy link
Contributor

bors commented Dec 26, 2021

📌 Commit 4ffd660 has been approved by xFrednet

@bors
Copy link
Contributor

bors commented Dec 26, 2021

⌛ Testing commit 4ffd660 with merge bb7b6be...

@bors
Copy link
Contributor

bors commented Dec 26, 2021

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

@bors bors merged commit bb7b6be into rust-lang:master Dec 26, 2021
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.

skip(..).next() lint incorrectly suggest using nth() in some cases
5 participants