Repository navigation
Fix needless_range_loop suggests wrongly for nested index - #16634
Conversation
|
r? @Jarcho rustbot has assigned @Jarcho. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Lintcheck changes for e5af49b
This comment will be updated if you push new changes |
|
r? clippy |
|
r? clippy |
|
r? clippy |
|
r? clippy |
|
r? clippy |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hello @profetia, I hope that you don't mind we using this contribution to teach @medzernik some things about reviewing (they were very interested!). cc @medzernik Check out this comment first. |
|
@blyxyas Sure! I'm also interested to learn about reviewing, feel free to use this one! |
|
@profetia Great! In that case, we'll wait until @medzernik gets to this one. AFAIK he's already catched something interesting in another pull request. If you're also interested in reviewing, read the comment I linked earlier. If many more people are interested in this, I might do something official with it. |
There was a problem hiding this comment.
I tried a simple example with a 1D array and got the following:
error: the loop variable `i` is only used to index `vec`
--> tests/ui/needless_range_loop.rs:16:14
... 287 lines skipped ...
|
+error: the loop variable `i` is only used to index `testing_vec`
+ --> tests/ui/needless_range_loop.rs:254:14
+ |
+LL | for i in 0..3 {
+ | ^^^^
+ |
+note: for this index operation
+ --> tests/ui/needless_range_loop.rs:255:9
+ |
+LL | testing_vec[i] = 0;
+ | ^^^^^^^^^^^^^^
+help: consider using an iterator
+ |
+LL - for i in 0..3 {
+LL + for <item> in testing_vec.iter_mut().take(3) {I was wondering, wouldn't it make more sense to suggest just .iter()/iter_mut() (without the take(x == testing_vec.len()) if the length of the array matches the length of the range?
Other than that, I guess the PR is good? xD I'll leave the comment as requesting changes so the bot throws the ball, but if it's not a valid one/fit for a different review, just let me know and I'll approve the PR :D
This comment has been minimized.
This comment has been minimized.
|
@profetia I won't say much here as I'm not the reviewer, but: While code clean-ups like:
are very welcome, having them in the same commit as functional changes makes reviewing unnecessarily difficult. Please consider extracting them into a separate commit whenever possible -- that would hopefully help the maintainers review your numerous (and very welcome!) patches faster. @medzernik I think that improvement would be best to leave for another PR, as this one already does a lot of things. So I'd say let's merge this PR if it looks good to you:) |
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit fec4470173562d3eb96825d9e27bf7aae73b56f9) Signed-off-by: Wentao Guan <[email protected]>
Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns:
warning: the loop variable `i` is only used to index `self.decimals`
--> drivers/gpu/drm/drm_panic_qr.rs:410:18
|
410 | for i in 0..len {
| ^^^^^^
|
note: for this index operation
--> drivers/gpu/drm/drm_panic_qr.rs:411:13
|
411 | self.decimals[i] = (chunk % 10) as u8;
| ^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop
= note: `-W clippy::needless-range-loop` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]`
help: consider using an iterator
|
410 - for i in 0..len {
410 + for <item> in self.decimals.iter_mut().take(len) {
|
The lint did not trigger here before because it could not handle arrays
behind a field access such as `self.decimals` -- Clippy was improved to
catch those cases [1][2].
Thus clean the warning by iterating over a slice rather than using
`take()` so that an out-of-range `len` still triggers the same bounds
check as the indexed loop.
Cc: [email protected] # Needed in 6.18.y and later.
Link: rust-lang/rust-clippy#16631 [1]
Link: rust-lang/rust-clippy#16634 [2]
Assisted-by: LLM
Reviewed-by: Alexandre Courbot <[email protected]>
Reviewed-by: Jocelyn Falempe <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns:
warning: the loop variable `i` is only used to index `self.decimals`
--> drivers/gpu/drm/drm_panic_qr.rs:410:18
|
410 | for i in 0..len {
| ^^^^^^
|
note: for this index operation
--> drivers/gpu/drm/drm_panic_qr.rs:411:13
|
411 | self.decimals[i] = (chunk % 10) as u8;
| ^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop
= note: `-W clippy::needless-range-loop` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]`
help: consider using an iterator
|
410 - for i in 0..len {
410 + for <item> in self.decimals.iter_mut().take(len) {
|
The lint did not trigger here before because it could not handle arrays
behind a field access such as `self.decimals` -- Clippy was improved to
catch those cases [1][2].
Thus clean the warning by iterating over a slice rather than using
`take()` so that an out-of-range `len` still triggers the same bounds
check as the indexed loop.
Cc: [email protected] # Needed in 6.18.y and later.
Link: rust-lang/rust-clippy#16631 [1]
Link: rust-lang/rust-clippy#16634 [2]
Assisted-by: LLM
Reviewed-by: Alexandre Courbot <[email protected]>
Reviewed-by: Jocelyn Falempe <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
commit 97f8cb91a8c5658fe2ae6f5c2ff6e95474a5eb2f upstream.
Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns:
warning: the loop variable `i` is only used to index `self.decimals`
--> drivers/gpu/drm/drm_panic_qr.rs:410:18
|
410 | for i in 0..len {
| ^^^^^^
|
note: for this index operation
--> drivers/gpu/drm/drm_panic_qr.rs:411:13
|
411 | self.decimals[i] = (chunk % 10) as u8;
| ^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop
= note: `-W clippy::needless-range-loop` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]`
help: consider using an iterator
|
410 - for i in 0..len {
410 + for <item> in self.decimals.iter_mut().take(len) {
|
The lint did not trigger here before because it could not handle arrays
behind a field access such as `self.decimals` -- Clippy was improved to
catch those cases [1][2].
Thus clean the warning by iterating over a slice rather than using
`take()` so that an out-of-range `len` still triggers the same bounds
check as the indexed loop.
Cc: [email protected] # Needed in 6.18.y and later.
Link: rust-lang/rust-clippy#16631 [1]
Link: rust-lang/rust-clippy#16634 [2]
Assisted-by: LLM
Reviewed-by: Alexandre Courbot <[email protected]>
Reviewed-by: Jocelyn Falempe <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
commit 97f8cb9 upstream. Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns: warning: the loop variable `i` is only used to index `self.decimals` --> drivers/gpu/drm/drm_panic_qr.rs:410:18 | 410 | for i in 0..len { | ^^^^^^ | note: for this index operation --> drivers/gpu/drm/drm_panic_qr.rs:411:13 | 411 | self.decimals[i] = (chunk % 10) as u8; | ^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop = note: `-W clippy::needless-range-loop` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]` help: consider using an iterator | 410 - for i in 0..len { 410 + for <item> in self.decimals.iter_mut().take(len) { | The lint did not trigger here before because it could not handle arrays behind a field access such as `self.decimals` -- Clippy was improved to catch those cases [1][2]. Thus clean the warning by iterating over a slice rather than using `take()` so that an out-of-range `len` still triggers the same bounds check as the indexed loop. Cc: [email protected] # Needed in 6.18.y and later. Link: rust-lang/rust-clippy#16631 [1] Link: rust-lang/rust-clippy#16634 [2] Assisted-by: LLM Reviewed-by: Alexandre Courbot <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
… 1.100.0 (dfinity#12142) `cargo clippy` fixes to prepare for upgrading to [rustc-1.100.0](https://blog.rust-lang.org/2026/11/12/Rust-1.100.0/). Clippy 0.1.100 reports **10 sites** that 0.1.99 does not, in 9 files. All of them are in hand-written code. Nine are fixed in the code and one gets a local `#[allow]` (see below), so no new global `--allow` is needed: | lint | sites | why it fires now | fix | | --- | --: | --- | --- | | [`needless_range_loop`](https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#needless_range_loop) | 4 | [#16634](rust-lang/rust-clippy#16634), which is missing from the changelog, makes the lint look through field accesses. So `self.coefficients[i]` and `public_key_bytes.0[i]` are now linted like `v[i]` | iterate over the elements instead of the indices, with `.enumerate()` where the index is used too. The two test loops that zero a public key become `.fill(0)` | | [`needless_bool`](https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#needless_bool) | 3 | [#17185](rust-lang/rust-clippy#17185): now also lints the early-return guard form `if !c { return false; } true` | return the condition, except in SNS governance's `list_proposals` (see below) | | [`unnecessary_fold`](https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#unnecessary_fold) | 2 | [#17445](rust-lang/rust-clippy#17445): now lints `fold` over an `Option`'s iterator | `archive_guard.as_ref().map_or(0, \|archive\| archive.nodes().len())` in the ICP and ICRC-1 ledgers' `encode_metrics` | | [`duplicated_attributes`](https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#duplicated_attributes) | 1 | [#17396](rust-lang/rust-clippy#17396) moved the check from items to every attribute list, so struct fields are now checked too | `ic-admin`'s `chain_key_configs_to_generate` had `#[clap(long)]` both above and below its doc comment. Now it has one, below the doc comment (see below) | Each fix keeps the behaviour. One deserves a word: `query_stats`' `duplicate_id_test` still needs its index for the match guard, the expected canister ID and the panic messages. So it now iterates `test_stats.stats.iter().enumerate().take(3)`, which runs the same three iterations as `0..3` over its four stats. Its doc comment also describes a fourth case (canister 4) that the loop has never covered. This PR leaves that as it is. Two changes come from review: * **SNS governance's `list_proposals`** keeps the early-return form of its last proposal filter. Every filter in its `filter_all` closure rejects a proposal with an early `return false`, and returning only the last one's condition would break that pattern. So the closure gets `#[allow(clippy::needless_bool)]` instead. The lint exists in Clippy 0.1.99 too, so the allow is valid on both toolchains. * **`update_subnet.rs`** now has every `#[clap(long)]` right above its field, below the doc comment. Before, 12 of the 20 fields with a plain `#[clap(long)]` had it above the doc comment (`chain_key_configs_to_generate` on both sides). The help output of `ic-admin propose-to-update-subnet` (`-h` and `--help`) is byte-for-byte unchanged. Other `ic-admin` files keep their mixed order. The two global allows that dfinity#11734 added stay for now: * **`double_must_use`**: Clippy 0.1.100 ships the fix ([#17547](rust-lang/rust-clippy#17547)) and reports nothing without the allow. But 0.1.99 still needs it, so the PR stacked on this one removes it. * **`redundant_field_names`**: 0.1.100 still flags the same 41 sites in thiserror and derive-new output. The fix, [rust-lang/rust#164816](rust-lang/rust#164816), ships in 1.101. Because this PR lands *before* the toolchain bump, it has to stay clean on 1.99.1 too. It uses no API that 1.99.1 lacks. The toolchain upgrade itself is the PR stacked on top of this one (dfinity#12143). ## Testing * `./ci/scripts/rust-lint.sh` exits 0 both on the currently pinned **1.99.1** and on **1.100.0**. * On 1.99.1, these pass: * `cargo check --all-targets --all-features` of the 9 touched crates * `bazel build` of the 32 directly affected targets * Of the 284 tests that depend on the touched files within two hops, 262 passed locally before the run was stopped in favour of CI (`CI_ALL_BAZEL_TARGETS`). The other 22: * 3 failures are environmental: the golden-state tests (`icrc_ledger_suite_integration_golden_state_upgrade_downgrade_test`, its `_u256` variant and `golden_state_swap_upgrade_twice`) cannot fetch their state over SSH from the dev environment. * 19 had not run yet: subnet-recovery and subnet-cooling-down system tests, which depend on `ic-admin`. This PR's changes to `ic-admin` leave its `propose-to-update-subnet` help output as it was. * For the review changes, on 1.99.1: `cargo check --all-targets --all-features` of `ic-sns-governance` and `ic-admin`, and `bazel build` of their 6 directly affected targets pass. Of the 114 tests within two hops of these two files, 94 had finished when the local run was stopped in favour of CI: 93 passed, and `golden_state_swap_upgrade_twice` failed because it can't fetch its golden state over SSH from the dev environment. * CI with `CI_ALL_BAZEL_TARGETS` passed on 4720dcc. The review changes get the default diff-based CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Closes #11529
Closes #16631
Closes #15560
Closes #16344
This PR addresses two problems of
needless_range_loop:changelog: [
needless_range_loop] fix wrong suggestions for nested index