rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

Add manual_checked_div lint

Open amerikrainian opened this issue 1 month ago • 3 comments

changelog: [manual_checked_div]: new lint suggesting checked_div instead of manual zero checks before unsigned division

Implements the manual checked div from rust-lang/rust-clippy#12894. I'm relatively new to Rust and a complete newbie at Clippy, so my apologies if I forgot anything. I looked through the linked issue and could not find anything talking about the above lint.

amerikrainian avatar Nov 28 '25 01:11 amerikrainian

r? @samueltardieu

rustbot has assigned @samueltardieu. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Nov 28 '25 01:11 rustbot

No changes for aef068ae15396b39b86bd45249ec92f24fb98db2

github-actions[bot] avatar Nov 28 '25 01:11 github-actions[bot]

:umbrella: The latest upstream changes (possibly a10cafebcdd63d95823ec8bff67a22a71a15a32d) made this pull request unmergeable. Please resolve the merge conflicts.

rustbot avatar Dec 02 '25 19:12 rustbot

@amerikrainian Could you look at, and probably apply, @ada4a's suggestions? @rustbot author

samueltardieu avatar Dec 15 '25 13:12 samueltardieu

Reminder, once the PR becomes ready for a review, use @rustbot ready.

rustbot avatar Dec 15 '25 13:12 rustbot

@amerikrainian Could you look at, and probably apply, @ada4a's suggestions? @rustbot author

Yes. I'm sorry. I'm a student and we're in the finals season, so I am deep in the trenches until tomorrow; will do my best to get this done before Friday.

amerikrainian avatar Dec 15 '25 13:12 amerikrainian

No hurry, I just wanted to make sure you noticed them. Take your time.

samueltardieu avatar Dec 15 '25 13:12 samueltardieu

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

rustbot avatar Dec 16 '25 03:12 rustbot

Applied @ada4a’s suggestions and rebased.

I also went ahead and gave multiple divisions implementation a shot; it turned out to be rather straightforward, although I'm not sure if the current form is what was intended.

I promise future feedback won't take as long to be applied.

@rustbot ready

amerikrainian avatar Dec 16 '25 05:12 amerikrainian

I'm happy to update this for the /=, %, and %= cases, I just wanted to ensure that this is what you had in mind. I updated the tests with the listed negative examples and enforced first use/purity of divisor expressions since I think it's more trickier and extension to other ops should be mechanical and straightforward. Is this what you intended?

@rustbot ready

amerikrainian avatar Dec 16 '25 14:12 amerikrainian

:umbrella: The latest upstream changes (possibly 741b684c90097002ca98322160c6c92e7a248b47) made this pull request unmergeable. Please resolve the merge conflicts.

rustbot avatar Dec 18 '25 14:12 rustbot