Improve suggestions for needless_range_loop
#1864
Labels
C-bug
Category: Clippy is not doing the correct thing
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
L-suggestion
Lint: Improving, adding or fixing lint suggestions
T-middle
Type: Probably requires verifiying types
Uh oh!
There was an error while loading. Please reload this page.
Hey there. First of all: Great work to all the devs. Clippy is a real handy tool when developing in Rust.
Now about my proposal: the
needless_range_loop
gives pretty good suggestions even for non default ranges. But if a range loop like the following is linted, one could suggest to use a mutable iterator usingiter_mut()
:Clippy would suggest something like
for <item> in arr.iter().take(arr.len()-1).skip(1) {
but in this caseiter_mut()
must be used to assign new values to<item>
. I don't know if there is an easy way to detect cases like this one but I think it would be a great improvement.The text was updated successfully, but these errors were encountered: