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

Add lint to suggest as_chunks over chunks_exact with constant

Open rommeld opened this issue 2 months ago • 6 comments

Adds a new lint chunks_exact_to_as_chunks that suggests using as_chunks instead of chunks_exact when the chunk size is a compile-time constant.

changelog: [chunks_exact_to_as_chunks]: Suggest using slice.as_chunks::<N>() when chunks_exact(N) is called with a compile-time constant. This provides better ergonomics and type safety.

fixes rust-lang/rust-clippy#15882

rommeld avatar Nov 01 '25 11:11 rommeld

r? @Jarcho

rustbot has assigned @Jarcho. 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 01 '25 11:11 rustbot

:warning: Warning :warning:

  • There are issue links (such as #123) in the commit messages of the following commits. Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.
    • 210a439be81b6caea318985099a57ac6a028f640

rustbot avatar Nov 01 '25 11:11 rustbot

Lintcheck changes for 219eca31fb19ef3e0f718b303b5074ad45413019

Lint Added Removed Changed
clippy::chunks_exact_with_const_size 9 0 0

This comment will be updated if you push new changes

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

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 Nov 04 '25 18:11 rustbot

:warning: Warning :warning:

  • There are issue links (such as #123) in the commit messages of the following commits. Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.
    • 3d3d2bef1058f547623cf7894b9ec11dc2f9b129

rustbot avatar Nov 04 '25 18:11 rustbot

FCP started: https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/FCP.3A.20.60chunks_exact_with_const_size.60/with/556737670

Jarcho avatar Nov 17 '25 03:11 Jarcho

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

rustbot avatar Dec 12 '25 20:12 rustbot