From a61f71a537e8920cf1a53e594617c3e318d1c41b Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Thu, 2 Nov 2023 20:59:56 +0000 Subject: [PATCH 1/8] clippy: eliminate a bunch of redundant `into_iter` calls --- src/descriptor/key.rs | 2 +- src/plan.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index cd4c828e8..99fcbe1f3 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -943,7 +943,7 @@ impl DescriptorXKey { Some((fingerprint, ref path)) => ( fingerprint, path.into_iter() - .chain(self.derivation_path.into_iter()) + .chain(&self.derivation_path) .collect(), ), None => ( diff --git a/src/plan.rs b/src/plan.rs index 32e9aa75d..fa70dbfd0 100644 --- a/src/plan.rs +++ b/src/plan.rs @@ -383,7 +383,7 @@ impl Plan { .entry(pk) .and_modify(|(leaf_hashes, _)| { if let Some(lh) = leaf_hash { - if leaf_hashes.iter().find(|&&i| i == lh).is_none() { + if leaf_hashes.iter().all(|&i| i != lh) { leaf_hashes.push(lh); } } @@ -661,7 +661,7 @@ pub trait IntoAssets { } impl IntoAssets for KeyMap { - fn into_assets(self) -> Assets { Assets::from_iter(self.into_iter().map(|(k, _)| k)) } + fn into_assets(self) -> Assets { Assets::from_iter(self.into_keys()) } } impl IntoAssets for DescriptorPublicKey { @@ -669,7 +669,7 @@ impl IntoAssets for DescriptorPublicKey { } impl IntoAssets for Vec { - fn into_assets(self) -> Assets { Assets::from_iter(self.into_iter()) } + fn into_assets(self) -> Assets { Assets::from_iter(self) } } impl IntoAssets for sha256::Hash { @@ -723,14 +723,14 @@ impl Assets { } fn append(&mut self, b: Self) { - self.keys.extend(b.keys.into_iter()); - self.sha256_preimages.extend(b.sha256_preimages.into_iter()); + self.keys.extend(b.keys); + self.sha256_preimages.extend(b.sha256_preimages); self.hash256_preimages - .extend(b.hash256_preimages.into_iter()); + .extend(b.hash256_preimages); self.ripemd160_preimages - .extend(b.ripemd160_preimages.into_iter()); + .extend(b.ripemd160_preimages); self.hash160_preimages - .extend(b.hash160_preimages.into_iter()); + .extend(b.hash160_preimages); self.relative_timelock = b.relative_timelock.or(self.relative_timelock); self.absolute_timelock = b.absolute_timelock.or(self.absolute_timelock); From 4f7782f9f8e14da99714b3b9c85b4820a74bd794 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Thu, 2 Nov 2023 21:15:28 +0000 Subject: [PATCH 2/8] clippy: minor things Also fixes a bunch of unused imports that are detected by the latest rustc nightly. (One is a wildcard import that actually imports nothing; the other are prelude things in a private prelude module.) --- src/descriptor/key.rs | 2 +- src/descriptor/tr.rs | 2 +- src/iter/mod.rs | 2 +- src/lib.rs | 3 ++- src/plan.rs | 21 +++++++++------------ src/psbt/finalizer.rs | 2 +- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index 99fcbe1f3..5be694a7e 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -589,7 +589,7 @@ impl DescriptorPublicKey { }; xpub.derivation_paths .paths() - .into_iter() + .iter() .map(|p| origin_path.extend(p)) .collect() } diff --git a/src/descriptor/tr.rs b/src/descriptor/tr.rs index 81cb5c65a..93455ab2b 100644 --- a/src/descriptor/tr.rs +++ b/src/descriptor/tr.rs @@ -737,7 +737,7 @@ where wit.push(Placeholder::TapScript(leaf_script.0)); wit.push(Placeholder::TapControlBlock(control_block)); - let wit_size = witness_size(&wit); + let wit_size = witness_size(wit); if min_wit_len.is_some() && Some(wit_size) > min_wit_len { continue; } else { diff --git a/src/iter/mod.rs b/src/iter/mod.rs index f8dbed939..553ae0f47 100644 --- a/src/iter/mod.rs +++ b/src/iter/mod.rs @@ -82,7 +82,7 @@ impl<'a, Pk: MiniscriptKey> TreeLike for &'a policy::Concrete { } } -impl<'a, Pk: MiniscriptKey> TreeLike for Arc> { +impl TreeLike for Arc> { fn as_node(&self) -> Tree { use policy::Concrete::*; match self.as_ref() { diff --git a/src/lib.rs b/src/lib.rs index 225d97df2..fe72ccfc1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -116,7 +116,6 @@ mod macros; mod pub_macros; use internals::hex::exts::DisplayHex; -pub use pub_macros::*; pub mod descriptor; pub mod expression; @@ -812,6 +811,8 @@ mod tests { } } + +#[allow(unused_imports)] // this is an internal prelude module; not all imports are used with every feature combination mod prelude { // Mutex implementation from LDK // https://github.com/lightningdevkit/rust-lightning/blob/9bdce47f0e0516e37c89c09f1975dfc06b5870b1/lightning-invoice/src/sync.rs diff --git a/src/plan.rs b/src/plan.rs index fa70dbfd0..2ee4b945e 100644 --- a/src/plan.rs +++ b/src/plan.rs @@ -255,13 +255,13 @@ impl Plan { // scriptSig len (1) + OP_0 (1) + OP_PUSHBYTES_32 (1) +