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

fix(clippy): Resolve unnecessary borrow lint and remove redundant imports #5045

Merged
merged 1 commit into from
Sep 2, 2022
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
5 changes: 2 additions & 3 deletions zebra-chain/src/block/merkle.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! The Bitcoin-inherited Merkle tree of transactions.
#![allow(clippy::unit_arg)]

use std::convert::TryInto;
use std::iter;
use std::{fmt, io::Write};

Expand Down Expand Up @@ -74,7 +73,7 @@ pub struct Root(pub [u8; 32]);

impl fmt::Debug for Root {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Root").field(&hex::encode(&self.0)).finish()
f.debug_tuple("Root").field(&hex::encode(self.0)).finish()
}
}

Expand Down Expand Up @@ -150,7 +149,7 @@ pub struct AuthDataRoot(pub(crate) [u8; 32]);
impl fmt::Debug for AuthDataRoot {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("AuthRoot")
.field(&hex::encode(&self.0))
.field(&hex::encode(self.0))
.finish()
}
}
Expand Down
9 changes: 3 additions & 6 deletions zebra-chain/src/orchard/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
#[cfg(test)]
mod tests;

use std::{
convert::{From, Into, TryFrom, TryInto},
fmt, io,
};
use std::{fmt, io};

use aes::Aes256;
use bech32::{self, ToBase32, Variant};
Expand Down Expand Up @@ -765,7 +762,7 @@ impl ConstantTimeEq for OutgoingViewingKey {
impl fmt::Debug for OutgoingViewingKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("OutgoingViewingKey")
.field(&hex::encode(&self.0))
.field(&hex::encode(self.0))
.finish()
}
}
Expand Down Expand Up @@ -898,7 +895,7 @@ pub struct Diversifier(pub(crate) [u8; 11]);
impl fmt::Debug for Diversifier {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Diversifier")
.field(&hex::encode(&self.0))
.field(&hex::encode(self.0))
.finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/orchard/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub struct Root(#[serde(with = "serde_helpers::Base")] pub(crate) pallas::Base);
impl fmt::Debug for Root {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Root")
.field(&hex::encode(&self.0.to_repr()))
.field(&hex::encode(self.0.to_repr()))
.finish()
}
}
Expand Down
5 changes: 2 additions & 3 deletions zebra-chain/src/sapling/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ mod test_vectors;
mod tests;

use std::{
convert::{From, Into, TryFrom, TryInto},
fmt,
io::{self, Write},
str::FromStr,
Expand Down Expand Up @@ -426,7 +425,7 @@ pub struct OutgoingViewingKey(pub(crate) [u8; 32]);
impl fmt::Debug for OutgoingViewingKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("OutgoingViewingKey")
.field(&hex::encode(&self.0))
.field(&hex::encode(self.0))
.finish()
}
}
Expand Down Expand Up @@ -741,7 +740,7 @@ pub struct Diversifier(pub(crate) [u8; 11]);
impl fmt::Debug for Diversifier {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Diversifier")
.field(&hex::encode(&self.0))
.field(&hex::encode(self.0))
.finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/sapling/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub struct Root(#[serde(with = "serde_helpers::Fq")] pub(crate) jubjub::Base);
impl fmt::Debug for Root {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Root")
.field(&hex::encode(&self.0.to_bytes()))
.field(&hex::encode(self.0.to_bytes()))
.finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/serialization/sha256d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'a> From<&'a [u8]> for Checksum {
impl fmt::Debug for Checksum {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Sha256dChecksum")
.field(&hex::encode(&self.0))
.field(&hex::encode(self.0))
.finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/sprout/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl fmt::Debug for SproutShieldedAddress {
// Use hex formatting for the transmission key.
.field(
"transmission_key",
&hex::encode(&self.transmission_key.as_bytes()),
&hex::encode(self.transmission_key.as_bytes()),
)
.finish()
}
Expand Down
9 changes: 3 additions & 6 deletions zebra-chain/src/sprout/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl AsRef<[u8]> for PayingKey {
impl fmt::Debug for PayingKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("PayingKey")
.field(&hex::encode(&self.0))
.field(&hex::encode(self.0))
.finish()
}
}
Expand Down Expand Up @@ -245,11 +245,8 @@ impl fmt::Debug for IncomingViewingKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("IncomingViewingKey")
.field("network", &self.network)
.field("paying_key", &hex::encode(&self.paying_key.0))
.field(
"receiving_key",
&hex::encode(&self.receiving_key.to_bytes()),
)
.field("paying_key", &hex::encode(self.paying_key.0))
.field("receiving_key", &hex::encode(self.receiving_key.to_bytes()))
.finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/sprout/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub struct Root([u8; 32]);

impl fmt::Debug for Root {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Root").field(&hex::encode(&self.0)).finish()
f.debug_tuple("Root").field(&hex::encode(self.0)).finish()
}
}

Expand Down
4 changes: 3 additions & 1 deletion zebra-chain/src/transaction/auth_digest.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Authorizing digests for Zcash transactions.

use std::{fmt, sync::Arc};

#[cfg(any(test, feature = "proptest-impl"))]
Expand Down Expand Up @@ -78,7 +80,7 @@ impl fmt::Display for AuthDigest {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut reversed_bytes = self.0;
reversed_bytes.reverse();
f.write_str(&hex::encode(&reversed_bytes))
f.write_str(&hex::encode(reversed_bytes))
}
}

Expand Down
2 changes: 1 addition & 1 deletion zebra-chain/src/transparent/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl Address {
/// <https://en.bitcoin.it/Base58Check_encoding#Encoding_a_Bitcoin_address>
fn hash_payload(bytes: &[u8]) -> [u8; 20] {
let sha_hash = Sha256::digest(bytes);
let ripe_hash = Ripemd160::digest(&sha_hash);
let ripe_hash = Ripemd160::digest(sha_hash);
let mut payload = [0u8; 20];
payload[..].copy_from_slice(&ripe_hash[..]);
payload
Expand Down
3 changes: 1 addition & 2 deletions zebra-chain/src/work/difficulty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::{block, parameters::Network};

use std::{
cmp::{Ordering, PartialEq, PartialOrd},
convert::TryFrom,
fmt,
iter::Sum,
ops::Add,
Expand Down Expand Up @@ -108,7 +107,7 @@ impl fmt::Debug for ExpandedDifficulty {
// Use the same byte order as block::Hash
self.0.to_big_endian(&mut buf);
f.debug_tuple("ExpandedDifficulty")
.field(&hex::encode(&buf))
.field(&hex::encode(buf))
.finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-network/src/protocol/external/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Magic(pub [u8; 4]);

impl fmt::Debug for Magic {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Magic").field(&hex::encode(&self.0)).finish()
f.debug_tuple("Magic").field(&hex::encode(self.0)).finish()
}
}

Expand Down
2 changes: 1 addition & 1 deletion zebra-utils/src/bin/zebra-checkpoints/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn main() -> Result<()> {
let mut cmd = passthrough_cmd();

// get block data
cmd.args(&["getblock", &x.to_string()]);
cmd.args(["getblock", &x.to_string()]);
let output = cmd_output(&mut cmd)?;
// parse json
let v: Value = serde_json::from_str(&output)?;
Expand Down
2 changes: 1 addition & 1 deletion zebrad/tests/common/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ where
let cache_dir = dir.join("state");
fs::create_dir_all(&cache_dir)?;
} else {
fs::create_dir_all(&dir)?;
fs::create_dir_all(dir)?;
}

let config_file = dir.join("zebrad.toml");
Expand Down