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

Chore: update clippy to toolchain 1.84 rules #986

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ missing_panics_doc = "allow"
module_name_repetitions = "allow"
unreadable_literal = "allow"
similar_names = "allow"
too_long_first_doc_paragraph = "allow"

[workspace]
resolver = "2"
Expand Down
2 changes: 2 additions & 0 deletions engine-hashchain/src/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//!
//! Reimplemented here since there is a large mismatch in types and dependencies.
#![allow(clippy::expl_impl_clone_on_copy, clippy::non_canonical_clone_impl)]
// NOTE: `fixed_hash` crate has clippy issue
#![allow(unexpected_cfgs)]

use aurora_engine_sdk::keccak;
use aurora_engine_types::borsh::{BorshDeserialize, BorshSerialize};
Expand Down
2 changes: 1 addition & 1 deletion engine-hashchain/src/wrapped_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<T: StorageIntermediate> StorageIntermediate for WrappedInput<T> {
}
}

impl<'cache, I: IO> IO for CachedIO<'cache, I> {
impl<I: IO> IO for CachedIO<'_, I> {
type StorageValue = WrappedInput<I::StorageValue>;

fn read_input(&self) -> Self::StorageValue {
Expand Down
2 changes: 1 addition & 1 deletion engine-precompiles/src/account_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a, E> PredecessorAccount<'a, E> {
}
}

impl<'a, E: Env> Precompile for PredecessorAccount<'a, E> {
impl<E: Env> Precompile for PredecessorAccount<'_, E> {
fn required_gas(_input: &[u8]) -> Result<EthGas, ExitError> {
Ok(costs::PREDECESSOR_ACCOUNT_GAS)
}
Expand Down
4 changes: 4 additions & 0 deletions engine-precompiles/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ impl SHA256 {
}

impl Precompile for SHA256 {
// TODO: should be enable from `RUst 1.84`
// #[allow(clippy::manual_div_ceil)]
fn required_gas(input: &[u8]) -> Result<EthGas, ExitError> {
let input_len = u64::try_from(input.len()).map_err(utils::err_usize_conv)?;
Ok(
Expand Down Expand Up @@ -105,6 +107,8 @@ impl RIPEMD160 {
}

impl Precompile for RIPEMD160 {
// TODO: should be enable from `RUst 1.84`
// #[allow(clippy::manual_div_ceil)]
fn required_gas(input: &[u8]) -> Result<EthGas, ExitError> {
let input_len = u64::try_from(input.len()).map_err(utils::err_usize_conv)?;
Ok(
Expand Down
2 changes: 2 additions & 0 deletions engine-precompiles/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ impl Identity {
}

impl Precompile for Identity {
// TODO: should be enable from `RUst 1.84`
// #[allow(clippy::manual_div_ceil)]
fn required_gas(input: &[u8]) -> Result<EthGas, ExitError> {
let input_len = u64::try_from(input.len()).map_err(utils::err_usize_conv)?;
Ok(
Expand Down
7 changes: 4 additions & 3 deletions engine-precompiles/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![forbid(unsafe_code)]

pub mod account_ids;
pub mod alt_bn256;
pub mod blake2;
Expand Down Expand Up @@ -114,14 +115,14 @@ pub struct Precompiles<'a, I, E, H> {
pub paused_precompiles: BTreeSet<Address>,
}

impl<'a, I, E, H> Precompiles<'a, I, E, H> {
impl<I, E, H> Precompiles<'_, I, E, H> {
fn is_paused(&self, address: &Address) -> bool {
self.paused_precompiles.contains(address)
}
}

impl<'a, I: IO + Copy, E: Env, H: ReadOnlyPromiseHandler> executor::stack::PrecompileSet
for Precompiles<'a, I, E, H>
impl<I: IO + Copy, E: Env, H: ReadOnlyPromiseHandler> executor::stack::PrecompileSet
for Precompiles<'_, I, E, H>
{
fn execute(
&self,
Expand Down
2 changes: 1 addition & 1 deletion engine-precompiles/src/prepaid_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<'a, E> PrepaidGas<'a, E> {
}
}

impl<'a, E: Env> Precompile for PrepaidGas<'a, E> {
impl<E: Env> Precompile for PrepaidGas<'_, E> {
fn required_gas(_input: &[u8]) -> Result<EthGas, ExitError> {
Ok(costs::PREPAID_GAS_COST)
}
Expand Down
4 changes: 2 additions & 2 deletions engine-standalone-storage/src/engine_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum EngineStorageValue<'a> {
Vec(Vec<u8>),
}

impl<'a> AsRef<[u8]> for EngineStorageValue<'a> {
impl AsRef<[u8]> for EngineStorageValue<'_> {
fn as_ref(&self) -> &[u8] {
match self {
Self::Slice(slice) => slice,
Expand All @@ -20,7 +20,7 @@ impl<'a> AsRef<[u8]> for EngineStorageValue<'a> {
}
}

impl<'a> StorageIntermediate for EngineStorageValue<'a> {
impl StorageIntermediate for EngineStorageValue<'_> {
fn len(&self) -> usize {
self.as_ref().len()
}
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl Storage {

// move to the next key by skipping all other DB keys corresponding to the same engine key
while iter.valid()
&& iter.key().map_or(false, |db_key| {
&& iter.key().is_some_and(|db_key| {
db_key[0..engine_prefix_len] == engine_prefix
&& &db_key[engine_prefix_len..(db_key.len() - ENGINE_KEY_SUFFIX_LEN)]
== *engine_key
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/promise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct NoScheduler<'a> {
pub promise_data: &'a [Option<Vec<u8>>],
}

impl<'a> PromiseHandler for NoScheduler<'a> {
impl PromiseHandler for NoScheduler<'_> {
type ReadOnly = Self;

fn promise_results_count(&self) -> u64 {
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-tracing/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ mod opcode_serde {

struct U8Visitor;

impl<'de> serde::de::Visitor<'de> for U8Visitor {
impl serde::de::Visitor<'_> for U8Visitor {
type Value = u8;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion engine-test-doubles/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Storage {
#[derive(Debug, Clone, Copy)]
pub struct StoragePointer<'a>(pub &'a RefCell<Storage>);

impl<'a> IO for StoragePointer<'a> {
impl IO for StoragePointer<'_> {
type StorageValue = Value;

fn read_input(&self) -> Self::StorageValue {
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub struct OneShotAuroraRunner<'a> {
pub context: VMContext,
}

impl<'a> OneShotAuroraRunner<'a> {
impl OneShotAuroraRunner<'_> {
pub fn profiled_call(
self,
method_name: &str,
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/utils/one_inch/liquidity_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Helper<'a> {
pub signer: &'a mut utils::Signer,
}

impl<'a> Helper<'a> {
impl Helper<'_> {
pub(crate) fn create_mooniswap_deployer(
&mut self,
) -> (SubmitResult, ExecutionProfile, PoolDeployer) {
Expand Down
4 changes: 2 additions & 2 deletions engine-types/src/account_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ mod tests {
assert!(
account_id
.parse::<AccountId>()
.map_or(false, |account_id| account_id.is_top_level_account_id()),
.is_ok_and(|account_id| account_id.is_top_level_account_id()),
"Valid top level account id {account_id:?} marked invalid",
);
}
Expand Down Expand Up @@ -364,7 +364,7 @@ mod tests {
assert!(
!account_id
.parse::<AccountId>()
.map_or(false, |account_id| account_id.is_top_level_account_id()),
.is_ok_and(|account_id| account_id.is_top_level_account_id()),
"Invalid top level account id {account_id:?} marked valid",
);
}
Expand Down
2 changes: 1 addition & 1 deletion engine-types/src/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn split_key_type_data(value: &str) -> Result<(KeyType, &str), DecodeBs58Error>
// for that: https://github.com/Nullus157/bs58-rs/pull/97
struct Bs58<'a>(&'a [u8]);

impl<'a> fmt::Display for Bs58<'a> {
impl fmt::Display for Bs58<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
debug_assert!(self.0.len() <= 65);
// The largest buffer we’re ever encoding is 65-byte long. Base58
Expand Down
10 changes: 5 additions & 5 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ pub fn submit_with_alt_modexp<
let fixed_gas = silo::get_fixed_gas(&io);

// Check if the sender has rights to submit transactions or deploy code on SILO mode.
assert_access(&io, env, &fixed_gas, &transaction)?;
assert_access(&io, env, fixed_gas, &transaction)?;

// Validate the chain ID, if provided inside the signature:
if let Some(chain_id) = transaction.chain_id {
Expand All @@ -1050,7 +1050,7 @@ pub fn submit_with_alt_modexp<
check_nonce(&io, &sender, &transaction.nonce)?;

// Check that fixed gas is not greater than gasLimit from the transaction.
if fixed_gas.map_or(false, |gas| gas.as_u256() > transaction.gas_limit) {
if fixed_gas.is_some_and(|gas| gas.as_u256() > transaction.gas_limit) {
return Err(EngineErrorKind::FixedGasOverflow.into());
}

Expand Down Expand Up @@ -1739,7 +1739,7 @@ unsafe fn schedule_promise_callback<P: PromiseHandler>(
fn assert_access<I: IO + Copy, E: Env>(
io: &I,
env: &E,
fixed_gas: &Option<EthGas>,
fixed_gas: Option<EthGas>,
transaction: &NormalizedEthTransaction,
) -> Result<(), EngineError> {
if fixed_gas.is_some() {
Expand All @@ -1760,7 +1760,7 @@ fn assert_access<I: IO + Copy, E: Env>(
Ok(())
}

impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Backend for Engine<'env, I, E, M> {
impl<I: IO + Copy, E: Env, M: ModExpAlgorithm> Backend for Engine<'_, I, E, M> {
/// Returns the "effective" gas price (as defined by EIP-1559)
fn gas_price(&self) -> U256 {
self.gas_price
Expand Down Expand Up @@ -1958,7 +1958,7 @@ impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Backend for Engine<'env, I,
}
}

impl<'env, J: IO + Copy, E: Env, M: ModExpAlgorithm> ApplyBackend for Engine<'env, J, E, M> {
impl<J: IO + Copy, E: Env, M: ModExpAlgorithm> ApplyBackend for Engine<'_, J, E, M> {
fn apply<A, I, L>(&mut self, values: A, _logs: L, delete_empty: bool)
where
A: IntoIterator<Item = Apply<I>>,
Expand Down
2 changes: 1 addition & 1 deletion engine/src/pausables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl PrecompileFlags {
/// Checks if the precompile belonging to the `address` is marked as paused.
#[must_use]
pub fn is_paused_by_address(&self, address: &Address) -> bool {
Self::from_address(address).map_or(false, |precompile_flag| self.contains(precompile_flag))
Self::from_address(address).is_some_and(|precompile_flag| self.contains(precompile_flag))
}
}

Expand Down
2 changes: 1 addition & 1 deletion engine/src/xcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl<'a, H> PromiseInterceptor<'a, H> {
}
}

impl<'a, H: PromiseHandler> PromiseHandler for PromiseInterceptor<'a, H> {
impl<H: PromiseHandler> PromiseHandler for PromiseInterceptor<'_, H> {
type ReadOnly = H::ReadOnly;

fn promise_results_count(&self) -> u64 {
Expand Down
Loading