Files
rust/tests/ui/range_unfixable.rs
T
Samuel Tardieu ea2ea62fd1 Note that using enumerate() will swap the arguments
The autofix now:

- includes the swapping of index and element in the closure in which the
  content will be consumed;
- notes, with applicability `MaybeIncorrect` (because it will be), that
  the element and the index will be swapped.
2025-06-04 15:51:41 +02:00

15 lines
397 B
Rust

//@no-rustfix
#![allow(clippy::useless_vec)]
#[warn(clippy::range_zip_with_len)]
fn main() {
let v1: Vec<u64> = vec![1, 2, 3];
let v2: Vec<u64> = vec![4, 5];
// Do not autofix, `filter()` would not consume the iterator.
//~v range_zip_with_len
v1.iter().zip(0..v1.len()).filter(|(_, i)| *i < 2).for_each(|(e, i)| {
let _: &u64 = e;
let _: usize = i;
});
}