-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New lint: windows_const and chunks_const #6580
Copy link
Copy link
Open
Labels
A-lintArea: New lintsArea: New lintsL-perfLint: Belongs in the perf lint groupLint: Belongs in the perf lint groupT-middleType: Probably requires verifiying typesType: Probably requires verifiying typesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Activity
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsL-perfLint: Belongs in the perf lint groupLint: Belongs in the perf lint groupT-middleType: Probably requires verifiying typesType: Probably requires verifiying typesgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Now that
min_const_genericsis stabilized, I suspect it won't be long forarray_windowsandarray_chunksto be stabilized as well. It would be nice to have a lint ready when that comes. But for now we can check the feature gates.What it does
Checks for usage of
windowsorchunkswith a constant size. These may be replaced witharray_windowsandarray_chunksrespectively.Categories (optional)
What is the advantage of the recommended code over the original code
It avoids heap allocation and should be more performant. Also it often simplifies the code since you can destructure the array.
Drawbacks
None.
Example
Could be written as:
Maybe we should avoid linting if the array would be too big?