Skip to content

Commit

Permalink
chore: apply new lint warnings from latest clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Dec 14, 2024
1 parent 106d867 commit 9a25dfc
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 67 deletions.
37 changes: 18 additions & 19 deletions pallas-applying/tests/babbage.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod common;

use common::*;
use hex;
use pallas_addresses::{Address, Network, ShelleyAddress, ShelleyPaymentPart};
use pallas_applying::{
utils::{
Expand Down Expand Up @@ -598,7 +597,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -675,7 +674,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -725,7 +724,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -857,7 +856,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -1019,7 +1018,7 @@ mod babbage_tests {
};
let altered_address: ShelleyAddress = ShelleyAddress::new(
old_shelley_address.network(),
ShelleyPaymentPart::Script(old_shelley_address.payment().as_hash().clone()),
ShelleyPaymentPart::Script(*old_shelley_address.payment().as_hash()),
old_shelley_address.delegation().clone(),
);
let tx_in = mtx
Expand Down Expand Up @@ -1303,7 +1302,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -1346,11 +1345,11 @@ mod babbage_tests {
)];
let utxos: UTxOs = mk_utxo_for_babbage_tx(&mtx.transaction_body, tx_outs_info);
let mut tx_body: MintedTransactionBody = (*mtx.transaction_body).clone();
tx_body.fee = tx_body.fee - 1;
tx_body.fee -= 1;
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -1480,7 +1479,7 @@ mod babbage_tests {
let utxos: UTxOs = mk_utxo_for_babbage_tx(&mtx.transaction_body, tx_outs_info);
let mut tx_body: MintedTransactionBody = (*mtx.transaction_body).clone();
let (first_output, rest): (&MintedTransactionOutput, &[MintedTransactionOutput]) =
(&tx_body.outputs).split_first().unwrap();
tx_body.outputs.split_first().unwrap();
let (address_bytes, val): (Bytes, Value) = match first_output {
PseudoTransactionOutput::Legacy(output) => {
(output.address.clone(), output.amount.clone())
Expand Down Expand Up @@ -1511,7 +1510,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -1561,7 +1560,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -1809,7 +1808,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -1977,7 +1976,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -2066,7 +2065,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -2156,12 +2155,12 @@ mod babbage_tests {
let mut new_datum_buf: Vec<u8> = Vec::new();
let _ = encode(new_datum, &mut new_datum_buf);
let keep_raw_new_datum: KeepRaw<PlutusData> =
Decode::decode(&mut Decoder::new(&new_datum_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(new_datum_buf.as_slice()), &mut ()).unwrap();
tx_wits.plutus_data = Some(vec![old_datum, keep_raw_new_datum]);
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -2254,7 +2253,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down Expand Up @@ -2344,7 +2343,7 @@ mod babbage_tests {
let mut tx_witness_set_buf: Vec<u8> = Vec::new();
let _ = encode(tx_witness_set, &mut tx_witness_set_buf);
mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_witness_set_buf.as_slice()), &mut ()).unwrap();
Decode::decode(&mut Decoder::new(tx_witness_set_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState {
treasury: 261_254_564_000_000,
Expand Down
6 changes: 3 additions & 3 deletions pallas-applying/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ pub fn minted_tx_from_cbor(tx_cbor: &[u8]) -> MintedTx<'_> {
}

pub fn babbage_minted_tx_from_cbor(tx_cbor: &[u8]) -> BabbageMintedTx<'_> {
pallas_codec::minicbor::decode::<BabbageMintedTx>(&tx_cbor[..]).unwrap()
pallas_codec::minicbor::decode::<BabbageMintedTx>(tx_cbor).unwrap()
}

pub fn minted_tx_payload_from_cbor<'a>(tx_cbor: &'a Vec<u8>) -> MintedTxPayload<'a> {
pallas_codec::minicbor::decode::<MintedTxPayload>(&tx_cbor[..]).unwrap()
pub fn minted_tx_payload_from_cbor(tx_cbor: &[u8]) -> MintedTxPayload<'_> {
pallas_codec::minicbor::decode::<MintedTxPayload>(tx_cbor).unwrap()
}

pub fn mk_utxo_for_byron_tx<'a>(tx: &Tx, tx_outs_info: &[(String, u64)]) -> UTxOs<'a> {
Expand Down
2 changes: 1 addition & 1 deletion pallas-codec/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ impl<'b, T> KeepRaw<'b, T> {
}
}

impl<'b, T> Deref for KeepRaw<'b, T> {
impl<T> Deref for KeepRaw<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand Down
2 changes: 1 addition & 1 deletion pallas-crypto/src/hash/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl<const BITS: usize> Write for Hasher<BITS> {
}
*/

impl<'a, const BITS: usize> minicbor::encode::Write for &'a mut Hasher<BITS> {
impl<const BITS: usize> minicbor::encode::Write for &mut Hasher<BITS> {
type Error = std::convert::Infallible;

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion pallas-crypto/src/hash/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<const BYTES: usize> Serialize for Hash<BYTES> {

struct HashVisitor<const BYTES: usize> {}

impl<'de, const BYTES: usize> Visitor<'de> for HashVisitor<BYTES> {
impl<const BYTES: usize> Visitor<'_> for HashVisitor<BYTES> {
type Value = Hash<BYTES>;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
18 changes: 6 additions & 12 deletions pallas-crypto/src/nonce/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,21 @@ mod tests {

#[test]
fn test_epoch_nonce() {
let nc_values = vec![
hex::decode("e86e133bd48ff5e79bec43af1ac3e348b539172f33e502d2c96735e8c51bd04d")
let nc_values = [hex::decode("e86e133bd48ff5e79bec43af1ac3e348b539172f33e502d2c96735e8c51bd04d")
.unwrap(),
hex::decode("d1340a9c1491f0face38d41fd5c82953d0eb48320d65e952414a0c5ebaf87587")
.unwrap(),
];
let nh_values = vec![
hex::decode("d7a1ff2a365abed59c9ae346cba842b6d3df06d055dba79a113e0704b44cc3e9")
.unwrap()];
let nh_values = [hex::decode("d7a1ff2a365abed59c9ae346cba842b6d3df06d055dba79a113e0704b44cc3e9")
.unwrap(),
hex::decode("ee91d679b0a6ce3015b894c575c799e971efac35c7a8cbdc2b3f579005e69abd")
.unwrap(),
];
.unwrap()];
let ee = hex::decode("d982e06fd33e7440b43cefad529b7ecafbaa255e38178ad4189a37e4ce9bf1fa")
.unwrap();
let extra_entropy_values: Vec<Option<&[u8]>> = vec![None, Some(&ee)];
let expected_epoch_nonces = vec![
hex::decode("e536a0081ddd6d19786e9d708a85819a5c3492c0da7349f59c8ad3e17e4acd98")
let expected_epoch_nonces = [hex::decode("e536a0081ddd6d19786e9d708a85819a5c3492c0da7349f59c8ad3e17e4acd98")
.unwrap(),
hex::decode("0022cfa563a5328c4fb5c8017121329e964c26ade5d167b1bd9b2ec967772b60")
.unwrap(),
];
.unwrap()];

for (nc_value, nh_value, extra_entropy_value, expected_epoch_nonce) in izip!(
nc_values.iter(),
Expand Down
2 changes: 1 addition & 1 deletion pallas-hardano/src/storage/immutable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ mod tests {
}

fn read_full_snapshot(path: &Path) {
let reader = super::read_blocks(&path).unwrap();
let reader = super::read_blocks(path).unwrap();

let mut count = 0;
let mut last_slot = None;
Expand Down
20 changes: 10 additions & 10 deletions pallas-math/src/math_dashu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl Neg for Decimal {
}

// Implement Neg for a reference to Decimal
impl<'a> Neg for &'a Decimal {
impl Neg for &Decimal {
type Output = Decimal;

fn neg(self) -> Self::Output {
Expand All @@ -138,7 +138,7 @@ impl Abs for Decimal {
}

// Implement Abs for a reference to Decimal
impl<'a> Abs for &'a Decimal {
impl Abs for &Decimal {
type Output = Decimal;

fn abs(self) -> Self::Output {
Expand Down Expand Up @@ -167,7 +167,7 @@ impl MulAssign for Decimal {
}

// Implement Mul for a reference to Decimal
impl<'a, 'b> Mul<&'b Decimal> for &'a Decimal {
impl<'b> Mul<&'b Decimal> for &Decimal {
type Output = Decimal;

fn mul(self, rhs: &'b Decimal) -> Self::Output {
Expand All @@ -178,7 +178,7 @@ impl<'a, 'b> Mul<&'b Decimal> for &'a Decimal {
}
}

impl<'a, 'b> MulAssign<&'b Decimal> for &'a mut Decimal {
impl<'b> MulAssign<&'b Decimal> for &mut Decimal {
fn mul_assign(&mut self, rhs: &'b Decimal) {
self.data *= &rhs.data;
scale(&mut self.data);
Expand All @@ -203,7 +203,7 @@ impl DivAssign for Decimal {
}

// Implement Div for a reference to Decimal
impl<'a, 'b> Div<&'b Decimal> for &'a Decimal {
impl<'b> Div<&'b Decimal> for &Decimal {
type Output = Decimal;

fn div(self, rhs: &'b Decimal) -> Self::Output {
Expand All @@ -213,7 +213,7 @@ impl<'a, 'b> Div<&'b Decimal> for &'a Decimal {
}
}

impl<'a, 'b> DivAssign<&'b Decimal> for &'a mut Decimal {
impl<'b> DivAssign<&'b Decimal> for &mut Decimal {
fn div_assign(&mut self, rhs: &'b Decimal) {
let temp = self.data.clone();
div(&mut self.data, &temp, &rhs.data);
Expand All @@ -237,7 +237,7 @@ impl SubAssign for Decimal {
}

// Implement Sub for a reference to Decimal
impl<'a, 'b> Sub<&'b Decimal> for &'a Decimal {
impl<'b> Sub<&'b Decimal> for &Decimal {
type Output = Decimal;

fn sub(self, rhs: &'b Decimal) -> Self::Output {
Expand All @@ -247,7 +247,7 @@ impl<'a, 'b> Sub<&'b Decimal> for &'a Decimal {
}
}

impl<'a, 'b> SubAssign<&'b Decimal> for &'a mut Decimal {
impl<'b> SubAssign<&'b Decimal> for &mut Decimal {
fn sub_assign(&mut self, rhs: &'b Decimal) {
self.data -= &rhs.data;
}
Expand All @@ -270,7 +270,7 @@ impl AddAssign for Decimal {
}

// Implement Add for a reference to Decimal
impl<'a, 'b> Add<&'b Decimal> for &'a Decimal {
impl<'b> Add<&'b Decimal> for &Decimal {
type Output = Decimal;

fn add(self, rhs: &'b Decimal) -> Self::Output {
Expand All @@ -280,7 +280,7 @@ impl<'a, 'b> Add<&'b Decimal> for &'a Decimal {
}
}

impl<'a, 'b> AddAssign<&'b Decimal> for &'a mut Decimal {
impl<'b> AddAssign<&'b Decimal> for &mut Decimal {
fn add_assign(&mut self, rhs: &'b Decimal) {
self.data += &rhs.data;
}
Expand Down
4 changes: 2 additions & 2 deletions pallas-traverse/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pallas_crypto::hash::Hash;

use crate::{MultiEraAsset, MultiEraPolicyAssets};

impl<'b> MultiEraPolicyAssets<'b> {
impl MultiEraPolicyAssets<'_> {
pub fn policy(&self) -> &Hash<28> {
match self {
MultiEraPolicyAssets::AlonzoCompatibleMint(x, _) => x,
Expand Down Expand Up @@ -74,7 +74,7 @@ impl<'b> MultiEraPolicyAssets<'b> {
}
}

impl<'b> MultiEraAsset<'b> {
impl MultiEraAsset<'_> {
pub fn policy(&self) -> &Hash<28> {
match self {
MultiEraAsset::AlonzoCompatibleMint(x, ..) => x,
Expand Down
2 changes: 1 addition & 1 deletion pallas-traverse/src/auxiliary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use pallas_primitives::alonzo;

use crate::MultiEraTx;

impl<'b> MultiEraTx<'b> {
impl MultiEraTx<'_> {
pub fn aux_plutus_v1_scripts(&self) -> &[alonzo::PlutusScript<1>] {
if let Some(aux_data) = self.aux_data() {
if let alonzo::AuxiliaryData::PostAlonzo(x) = aux_data.deref() {
Expand Down
2 changes: 1 addition & 1 deletion pallas-traverse/src/cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pallas_primitives::{alonzo, conway};

use crate::MultiEraCert;

impl<'b> MultiEraCert<'b> {
impl MultiEraCert<'_> {
pub fn as_alonzo(&self) -> Option<&alonzo::Certificate> {
match self {
MultiEraCert::AlonzoCompatible(x) => Some(x),
Expand Down
2 changes: 1 addition & 1 deletion pallas-traverse/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pallas_primitives::alonzo;

use crate::MultiEraMeta;

impl<'b> MultiEraMeta<'b> {
impl MultiEraMeta<'_> {
pub fn as_alonzo(&self) -> Option<&alonzo::Metadata> {
match self {
Self::AlonzoCompatible(x) => Some(x),
Expand Down
2 changes: 1 addition & 1 deletion pallas-traverse/src/signers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl Default for MultiEraSigners<'_> {
}
}

impl<'b> MultiEraSigners<'b> {
impl MultiEraSigners<'_> {
pub fn as_alonzo(&self) -> Option<&alonzo::RequiredSigners> {
match self {
Self::AlonzoCompatible(x) => Some(x),
Expand Down
Loading

0 comments on commit 9a25dfc

Please sign in to comment.