From 3da6ebcbd8afa01d5c94dbc7f0475f4c00089420 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 27 Feb 2024 23:43:52 -0800 Subject: [PATCH] Fix clippy warnings on Rust 1.75 (#344) --- src/curr/mod.rs | 2 -- src/curr/scval_conversions.rs | 18 +++++++++--------- src/next/mod.rs | 2 -- src/next/scval_conversions.rs | 26 +++++++++++++------------- tests/serde.rs | 6 +++--- tests/tx_debug_display.rs | 4 ++-- 6 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/curr/mod.rs b/src/curr/mod.rs index 8ab0180c..288c1e2e 100644 --- a/src/curr/mod.rs +++ b/src/curr/mod.rs @@ -11,5 +11,3 @@ pub use scval_validations::*; #[cfg(feature = "alloc")] mod scmap; -#[cfg(feature = "alloc")] -pub use scmap::*; diff --git a/src/curr/scval_conversions.rs b/src/curr/scval_conversions.rs index 4f84f5ed..8c42eef6 100644 --- a/src/curr/scval_conversions.rs +++ b/src/curr/scval_conversions.rs @@ -102,7 +102,7 @@ impl From<()> for ScVal { } impl From<&()> for ScVal { - fn from(_: &()) -> Self { + fn from((): &()) -> Self { ScVal::Void } } @@ -636,7 +636,7 @@ mod test { #[test] fn i32_pos() { let v = 5; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::I32(5)); let roundtrip: i32 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -645,7 +645,7 @@ mod test { #[test] fn i32_neg() { let v = -5; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::I32(-5)); let roundtrip: i32 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -656,7 +656,7 @@ mod test { use super::ScVal; let v = 5u32; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::U32(5)); let roundtrip: u32 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -665,7 +665,7 @@ mod test { #[test] fn i64_pos() { let v = 5i64; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::I64(5)); let roundtrip: i64 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -674,7 +674,7 @@ mod test { #[test] fn i64_neg() { let v = -5i64; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::I64(-5)); let roundtrip: i64 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -683,7 +683,7 @@ mod test { #[test] fn u64() { let v = 5u64; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::U64(5)); let roundtrip: u64 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -698,7 +698,7 @@ mod test { assert_eq!(int128_helpers::u128_hi(u), hi); assert_eq!(int128_helpers::u128_lo(u), lo); - let val: ScVal = u.try_into().unwrap(); + let val: ScVal = u.into(); assert_eq!(val, ScVal::U128(UInt128Parts { hi, lo })); let roundtrip: u128 = val.try_into().unwrap(); assert_eq!(u, roundtrip); @@ -715,7 +715,7 @@ mod test { assert_eq!(int128_helpers::i128_hi(i), hi); assert_eq!(int128_helpers::i128_lo(i), lo); - let val: ScVal = i.try_into().unwrap(); + let val: ScVal = i.into(); assert_eq!(val, ScVal::I128(Int128Parts { hi, lo })); let roundtrip: i128 = val.try_into().unwrap(); assert_eq!(i, roundtrip); diff --git a/src/next/mod.rs b/src/next/mod.rs index 8ab0180c..288c1e2e 100644 --- a/src/next/mod.rs +++ b/src/next/mod.rs @@ -11,5 +11,3 @@ pub use scval_validations::*; #[cfg(feature = "alloc")] mod scmap; -#[cfg(feature = "alloc")] -pub use scmap::*; diff --git a/src/next/scval_conversions.rs b/src/next/scval_conversions.rs index 01267cb1..dd64b316 100644 --- a/src/next/scval_conversions.rs +++ b/src/next/scval_conversions.rs @@ -102,7 +102,7 @@ impl From<()> for ScVal { } impl From<&()> for ScVal { - fn from(_: &()) -> Self { + fn from((): &()) -> Self { ScVal::Void } } @@ -304,7 +304,7 @@ impl TryFrom for ScSymbol { impl TryFrom for ScVal { type Error = (); fn try_from(v: String) -> Result { - Ok(ScVal::Symbol(v.try_into().map_err(|()| ())?)) + Ok(ScVal::Symbol(v.try_into()?)) } } @@ -312,7 +312,7 @@ impl TryFrom for ScVal { impl TryFrom<&String> for ScVal { type Error = (); fn try_from(v: &String) -> Result { - Ok(ScVal::Symbol(v.try_into().map_err(|()| ())?)) + Ok(ScVal::Symbol(v.try_into()?)) } } @@ -336,7 +336,7 @@ impl TryFrom<&String> for ScSymbol { impl TryFrom<&str> for ScVal { type Error = (); fn try_from(v: &str) -> Result { - Ok(ScVal::Symbol(v.try_into().map_err(|()| ())?)) + Ok(ScVal::Symbol(v.try_into()?)) } } @@ -344,7 +344,7 @@ impl TryFrom<&str> for ScVal { impl TryFrom<&'static str> for ScVal { type Error = (); fn try_from(v: &'static str) -> Result { - Ok(ScVal::Symbol(v.try_into().map_err(|()| ())?)) + Ok(ScVal::Symbol(v.try_into()?)) } } @@ -679,7 +679,7 @@ mod test { #[test] fn i32_pos() { let v = 5; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::I32(5)); let roundtrip: i32 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -688,7 +688,7 @@ mod test { #[test] fn i32_neg() { let v = -5; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::I32(-5)); let roundtrip: i32 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -699,7 +699,7 @@ mod test { use super::ScVal; let v = 5u32; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::U32(5)); let roundtrip: u32 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -708,7 +708,7 @@ mod test { #[test] fn i64_pos() { let v = 5i64; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::I64(5)); let roundtrip: i64 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -717,7 +717,7 @@ mod test { #[test] fn i64_neg() { let v = -5i64; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::I64(-5)); let roundtrip: i64 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -726,7 +726,7 @@ mod test { #[test] fn u64() { let v = 5u64; - let val: ScVal = v.try_into().unwrap(); + let val: ScVal = v.into(); assert_eq!(val, ScVal::U64(5)); let roundtrip: u64 = val.try_into().unwrap(); assert_eq!(v, roundtrip); @@ -741,7 +741,7 @@ mod test { assert_eq!(int128_helpers::u128_hi(u), hi); assert_eq!(int128_helpers::u128_lo(u), lo); - let val: ScVal = u.try_into().unwrap(); + let val: ScVal = u.into(); assert_eq!(val, ScVal::U128(UInt128Parts { hi, lo })); let roundtrip: u128 = val.try_into().unwrap(); assert_eq!(u, roundtrip); @@ -758,7 +758,7 @@ mod test { assert_eq!(int128_helpers::i128_hi(i), hi); assert_eq!(int128_helpers::i128_lo(i), lo); - let val: ScVal = i.try_into().unwrap(); + let val: ScVal = i.into(); assert_eq!(val, ScVal::I128(Int128Parts { hi, lo })); let roundtrip: i128 = val.try_into().unwrap(); assert_eq!(i, roundtrip); diff --git a/tests/serde.rs b/tests/serde.rs index 55d7cb03..ba58a493 100644 --- a/tests/serde.rs +++ b/tests/serde.rs @@ -32,9 +32,9 @@ fn test_serde_ser() -> Result<(), Box> { "\"hello world\"" ); assert_eq!( - serde_json::to_string(&<_ as TryInto>::try_into( + serde_json::to_string(&<_ as Into>::into( *b"01234567890123456789013456789012" - )?)?, + ))?, "\"3031323334353637383930313233343536373839303133343536373839303132\"" ); #[cfg(feature = "curr")] @@ -64,7 +64,7 @@ fn test_serde_der() -> Result<(), Box> { )?; assert_eq!( v, - <_ as TryInto>::try_into(*b"01234567890123456789013456789012")?, + <_ as Into>::into(*b"01234567890123456789013456789012"), ); #[cfg(feature = "curr")] diff --git a/tests/tx_debug_display.rs b/tests/tx_debug_display.rs index 9354747a..1550d080 100644 --- a/tests/tx_debug_display.rs +++ b/tests/tx_debug_display.rs @@ -40,7 +40,7 @@ fn test_debug() { assert_eq!( format!( "{:?}", - <_ as TryInto>::try_into(*b"01234567890123456789013456789012").unwrap() + <_ as Into>::into(*b"01234567890123456789013456789012") ), "Hash(3031323334353637383930313233343536373839303133343536373839303132)" ); @@ -91,7 +91,7 @@ fn test_display() -> Result<(), Error> { assert_eq!( format!( "{}", - <_ as TryInto>::try_into(*b"01234567890123456789013456789012").unwrap() + <_ as Into>::into(*b"01234567890123456789013456789012") ), "3031323334353637383930313233343536373839303133343536373839303132" );