diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index 34d93833a..e65195b08 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -605,8 +605,8 @@ impl Xpriv { } /// Constructs a new extended public key from this extended private key. - pub fn to_xpub(&self, secp: &Secp256k1) -> Xpub { - Xpub::from_xpriv(secp, self) + pub fn to_xpub(self, secp: &Secp256k1) -> Xpub { + Xpub::from_xpriv(secp, &self) } /// Constructs a new BIP340 keypair for Schnorr signatures and Taproot use matching the internal diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index 9772f39d4..7d0e3a95c 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -327,7 +327,7 @@ impl CompressedPublicKey { /// /// Note that this can be used as a sort key to get BIP67-compliant sorting. /// That's why this type doesn't have the `to_sort_key` method - it would duplicate this one. - pub fn to_bytes(&self) -> [u8; 33] { self.0.serialize() } + pub fn to_bytes(self) -> [u8; 33] { self.0.serialize() } /// Deserializes a public key from a slice. pub fn from_slice(data: &[u8]) -> Result { diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs index ccbac973e..5934e2934 100644 --- a/bitcoin/src/crypto/sighash.rs +++ b/bitcoin/src/crypto/sighash.rs @@ -1401,6 +1401,7 @@ impl EncodeSigningDataResult { /// // use the hash from `writer` /// } /// ``` + #[allow(clippy::wrong_self_convention)] // Consume self so we can take the error. pub fn is_sighash_single_bug(self) -> Result { match self { EncodeSigningDataResult::SighashSingleBug => Ok(true), diff --git a/bitcoin/src/internal_macros.rs b/bitcoin/src/internal_macros.rs index dfecac978..9b97bb9bb 100644 --- a/bitcoin/src/internal_macros.rs +++ b/bitcoin/src/internal_macros.rs @@ -303,7 +303,7 @@ macro_rules! impl_array_newtype { /// Copies the underlying bytes into a new `Vec`. #[inline] - pub fn to_vec(&self) -> alloc::vec::Vec { self.0.to_vec() } + pub fn to_vec(self) -> alloc::vec::Vec { self.0.to_vec() } /// Returns a slice of the underlying bytes. #[inline] @@ -312,7 +312,7 @@ macro_rules! impl_array_newtype { /// Copies the underlying bytes into a new `Vec`. #[inline] #[deprecated(since = "TBD", note = "use to_vec instead")] - pub fn to_bytes(&self) -> alloc::vec::Vec { self.to_vec() } + pub fn to_bytes(self) -> alloc::vec::Vec { self.to_vec() } /// Converts the object to a raw pointer. #[inline] diff --git a/bitcoin/src/taproot/serialized_signature.rs b/bitcoin/src/taproot/serialized_signature.rs index 14cfa22be..d00730601 100644 --- a/bitcoin/src/taproot/serialized_signature.rs +++ b/bitcoin/src/taproot/serialized_signature.rs @@ -155,8 +155,8 @@ impl SerializedSignature { /// Convert the serialized signature into the Signature struct. /// (This deserializes it) #[inline] - pub fn to_signature(&self) -> Result { - Signature::from_slice(self) + pub fn to_signature(self) -> Result { + Signature::from_slice(&self) } /// Constructs a new SerializedSignature from a Signature. diff --git a/clippy.toml b/clippy.toml index ddca6b4cb..0d5416666 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1,3 @@ msrv = "1.63.0" too-many-arguments-threshold = 13 +avoid-breaking-exported-api = false diff --git a/primitives/src/locktime/relative.rs b/primitives/src/locktime/relative.rs index aa5d61118..98b4efe1c 100644 --- a/primitives/src/locktime/relative.rs +++ b/primitives/src/locktime/relative.rs @@ -81,7 +81,7 @@ impl LockTime { /// Locktimes are not ordered by the natural ordering on `u32`. If you want to /// compare locktimes, use [`Self::is_implied_by`] or similar methods. #[inline] - pub fn to_consensus_u32(&self) -> u32 { + pub fn to_consensus_u32(self) -> u32 { match self { LockTime::Blocks(ref h) => h.to_consensus_u32(), LockTime::Time(ref t) => t.to_consensus_u32(), @@ -99,7 +99,7 @@ impl LockTime { /// Encodes the locktime as a sequence number. #[inline] - pub fn to_sequence(&self) -> Sequence { Sequence::from_consensus(self.to_consensus_u32()) } + pub fn to_sequence(self) -> Sequence { Sequence::from_consensus(self.to_consensus_u32()) } /// Constructs a new `LockTime` from `n`, expecting `n` to be a 16-bit count of blocks. #[inline] diff --git a/primitives/src/sequence.rs b/primitives/src/sequence.rs index a0adab268..163f70a05 100644 --- a/primitives/src/sequence.rs +++ b/primitives/src/sequence.rs @@ -184,7 +184,7 @@ impl Sequence { /// Constructs a new [`relative::LockTime`] from this [`Sequence`] number. #[inline] - pub fn to_relative_lock_time(&self) -> Option { + pub fn to_relative_lock_time(self) -> Option { use crate::locktime::relative::{Height, LockTime, Time}; if !self.is_relative_lock_time() { diff --git a/units/src/block.rs b/units/src/block.rs index aabb4c2cc..6afa29453 100644 --- a/units/src/block.rs +++ b/units/src/block.rs @@ -47,7 +47,7 @@ impl BlockHeight { /// Returns block height as a `u32`. // Because type inference doesn't always work using `Into`. - pub const fn to_u32(&self) -> u32 { self.0 } + pub const fn to_u32(self) -> u32 { self.0 } } impl fmt::Display for BlockHeight { @@ -114,7 +114,7 @@ impl BlockInterval { /// Returns block interval as a `u32`. // Because type inference doesn't always work using `Into`. - pub const fn to_u32(&self) -> u32 { self.0 } + pub const fn to_u32(self) -> u32 { self.0 } } impl fmt::Display for BlockInterval { diff --git a/units/src/locktime/relative.rs b/units/src/locktime/relative.rs index 9b98e38c4..5b54d9a6d 100644 --- a/units/src/locktime/relative.rs +++ b/units/src/locktime/relative.rs @@ -33,7 +33,7 @@ impl Height { /// Returns the `u32` value used to encode this locktime in an nSequence field or /// argument to `OP_CHECKSEQUENCEVERIFY`. #[inline] - pub const fn to_consensus_u32(&self) -> u32 { + pub const fn to_consensus_u32(self) -> u32 { self.0 as u32 // cast safety: u32 is wider than u16 on all architectures } } @@ -113,7 +113,7 @@ impl Time { /// Returns the `u32` value used to encode this locktime in an nSequence field or /// argument to `OP_CHECKSEQUENCEVERIFY`. #[inline] - pub const fn to_consensus_u32(&self) -> u32 { + pub const fn to_consensus_u32(self) -> u32 { (1u32 << 22) | self.0 as u32 // cast safety: u32 is wider than u16 on all architectures } }