From cd5a570d68bd2d475ef3d1cd9d2203b5bdb15403 Mon Sep 17 00:00:00 2001 From: lichuang Date: Sun, 2 Jan 2022 09:31:56 +0800 Subject: [PATCH] fix clippy warning --- async-raft/src/core/admin.rs | 4 ++-- async-raft/src/core/client.rs | 2 +- async-raft/src/lib.rs | 1 - async-raft/src/raft.rs | 1 + async-raft/tests/add_remove_voter.rs | 4 ++-- async-raft/tests/concurrent_write_and_add_non_voter.rs | 4 ++-- async-raft/tests/membership/t30_commit_joint_config.rs | 6 ++---- async-raft/tests/membership/t40_removed_follower.rs | 4 ++-- memstore/src/lib.rs | 1 - 9 files changed, 12 insertions(+), 15 deletions(-) diff --git a/async-raft/src/core/admin.rs b/async-raft/src/core/admin.rs index c8d0ffbfd..95432cc5b 100644 --- a/async-raft/src/core/admin.rs +++ b/async-raft/src/core/admin.rs @@ -165,8 +165,8 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork, S: RaftStorage // TODO(xp): 111 test adding a node that is not non-voter. // TODO(xp): 111 test adding a node that is lagging. - for new_node in members.difference(&self.core.effective_membership.membership.get_ith_config(0).unwrap()) { - match self.nodes.get(&new_node) { + for new_node in members.difference(self.core.effective_membership.membership.get_ith_config(0).unwrap()) { + match self.nodes.get(new_node) { // Node is ready to join. Some(node) => { if node.is_line_rate(&self.core.last_log_id, &self.core.config) { diff --git a/async-raft/src/core/client.rs b/async-raft/src/core/client.rs index 1af793347..1cf96ec24 100644 --- a/async-raft/src/core/client.rs +++ b/async-raft/src/core/client.rs @@ -296,7 +296,7 @@ impl<'a, D: AppData, R: AppDataResponse, N: RaftNetwork, S: RaftStorage pub(super) async fn client_request_post_commit(&mut self, req: ClientRequestEntry) { let entry = &req.entry; - let apply_res = self.apply_entry_to_state_machine(&entry).await; + let apply_res = self.apply_entry_to_state_machine(entry).await; self.send_response(entry, apply_res, req.tx).await; diff --git a/async-raft/src/lib.rs b/async-raft/src/lib.rs index 773c8d00e..949ca6a54 100644 --- a/async-raft/src/lib.rs +++ b/async-raft/src/lib.rs @@ -1,6 +1,5 @@ #![doc = include_str!("../README.md")] #![feature(backtrace)] -#![feature(bound_cloned)] pub mod config; mod core; diff --git a/async-raft/src/raft.rs b/async-raft/src/raft.rs index 8b96b4a22..870f5293a 100644 --- a/async-raft/src/raft.rs +++ b/async-raft/src/raft.rs @@ -759,6 +759,7 @@ impl Membership { Membership::new_single(btreeset! {id}) } + #[must_use] pub fn to_final_config(&self) -> Self { assert!(!self.configs.is_empty()); diff --git a/async-raft/tests/add_remove_voter.rs b/async-raft/tests/add_remove_voter.rs index aa92a4f66..4f18f1c2c 100644 --- a/async-raft/tests/add_remove_voter.rs +++ b/async-raft/tests/add_remove_voter.rs @@ -135,7 +135,7 @@ async fn wait_log(router: std::sync::Arc, node_ids: &BTree for i in node_ids.iter() { router .wait_for_metrics( - &i, + i, |x| x.last_log_index == want_log, Some(timeout), &format!("n{}.last_log_index -> {}", i, want_log), @@ -143,7 +143,7 @@ async fn wait_log(router: std::sync::Arc, node_ids: &BTree .await?; router .wait_for_metrics( - &i, + i, |x| x.last_applied == want_log, Some(timeout), &format!("n{}.last_applied -> {}", i, want_log), diff --git a/async-raft/tests/concurrent_write_and_add_non_voter.rs b/async-raft/tests/concurrent_write_and_add_non_voter.rs index 130d2bc5c..def0d58d5 100644 --- a/async-raft/tests/concurrent_write_and_add_non_voter.rs +++ b/async-raft/tests/concurrent_write_and_add_non_voter.rs @@ -143,7 +143,7 @@ async fn wait_log( for i in node_ids.iter() { router .wait_for_metrics( - &i, + i, |x| x.last_log_index == want_log, Some(timeout), &format!("n{}.last_log_index -> {}", i, want_log), @@ -151,7 +151,7 @@ async fn wait_log( .await?; router .wait_for_metrics( - &i, + i, |x| x.last_applied == want_log, Some(timeout), &format!("n{}.last_applied -> {}", i, want_log), diff --git a/async-raft/tests/membership/t30_commit_joint_config.rs b/async-raft/tests/membership/t30_commit_joint_config.rs index 492373205..a7fa61920 100644 --- a/async-raft/tests/membership/t30_commit_joint_config.rs +++ b/async-raft/tests/membership/t30_commit_joint_config.rs @@ -26,15 +26,13 @@ async fn commit_joint_config_during_0_to_012() -> Result<()> { let router = Arc::new(RaftRouter::new(config.clone())); router.new_raft_node(0).await; - // Assert all nodes are in non-voter state & have no entries. - let want; - // router.assert_pristine_cluster().await; // Initialize the cluster, then assert that a stable cluster was formed & held. tracing::info!("--- initializing cluster"); router.initialize_from_single_node(0).await?; - want = 1; + // Assert all nodes are in non-voter state & have no entries. + let want = 1; router.wait_for_log(&btreeset![0], want, None, "init node 0").await?; diff --git a/async-raft/tests/membership/t40_removed_follower.rs b/async-raft/tests/membership/t40_removed_follower.rs index d75b277de..aa823be7f 100644 --- a/async-raft/tests/membership/t40_removed_follower.rs +++ b/async-raft/tests/membership/t40_removed_follower.rs @@ -50,7 +50,7 @@ async fn stop_replication_to_removed_follower() -> Result<()> { for i in &[0, 3, 4] { router - .wait(&i, timeout()) + .wait(i, timeout()) .await? .metrics(|x| x.last_applied >= n_logs, "new cluster recv new logs") .await?; @@ -59,7 +59,7 @@ async fn stop_replication_to_removed_follower() -> Result<()> { for i in &[1, 2] { router - .wait(&i, timeout()) + .wait(i, timeout()) .await? .metrics(|x| x.last_applied < n_logs, "old cluster does not recv new logs") .await?; diff --git a/memstore/src/lib.rs b/memstore/src/lib.rs index d2ac39093..42a3b99aa 100644 --- a/memstore/src/lib.rs +++ b/memstore/src/lib.rs @@ -1,6 +1,5 @@ #![doc = include_str!("../README.md")] #![feature(backtrace)] -#![feature(bound_cloned)] #[cfg(test)] mod test;