evm icon indicating copy to clipboard operation
evm copied to clipboard

Chore: silence clippy closure in match warning

Open clayrab opened this issue 1 year ago • 2 comments

Clippy is complaining about closures in match conditions.

https://rust-lang.github.io/rust-clippy/master/index.html#/blocks_in_conditions

I think the claim that this style "makes it hard to read" is subjective. I personally find these to be easily readable and I think it would be okay to just silence this warning.

These are the 2 offending blocks:

in misc.rs:

	match stack.perform_pop0_push1(|| {
		let size = U256::from(code.len());
		Ok((u256_to_h256(size), ()))
	}) {
		Ok(()) => Control::Continue,
		Err(e) => Control::Exit(Err(e)),
	}

in system.rs

	match machine.stack.perform_pop1_push0(|target| {
		let balance = handler.balance(address);

		handler.transfer(Transfer {
			source: address,
			target: (*target).into(),
			value: balance,
		})?;

		handler.mark_delete(address);
		handler.reset_balance(address);

		Ok(((), ()))
	}) {
		Ok(()) => Control::Exit(ExitSucceed::Suicided.into()),
		Err(e) => Control::Exit(Err(e)),
	}

I think find clippy is a bit heavy-handed, we've silenced quite a few things on litheumcore:

cargo clippy -- -A clippy::new_without_default -A clippy::too_many_arguments -A clippy::borrowed_box -A clippy::redundant_pattern_matching -A clippy::needless_bool -A clippy::or_fun_call -A clippy::len_without_is_empty -A clippy::identity_op -A clippy::collapsible_else_if -A clippy::unnecessary_fold -A clippy::map_flatten

clayrab avatar Jan 06 '24 12:01 clayrab