chore(clippy): Fix clippy cast and closure warnings (#5378)
* Fix clippy cast and closure warnings * Silence incorrect lints in Clippy 1.64 * Use correct clippy syntax Co-authored-by: Marek <mail@marek.onl> * Disable an incorrect Clippy 1.64 lint * Disable lint on the correct code * Try another place Co-authored-by: Marek <mail@marek.onl>
This commit is contained in:
parent
ff8360122d
commit
7daffb572a
|
@ -275,7 +275,7 @@ impl NonEmptyHistoryTree {
|
|||
// /\ /\ /\ /\ /\ /\ /\ 0
|
||||
//
|
||||
// We start by determining the altitude of the highest peak (A).
|
||||
let mut alt = (32 - ((self.size + 1) as u32).leading_zeros() - 1) - 1;
|
||||
let mut alt = (32 - (self.size + 1).leading_zeros() - 1) - 1;
|
||||
|
||||
// We determine the position of the highest peak (A) by pretending it is the right
|
||||
// sibling in a tree, and its left-most leaf has position 0. Then the left sibling
|
||||
|
|
|
@ -249,7 +249,10 @@ impl ZcashDeserialize for Flags {
|
|||
// Consensus rule: "In a version 5 transaction,
|
||||
// the reserved bits 2..7 of the flagsOrchard field MUST be zero."
|
||||
// https://zips.z.cash/protocol/protocol.pdf#txnencodingandconsensus
|
||||
//
|
||||
// Clippy 1.64 is wrong here, this lazy evaluation is necessary, constructors are functions. This is fixed in 1.66.
|
||||
#[allow(clippy::unnecessary_lazy_evaluations)]
|
||||
Flags::from_bits(reader.read_u8()?)
|
||||
.ok_or(SerializationError::Parse("invalid reserved orchard flags"))
|
||||
.ok_or_else(|| SerializationError::Parse("invalid reserved orchard flags"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -535,7 +535,7 @@ impl Arbitrary for LockTime {
|
|||
(block::Height::MIN.0..=LockTime::MAX_HEIGHT.0)
|
||||
.prop_map(|n| LockTime::Height(block::Height(n))),
|
||||
(LockTime::MIN_TIMESTAMP..=LockTime::MAX_TIMESTAMP)
|
||||
.prop_map(|n| { LockTime::Time(Utc.timestamp(n as i64, 0)) })
|
||||
.prop_map(|n| { LockTime::Time(Utc.timestamp(n, 0)) })
|
||||
]
|
||||
.boxed()
|
||||
}
|
||||
|
|
|
@ -872,11 +872,16 @@ impl ZcashDeserialize for Transaction {
|
|||
}
|
||||
// Denoted as `nConsensusBranchId` in the spec.
|
||||
// Convert it to a NetworkUpgrade
|
||||
//
|
||||
// Clippy 1.64 is wrong here, this lazy evaluation is necessary, constructors are functions. This is fixed in 1.66.
|
||||
#[allow(clippy::unnecessary_lazy_evaluations)]
|
||||
let network_upgrade =
|
||||
NetworkUpgrade::from_branch_id(limited_reader.read_u32::<LittleEndian>()?)
|
||||
.ok_or(SerializationError::Parse(
|
||||
"expected a valid network upgrade from the consensus branch id",
|
||||
))?;
|
||||
.ok_or_else(|| {
|
||||
SerializationError::Parse(
|
||||
"expected a valid network upgrade from the consensus branch id",
|
||||
)
|
||||
})?;
|
||||
|
||||
// Denoted as `lock_time` in the spec.
|
||||
let lock_time = LockTime::zcash_deserialize(&mut limited_reader)?;
|
||||
|
|
|
@ -752,7 +752,7 @@ fn test_vec243_2() -> Result<()> {
|
|||
|
||||
let lock_script = Script::new(&[]);
|
||||
let prevout = transparent::Output { value, lock_script };
|
||||
let index = input_ind as usize;
|
||||
let index = input_ind;
|
||||
let all_previous_outputs = mock_pre_v5_output_list(prevout, input_ind);
|
||||
|
||||
let alt_sighash = crate::primitives::zcash_primitives::sighash(
|
||||
|
@ -805,7 +805,7 @@ fn test_vec243_3() -> Result<()> {
|
|||
"76a914507173527b4c3318a2aecd793bf1cfed705950cf88ac",
|
||||
)?);
|
||||
let prevout = transparent::Output { value, lock_script };
|
||||
let index = input_ind as usize;
|
||||
let index = input_ind;
|
||||
|
||||
let alt_sighash = crate::primitives::zcash_primitives::sighash(
|
||||
&transaction,
|
||||
|
|
|
@ -465,6 +465,8 @@ impl Decoder for Codec {
|
|||
|
||||
impl Codec {
|
||||
fn read_version<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
|
||||
// Clippy 1.64 is wrong here, this lazy evaluation is necessary, constructors are functions. This is fixed in 1.66.
|
||||
#[allow(clippy::unnecessary_lazy_evaluations)]
|
||||
Ok(VersionMessage {
|
||||
version: Version(reader.read_u32::<LittleEndian>()?),
|
||||
// Use from_bits_truncate to discard unknown service bits.
|
||||
|
@ -472,9 +474,7 @@ impl Codec {
|
|||
timestamp: Utc
|
||||
.timestamp_opt(reader.read_i64::<LittleEndian>()?, 0)
|
||||
.single()
|
||||
.ok_or(Error::Parse(
|
||||
"version timestamp is out of range for DateTime",
|
||||
))?,
|
||||
.ok_or_else(|| Error::Parse("version timestamp is out of range for DateTime"))?,
|
||||
address_recv: AddrInVersion::zcash_deserialize(&mut reader)?,
|
||||
address_from: AddrInVersion::zcash_deserialize(&mut reader)?,
|
||||
nonce: Nonce(reader.read_u64::<LittleEndian>()?),
|
||||
|
|
Loading…
Reference in New Issue