tikv / raft-rs

Raft distributed consensus algorithm implemented in Rust.
Apache License 2.0
2.86k stars 391 forks source link

Fix the compile error while running the cargo clippy #540

Closed git-hulk closed 3 months ago

git-hulk commented 3 months ago

I ran the instruction cargo clippy --all --all-targets -- -D clippy::all according to the README and got below error:

❯ cargo clippy --all --all-targets -- -D clippy::all
    Checking harness v0.1.0 (/Users/hulk/code/rust/raft-rs/harness)
error: you seem to use `.enumerate()` and immediately discard the index
    --> harness/tests/integration_cases/test_raft.rs:5304:54
     |
5304 |     for (_, &(l1, l2, l3, p1, p2, p3, id, state)) in tests.iter().enumerate() {
     |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
     = note: `-D clippy::unused-enumerate-index` implied by `-D clippy::all`
     = help: to override `-D clippy::all` add `#[allow(clippy::unused_enumerate_index)]`
help: remove the `.enumerate()` call
     |
5304 |     for &(l1, l2, l3, p1, p2, p3, id, state) in tests.iter() {
     |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    ~~~~~~~~~~~~
tisonkun commented 3 months ago

@git-hulk more violations are found. Please try to fix them.

git-hulk commented 3 months ago

@tisonkun Thanks for your quick review

BTW, what's Rust toolchain do you use? Perhaps we can add a rust-toolchain file or add a package.rust-version field in Cargo.toml.

I'm using the version v1.75.0

@git-hulk more violations are found. Please try to fix them.

sure, will take a look.

tisonkun commented 3 months ago

More error ... Weird. Why they are not spotted before in CI.

tisonkun commented 3 months ago

But all about styles / format

git-hulk commented 3 months ago

@tisonkun Yeah, I'm fixing them, it might be caused by the rules in the new version of the toolchain.

git-hulk commented 3 months ago

@tisonkun I have tested on my side and it works now: https://github.com/git-hulk/raft-rs/actions/runs/8454044888/job/23158169847