Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fixes for rust stable clippy, and rust 1.56.1 compilation #221

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contrib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if cargo --version | grep "1\.56"; then
cargo update -p which --precise 4.4.0
cargo update -p byteorder --precise 1.4.3
cargo update -p cc --precise 1.0.94
cargo update -p libc --precise 0.2.163
cargo update -p serde_json --precise 1.0.98
cargo update -p serde --precise 1.0.156
cargo update -p ppv-lite86 --precise 0.2.8
Expand Down
4 changes: 2 additions & 2 deletions src/blech32/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,15 @@ pub struct ByteIter<'s> {
iter: FesToBytes<AsciiToFe32Iter<iter::Copied<slice::Iter<'s, u8>>>>,
}

impl<'s> Iterator for ByteIter<'s> {
impl Iterator for ByteIter<'_> {
type Item = u8;
#[inline]
fn next(&mut self) -> Option<u8> { self.iter.next() }
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
}

impl<'s> ExactSizeIterator for ByteIter<'s> {
impl ExactSizeIterator for ByteIter<'_> {
#[inline]
fn len(&self) -> usize { self.iter.len() }
}
Expand Down
2 changes: 1 addition & 1 deletion src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<'de> Deserialize<'de> for ExtData {
enum Enum { Unknown, Challenge, Solution, Current, Proposed, Witness }
struct EnumVisitor;

impl<'de> de::Visitor<'de> for EnumVisitor {
impl de::Visitor<'_> for EnumVisitor {
type Value = Enum;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
12 changes: 6 additions & 6 deletions src/confidential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ impl<'de> Deserialize<'de> for AssetBlindingFactor {
if d.is_human_readable() {
struct HexVisitor;

impl<'de> ::serde::de::Visitor<'de> for HexVisitor {
impl ::serde::de::Visitor<'_> for HexVisitor {
type Value = AssetBlindingFactor;

fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
Expand All @@ -830,7 +830,7 @@ impl<'de> Deserialize<'de> for AssetBlindingFactor {
if let Ok(hex) = ::std::str::from_utf8(v) {
AssetBlindingFactor::from_hex(hex).map_err(E::custom)
} else {
return Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self));
Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
}
}

Expand All @@ -846,7 +846,7 @@ impl<'de> Deserialize<'de> for AssetBlindingFactor {
} else {
struct BytesVisitor;

impl<'de> ::serde::de::Visitor<'de> for BytesVisitor {
impl ::serde::de::Visitor<'_> for BytesVisitor {
type Value = AssetBlindingFactor;

fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
Expand Down Expand Up @@ -1019,7 +1019,7 @@ impl<'de> Deserialize<'de> for ValueBlindingFactor {
if d.is_human_readable() {
struct HexVisitor;

impl<'de> ::serde::de::Visitor<'de> for HexVisitor {
impl ::serde::de::Visitor<'_> for HexVisitor {
type Value = ValueBlindingFactor;

fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
Expand All @@ -1033,7 +1033,7 @@ impl<'de> Deserialize<'de> for ValueBlindingFactor {
if let Ok(hex) = ::std::str::from_utf8(v) {
ValueBlindingFactor::from_hex(hex).map_err(E::custom)
} else {
return Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self));
Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
}
}

Expand All @@ -1049,7 +1049,7 @@ impl<'de> Deserialize<'de> for ValueBlindingFactor {
} else {
struct BytesVisitor;

impl<'de> ::serde::de::Visitor<'de> for BytesVisitor {
impl ::serde::de::Visitor<'_> for BytesVisitor {
type Value = ValueBlindingFactor;

fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
Expand Down
14 changes: 7 additions & 7 deletions src/dynafed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ use crate::Script;

/// ad-hoc struct to fmt in hex
struct HexBytes<'a>(&'a [u8]);
impl<'a> fmt::Display for HexBytes<'a> {
impl fmt::Display for HexBytes<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
crate::hex::format_hex(self.0, f)
}
}
impl<'a> fmt::Debug for HexBytes<'a> {
impl fmt::Debug for HexBytes<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self, f)
}
}
#[cfg(feature = "serde")]
impl<'a> Serialize for HexBytes<'a> {
impl Serialize for HexBytes<'_> {
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
if s.is_human_readable() {
s.collect_str(self)
Expand All @@ -50,7 +50,7 @@ impl<'a> Serialize for HexBytes<'a> {

/// ad-hoc struct to fmt in hex
struct HexBytesArray<'a>(&'a [Vec<u8>]);
impl<'a> fmt::Display for HexBytesArray<'a> {
impl fmt::Display for HexBytesArray<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[")?;
for (i, e) in self.0.iter().enumerate() {
Expand All @@ -62,13 +62,13 @@ impl<'a> fmt::Display for HexBytesArray<'a> {
write!(f, "]")
}
}
impl<'a> fmt::Debug for HexBytesArray<'a> {
impl fmt::Debug for HexBytesArray<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self, f)
}
}
#[cfg(feature = "serde")]
impl<'a> Serialize for HexBytesArray<'a> {
impl Serialize for HexBytesArray<'_> {
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
let mut seq = s.serialize_seq(Some(self.0.len()))?;
for b in self.0 {
Expand Down Expand Up @@ -420,7 +420,7 @@ impl<'de> Deserialize<'de> for Params {
}
struct EnumVisitor;

impl<'de> de::Visitor<'de> for EnumVisitor {
impl de::Visitor<'_> for EnumVisitor {
type Value = Enum;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
8 changes: 4 additions & 4 deletions src/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn chars_to_hex(hi: u8, lo: u8) -> Result<u8, Error> {
Ok(ret as u8)
}

impl<'a> Iterator for HexIterator<'a> {
impl Iterator for HexIterator<'_> {
type Item = Result<u8, Error>;

fn next(&mut self) -> Option<Result<u8, Error>> {
Expand All @@ -119,7 +119,7 @@ impl<'a> Iterator for HexIterator<'a> {
}
}

impl<'a> io::Read for HexIterator<'a> {
impl io::Read for HexIterator<'_> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let mut bytes_read = 0usize;
for dst in buf {
Expand All @@ -135,15 +135,15 @@ impl<'a> io::Read for HexIterator<'a> {
}
}

impl<'a> DoubleEndedIterator for HexIterator<'a> {
impl DoubleEndedIterator for HexIterator<'_> {
fn next_back(&mut self) -> Option<Result<u8, Error>> {
let lo = self.iter.next_back()?;
let hi = self.iter.next_back().unwrap();
Some(chars_to_hex(hi, lo))
}
}

impl<'a> ExactSizeIterator for HexIterator<'a> {}
impl ExactSizeIterator for HexIterator<'_> {}

/// Outputs hex into an object implementing `fmt::Write`.
///
Expand Down
6 changes: 3 additions & 3 deletions src/issuance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<'de> ::serde::Deserialize<'de> for AssetId {
if d.is_human_readable() {
struct HexVisitor;

impl<'de> ::serde::de::Visitor<'de> for HexVisitor {
impl ::serde::de::Visitor<'_> for HexVisitor {
type Value = AssetId;

fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
Expand All @@ -217,7 +217,7 @@ impl<'de> ::serde::Deserialize<'de> for AssetId {
if let Ok(hex) = ::std::str::from_utf8(v) {
AssetId::from_str(hex).map_err(E::custom)
} else {
return Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self));
Err(E::invalid_value(::serde::de::Unexpected::Bytes(v), &self))
}
}

Expand All @@ -233,7 +233,7 @@ impl<'de> ::serde::Deserialize<'de> for AssetId {
} else {
struct BytesVisitor;

impl<'de> ::serde::de::Visitor<'de> for BytesVisitor {
impl ::serde::de::Visitor<'_> for BytesVisitor {
type Value = AssetId;

fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions src/serde_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ pub mod hex_bytes {
{
struct Visitor<B>(::std::marker::PhantomData<B>);

impl<'de, B: FromHex> serde::de::Visitor<'de> for Visitor<B> {
impl<B: FromHex> serde::de::Visitor<'_> for Visitor<B> {
type Value = B;

fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
Expand All @@ -255,7 +255,7 @@ pub mod hex_bytes {
if let Ok(hex) = ::std::str::from_utf8(v) {
FromHex::from_hex(hex).map_err(E::custom)
} else {
return Err(E::invalid_value(serde::de::Unexpected::Bytes(v), &self));
Err(E::invalid_value(serde::de::Unexpected::Bytes(v), &self))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl fmt::Display for Error {

impl ::std::error::Error for Error {}

impl<'u, T> Prevouts<'u, T> where T: Borrow<TxOut> {
impl<T> Prevouts<'_, T> where T: Borrow<TxOut> {
fn check_all(&self, tx: &Transaction) -> Result<(), Error> {
if let Prevouts::All(prevouts) = self {
if prevouts.len() != tx.input.len() {
Expand Down Expand Up @@ -866,7 +866,7 @@ impl<'a> Annex<'a> {
}
}

impl<'a> Encodable for Annex<'a> {
impl Encodable for Annex<'_> {
fn consensus_encode<W: io::Write>(&self, writer: W) -> Result<usize, encode::Error> {
encode::consensus_encode_with_size(self.0, writer)
}
Expand Down