Skip to content

Add new lints: const_sized_chunks_exact, const_sized_chunks_exact_mut, and const_sized_windows #15097

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

immersum
Copy link

@immersum immersum commented Jun 21, 2025

Suggests using array_chunks and array_windows (Closes #6580)

These methods are nightly-only, so the lints have been added to nursery

changelog: new lint: [const_sized_chunks_exact]
changelog: new lint: [const_sized_chunks_exact_mut]
changelog: new lint: [const_sized_windows]

@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

r? @y21

rustbot has assigned @y21.
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 rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 21, 2025
@rustbot

This comment has been minimized.

@immersum
Copy link
Author

In the three lints, the suggestions are as follows:

  • .chunks_exact(n).array_chunks()
  • .chunks_exact_mut(n).array_chunks_mut()
  • .windows(n).array_windows()

Right now, there are three lints declared for the three methods:

  • [const_sized_chunks_exact]
  • [const_sized_chunks_exact_mut]
  • [const_sized_windows]

Question 1. Do you think it would be better to reduce the number of lints to just two?

  • [const_sized_chunks_exact] – would include the checks for the _mut method
  • [const_sized_windows]

Question 2. Do you think it would be even better to reduce that number to just one?

  • [const_sized_chunks] – would include the checks for all three methods: chunks_exact, chunks_exact_mut, and windows
    Note: There are two feature gates: array_chunks and array_windows

@rustbot

This comment has been minimized.

…indows`

Suggests using (nightly) `array_chunks`, `_mut`, and `array_windows`

changelog: new lint: [`const_sized_chunks_exact`]
changelog: new lint: [`const_sized_chunks_exact_mut`]
changelog: new lint: [`const_sized_windows`]

Co-authored-by: Michał Chodzikiewicz <[email protected]>
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.

New lint: windows_const and chunks_const
3 participants