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

mut_range_bound check for immediate break after mutation #7607

Merged
merged 4 commits into from
Sep 8, 2021

Conversation

dswij
Copy link
Member

@dswij dswij commented Aug 29, 2021

closes #7532

mut_range_bound ignores mutation on range bounds that is placed immediately before break. Still warns if the break is not always reachable.

changelog: [mut_range_bound] ignore range bound mutations before immediate break

@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 Aug 29, 2021
tests/ui/mut_range_bound.rs Outdated Show resolved Hide resolved
@dswij dswij force-pushed the mut-range-bound-break branch 2 times, most recently from b72baca to 2035b1d Compare August 30, 2021 09:18
tests/ui/mut_range_bound.rs Outdated Show resolved Hide resolved
clippy_lints/src/loops/mut_range_bound.rs Outdated Show resolved Hide resolved
@flip1995 flip1995 added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Aug 30, 2021
@bors
Copy link
Collaborator

bors commented Sep 2, 2021

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

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.

LGTM now. All comments are about technical debt with this lint, which you uncovered by working on this lint 😛

tests/ui/mut_range_bound.rs Outdated Show resolved Hide resolved
clippy_lints/src/loops/mut_range_bound.rs Outdated Show resolved Hide resolved
tests/ui/mut_range_bound.stderr Outdated Show resolved Hide resolved
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.

Last comment. Thank for addressing all of my complaints 😄

Comment on lines 401 to 402
/// False positive when mutation is not immediately followed by a break statement
/// False positive on nested expressions ([#6072](https://github.com/rust-lang/rust-clippy/issues/6072))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// False positive when mutation is not immediately followed by a break statement
/// False positive on nested expressions ([#6072](https://github.com/rust-lang/rust-clippy/issues/6072))
/// False positive when mutation is followed by a `break`, but the `break` is not immediately after the mutation:
///
/// ```
/// x += 1; // x is range bound
/// some_other_expr();
/// break; // leaves the loop so mutating is not an issue
/// ```
///
/// False positive on nested loops ([#6072](https://github.com/rust-lang/rust-clippy/issues/6072))

@flip1995
Copy link
Member

flip1995 commented Sep 8, 2021

@bors r+

Thanks!

@bors
Copy link
Collaborator

bors commented Sep 8, 2021

📌 Commit dc6f7dc has been approved by flip1995

@bors
Copy link
Collaborator

bors commented Sep 8, 2021

⌛ Testing commit dc6f7dc with merge f356784...

@bors
Copy link
Collaborator

bors commented Sep 8, 2021

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

@bors bors merged commit f356784 into rust-lang:master Sep 8, 2021
@dswij dswij deleted the mut-range-bound-break branch September 8, 2021 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mut_range_bound on immediately broken loop
4 participants