diff --git a/Cargo.toml b/Cargo.toml index 09533a1e8..25872b3ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -308,3 +308,4 @@ overflow-checks = true inherits = "release" debug = true strip = false + diff --git a/cli/Cargo.toml b/cli/Cargo.toml index a936016a8..5b3622d95 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -78,3 +78,6 @@ features = [ [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tokio.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/components/addressmanager/src/stores/address_store.rs b/components/addressmanager/src/stores/address_store.rs index 41b12f6cc..accfcfda4 100644 --- a/components/addressmanager/src/stores/address_store.rs +++ b/components/addressmanager/src/stores/address_store.rs @@ -26,6 +26,7 @@ pub trait AddressesStoreReader { pub trait AddressesStore: AddressesStoreReader { fn set(&mut self, key: AddressKey, entry: Entry) -> StoreResult<()>; + #[allow(dead_code)] fn set_failed_count(&mut self, key: AddressKey, connection_failed_count: u64) -> StoreResult<()>; fn remove(&mut self, key: AddressKey) -> StoreResult<()>; } diff --git a/consensus/core/Cargo.toml b/consensus/core/Cargo.toml index 29646cfe1..43669547b 100644 --- a/consensus/core/Cargo.toml +++ b/consensus/core/Cargo.toml @@ -50,3 +50,6 @@ harness = false [features] devnet-prealloc = [] + +[lints.clippy] +empty_docs = "allow" diff --git a/consensus/core/src/sign.rs b/consensus/core/src/sign.rs index adf4aa731..e9171afe6 100644 --- a/consensus/core/src/sign.rs +++ b/consensus/core/src/sign.rs @@ -136,7 +136,7 @@ pub fn sign_with_multiple_v2(mut mutable_tx: SignableTransaction, privkeys: Vec< let mut additional_signatures_required = false; for i in 0..mutable_tx.tx.inputs.len() { let script = mutable_tx.entries[i].as_ref().unwrap().script_public_key.script(); - if let Some(schnorr_key) = map.get(&script.to_vec()) { + if let Some(schnorr_key) = map.get(script) { let sig_hash = calc_schnorr_signature_hash(&mutable_tx.as_verifiable(), i, SIG_HASH_ALL, &mut reused_values); let msg = secp256k1::Message::from_slice(sig_hash.as_bytes().as_slice()).unwrap(); let sig: [u8; 64] = *schnorr_key.sign_schnorr(msg).as_ref(); diff --git a/consensus/wasm/Cargo.toml b/consensus/wasm/Cargo.toml index a44169cf7..1da0b26a8 100644 --- a/consensus/wasm/Cargo.toml +++ b/consensus/wasm/Cargo.toml @@ -28,3 +28,6 @@ rand.workspace = true workflow-wasm.workspace = true workflow-log.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/crypto/txscript/src/data_stack.rs b/crypto/txscript/src/data_stack.rs index 0eafb8d14..74988042a 100644 --- a/crypto/txscript/src/data_stack.rs +++ b/crypto/txscript/src/data_stack.rs @@ -14,6 +14,7 @@ pub(crate) trait DataStack { fn pop_items(&mut self) -> Result<[T; SIZE], TxScriptError> where Vec: OpcodeData; + #[allow(dead_code)] fn peek_items(&self) -> Result<[T; SIZE], TxScriptError> where Vec: OpcodeData; diff --git a/crypto/txscript/src/opcodes/mod.rs b/crypto/txscript/src/opcodes/mod.rs index 9727e2e87..5d6096b7a 100644 --- a/crypto/txscript/src/opcodes/mod.rs +++ b/crypto/txscript/src/opcodes/mod.rs @@ -1013,7 +1013,7 @@ mod test { let mut reused_values = SigHashReusedValues::new(); for ErrorTestCase { init, code, error } in tests { let mut vm = TxScriptEngine::new(&mut reused_values, &cache); - vm.dstack = init.clone(); + vm.dstack.clone_from(&init); assert_eq!( code.execute(&mut vm) .expect_err(format!("Opcode {} should have errored (init: {:?})", code.value(), init.clone()).as_str()), diff --git a/kaspad/src/args.rs b/kaspad/src/args.rs index 7483d9091..e11672915 100644 --- a/kaspad/src/args.rs +++ b/kaspad/src/args.rs @@ -154,7 +154,7 @@ impl Args { config.is_archival = self.archival; // TODO: change to `config.enable_sanity_checks = self.sanity` when we reach stable versions config.enable_sanity_checks = true; - config.user_agent_comments = self.user_agent_comments.clone(); + config.user_agent_comments.clone_from(&self.user_agent_comments); config.block_template_cache_lifetime = self.block_template_cache_lifetime; config.p2p_listen_address = self.listen.unwrap_or(ContextualNetAddress::unspecified()); config.externalip = self.externalip.map(|v| v.normalize(config.default_p2p_port())); diff --git a/kos/src/metrics/ipc.rs b/kos/src/metrics/ipc.rs index 34e32dc20..3ca02be6c 100644 --- a/kos/src/metrics/ipc.rs +++ b/kos/src/metrics/ipc.rs @@ -18,6 +18,7 @@ impl MetricsIpc { } } +#[allow(dead_code)] #[async_trait] pub trait MetricsCtl: Send + Sync + 'static { async fn post_data(&self, data: MetricsSnapshot) -> Result<()>; diff --git a/mining/src/mempool/model/pool.rs b/mining/src/mempool/model/pool.rs index 1f9ff1552..5ad6970eb 100644 --- a/mining/src/mempool/model/pool.rs +++ b/mining/src/mempool/model/pool.rs @@ -36,6 +36,7 @@ pub(crate) trait Pool { /// Returns an index over either high or low priority transaction ids which can /// in turn be topologically ordered. + #[allow(dead_code)] fn index(&self, priority: Priority) -> PoolIndex { let transactions: TransactionIdSet = self.all().iter().filter_map(|(id, tx)| if tx.priority == priority { Some(*id) } else { None }).collect(); diff --git a/rpc/core/Cargo.toml b/rpc/core/Cargo.toml index 26783d50e..76fb13a73 100644 --- a/rpc/core/Cargo.toml +++ b/rpc/core/Cargo.toml @@ -42,3 +42,6 @@ workflow-wasm.workspace = true [dev-dependencies] serde_json.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/rpc/core/src/model/address.rs b/rpc/core/src/model/address.rs index 7ea382705..720cb4f86 100644 --- a/rpc/core/src/model/address.rs +++ b/rpc/core/src/model/address.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; pub type RpcAddress = kaspa_addresses::Address; -/// +/// Represents a UTXO entry of an address returned by the `GetUtxosByAddresses` RPC. #[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] #[serde(rename_all = "camelCase")] pub struct RpcUtxosByAddressesEntry { @@ -13,7 +13,7 @@ pub struct RpcUtxosByAddressesEntry { pub utxo_entry: RpcUtxoEntry, } -/// +/// Represents a balance of an address returned by the `GetBalancesByAddresses` RPC. #[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] #[serde(rename_all = "camelCase")] pub struct RpcBalancesByAddressesEntry { diff --git a/rpc/wrpc/client/src/client.rs b/rpc/wrpc/client/src/client.rs index 2b6d85646..573d2a500 100644 --- a/rpc/wrpc/client/src/client.rs +++ b/rpc/wrpc/client/src/client.rs @@ -363,9 +363,9 @@ impl KaspaRpcClient { // or 1.2.3.4:port where port is based on the network type. // if (parse_output.scheme.is_some() || !path_str.is_empty()) && parse_output.port.is_none() { - Ok(format!("{}://{}{}", scheme, parse_output.host.to_string(), path_str)) + Ok(format!("{}://{}{}", scheme, parse_output.host, path_str)) } else { - Ok(format!("{}://{}:{}{}", scheme, parse_output.host.to_string(), port, path_str)) + Ok(format!("{}://{}:{}{}", scheme, parse_output.host, port, path_str)) } } diff --git a/rpc/wrpc/client/src/parse.rs b/rpc/wrpc/client/src/parse.rs index 6928ad650..35db2c768 100644 --- a/rpc/wrpc/client/src/parse.rs +++ b/rpc/wrpc/client/src/parse.rs @@ -15,7 +15,7 @@ impl Display for ParseHostOutput<'_> { if let Some(scheme) = self.scheme { write!(f, "{}://", scheme)?; } - write!(f, "{}", self.host.to_string())?; + write!(f, "{}", self.host)?; if let Some(port) = self.port { write!(f, ":{}", port)?; } @@ -31,13 +31,13 @@ pub enum Host<'a> { Ipv6(Ipv6Addr), } -impl ToString for Host<'_> { - fn to_string(&self) -> String { +impl Display for Host<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Host::Domain(domain) => domain.to_string(), - Host::Hostname(hostname) => hostname.to_string(), - Host::Ipv4(ipv4) => ipv4.to_string(), - Host::Ipv6(ipv6) => format!("[{}]", ipv6), + Host::Domain(domain) => write!(f, "{}", domain), + Host::Hostname(hostname) => write!(f, "{}", hostname), + Host::Ipv4(ipv4) => write!(f, "{}", ipv4), + Host::Ipv6(ipv6) => write!(f, "[{}]", ipv6), } } } diff --git a/utils/benches/bench.rs b/utils/benches/bench.rs index d726fa257..15617134d 100644 --- a/utils/benches/bench.rs +++ b/utils/benches/bench.rs @@ -45,6 +45,7 @@ trait RwLockTrait { type WriteGuard; fn new(value: T) -> Self; async fn read_(&self) -> Self::ReadGuard; + #[allow(dead_code)] async fn write_(&self) -> Self::WriteGuard; } diff --git a/wallet/core/Cargo.toml b/wallet/core/Cargo.toml index 9c93fd031..c882ceedc 100644 --- a/wallet/core/Cargo.toml +++ b/wallet/core/Cargo.toml @@ -104,3 +104,6 @@ serde_repr.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] tokio.workspace = true + +[lints.clippy] +empty_docs = "allow" diff --git a/wallet/core/src/storage/local/collection.rs b/wallet/core/src/storage/local/collection.rs index 85cfb6aec..53c740710 100644 --- a/wallet/core/src/storage/local/collection.rs +++ b/wallet/core/src/storage/local/collection.rs @@ -44,7 +44,7 @@ where } pub fn insert(&mut self, id: Id, data: Arc) -> Result<()> { - if self.map.get(&id).is_some() { + if self.map.contains_key(&id) { self.map.remove(&id); self.vec.retain(|d| d.id() != &id); } @@ -84,7 +84,7 @@ where pub fn store_multiple(&mut self, data: Vec) -> Result<()> { for data in data.into_iter() { let id = data.id().clone(); - if self.map.get(&id).is_some() { + if self.map.contains_key(&id) { self.map.remove(&id); self.vec.retain(|d| d.id() != &id); } @@ -98,7 +98,7 @@ where pub fn store_single(&mut self, data: &Data) -> Result<()> { let id = data.id(); - if self.map.get(id).is_some() { + if self.map.contains_key(id) { self.map.remove(id); self.vec.retain(|d| d.id() != id); } diff --git a/wallet/core/src/tx/generator/test.rs b/wallet/core/src/tx/generator/test.rs index be7129f59..c26c38364 100644 --- a/wallet/core/src/tx/generator/test.rs +++ b/wallet/core/src/tx/generator/test.rs @@ -63,6 +63,7 @@ impl FeesExpected { } trait PendingTransactionExtension { + #[allow(dead_code)] fn tuple(self) -> (PendingTransaction, Transaction); fn expect(self, expected: &Expected) -> Self where @@ -297,7 +298,7 @@ impl Harness { Rc::new(Harness { generator, accumulator: RefCell::new(Accumulator::default()) }) } - pub fn fetch>(self: &Rc, expected: &Expected) -> Rc + pub fn fetch(self: &Rc, expected: &Expected) -> Rc where SOMPI: Into + Debug + Copy, { diff --git a/wallet/core/src/utxo/processor.rs b/wallet/core/src/utxo/processor.rs index 1f38d0a41..9d2ca9ce7 100644 --- a/wallet/core/src/utxo/processor.rs +++ b/wallet/core/src/utxo/processor.rs @@ -120,7 +120,7 @@ impl UtxoProcessor { } pub async fn bind_rpc(&self, rpc: Option) -> Result<()> { - *self.inner.rpc.lock().unwrap() = rpc.clone(); + self.inner.rpc.lock().unwrap().clone_from(&rpc); self.sync_proc().bind_rpc(rpc).await?; Ok(()) }