From 70fe64e57551d9025da2a6adfff5276daed0ff25 Mon Sep 17 00:00:00 2001 From: Ping Yu Date: Sat, 1 Jun 2024 19:32:00 +0800 Subject: [PATCH] fix clippy error for rust 1.78 Signed-off-by: Ping Yu --- Makefile | 3 +++ src/pd/cluster.rs | 4 ++-- src/raw/requests.rs | 2 +- src/region_cache.rs | 4 ++-- src/store/mod.rs | 16 ---------------- src/transaction/buffer.rs | 4 ++-- 6 files changed, 10 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index aef0ad45..e616b32e 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,9 @@ check: generate cargo fmt -- --check cargo clippy --all-targets --features "${ALL_FEATURES}" -- -D clippy::all +clippy: + cargo clippy --all-targets --features "${ALL_FEATURES}" -- -D clippy::all + unit-test: generate cargo nextest run --all --no-default-features diff --git a/src/pd/cluster.rs b/src/pd/cluster.rs index e74a78fb..f723f8f7 100644 --- a/src/pd/cluster.rs +++ b/src/pd/cluster.rs @@ -49,7 +49,7 @@ impl Cluster { timeout: Duration, ) -> Result { let mut req = pd_request!(self.id, pdpb::GetRegionRequest); - req.region_key = key.clone(); + req.region_key = key; req.send(&mut self.client, timeout).await } @@ -101,7 +101,7 @@ impl Cluster { timeout: Duration, ) -> Result { let mut req = pd_request!(self.id, keyspacepb::LoadKeyspaceRequest); - req.name = keyspace.to_owned(); + req.name = keyspace.to_string(); let resp = req.send(&mut self.keyspace_client, timeout).await?; let keyspace = resp .keyspace diff --git a/src/raw/requests.rs b/src/raw/requests.rs index 8c49da9e..201ac657 100644 --- a/src/raw/requests.rs +++ b/src/raw/requests.rs @@ -472,7 +472,7 @@ impl Shardable for RawCoprocessorRequest { fn apply_shard(&mut self, shard: Self::Shard, store: &RegionStore) -> Result<()> { self.set_leader(&store.region_with_leader)?; - self.inner.ranges = shard.clone(); + self.inner.ranges.clone_from(&shard); self.inner.data = (self.data_builder)(store.region_with_leader.region.clone(), shard); Ok(()) } diff --git a/src/region_cache.rs b/src/region_cache.rs index 3a5c0a25..e56068c0 100644 --- a/src/region_cache.rs +++ b/src/region_cache.rs @@ -575,10 +575,10 @@ mod test { }); assert!(!is_valid_tikv_store(&store)); - store.labels[1].value = "tiflash_compute".to_owned(); + store.labels[1].value = "tiflash_compute".to_string(); assert!(!is_valid_tikv_store(&store)); - store.labels[1].value = "other".to_owned(); + store.labels[1].value = "other".to_string(); assert!(is_valid_tikv_store(&store)); } } diff --git a/src/store/mod.rs b/src/store/mod.rs index a244a1bc..f21373b4 100644 --- a/src/store/mod.rs +++ b/src/store/mod.rs @@ -8,7 +8,6 @@ use std::cmp::max; use std::cmp::min; use std::sync::Arc; -use async_trait::async_trait; use derive_new::new; use futures::prelude::*; use futures::stream::BoxStream; @@ -38,21 +37,6 @@ pub struct Store { pub client: Arc, } -#[async_trait] -pub trait KvConnectStore: KvConnect { - async fn connect_to_store( - &self, - region: RegionWithLeader, - address: String, - ) -> Result { - log::info!("connect to tikv endpoint: {:?}", &address); - let client = self.connect(address.as_str()).await?; - Ok(RegionStore::new(region, Arc::new(client))) - } -} - -impl KvConnectStore for TikvConnect {} - /// Maps keys to a stream of stores. `key_data` must be sorted in increasing order pub fn store_stream_for_keys( key_data: impl Iterator + Send + Sync + 'static, diff --git a/src/transaction/buffer.rs b/src/transaction/buffer.rs index 7090ebd4..be88ce85 100644 --- a/src/transaction/buffer.rs +++ b/src/transaction/buffer.rs @@ -358,13 +358,13 @@ impl BufferEntry { BufferEntry::Cached(_) => return None, BufferEntry::Put(v) => { pb.op = kvrpcpb::Op::Put.into(); - pb.value = v.clone(); + pb.value.clone_from(v); } BufferEntry::Del => pb.op = kvrpcpb::Op::Del.into(), BufferEntry::Locked(_) => pb.op = kvrpcpb::Op::Lock.into(), BufferEntry::Insert(v) => { pb.op = kvrpcpb::Op::Insert.into(); - pb.value = v.clone(); + pb.value.clone_from(v); } BufferEntry::CheckNotExist => pb.op = kvrpcpb::Op::CheckNotExists.into(), };