chore(lez,lee): fix clippy pedantic/nursery/restriction findings

Resolves needless_pass_by_value (take AccountWithMetadata/Account by
reference where only borrowed), unnecessary_wraps (drop Result<Data,
Infallible> from passthrough update_from_diff implementations),
missing_const_for_fn, useless_let_if_seq, arbitrary_source_item_ordering,
too_many_arguments, redundant_clone, and useless_conversion across the
guest programs and lee core touched by the incremental-updates rebase.
This commit is contained in:
Marvin Jones
2026-08-22 02:03:43 -04:00
parent b676c6c360
commit 15dbd6f1a6
55 changed files with 494 additions and 549 deletions
@@ -37,8 +37,7 @@ fn main() {
pre_state,
diff_data,
} => {
let data = update_from_diff(pre_state.clone(), diff_data.clone())
.expect("update_from_diff should not fail");
let data = update_from_diff(pre_state.clone(), diff_data.clone());
write_update_from_diff_output(pre_state, diff_data, data);
return;
}
@@ -85,9 +84,6 @@ fn main() {
.write();
}
fn update_from_diff(
_pre_state: Account,
diff_data: Data,
) -> Result<Data, std::convert::Infallible> {
Ok(diff_data)
fn update_from_diff(_pre_state: Account, diff_data: Data) -> Data {
diff_data
}
@@ -37,8 +37,7 @@ fn main() {
pre_state,
diff_data,
} => {
let data = update_from_diff(pre_state.clone(), diff_data.clone())
.expect("update_from_diff should not fail");
let data = update_from_diff(pre_state.clone(), diff_data.clone());
write_update_from_diff_output(pre_state, diff_data, data);
return;
}
@@ -92,9 +91,6 @@ fn main() {
.write();
}
fn update_from_diff(
_pre_state: Account,
diff_data: Data,
) -> Result<Data, std::convert::Infallible> {
Ok(diff_data)
fn update_from_diff(_pre_state: Account, diff_data: Data) -> Data {
diff_data
}
@@ -27,7 +27,7 @@ const MOVE_DATA_FUNCTION_ID: u8 = 1;
type Instruction = (u8, Vec<u8>);
fn write(pre_state: AccountWithMetadata, greeting: &[u8]) -> AccountDiffOutput {
fn write(pre_state: &AccountWithMetadata, greeting: &[u8]) -> AccountDiffOutput {
// Construct the new data value
let new_data: Data = {
let mut bytes = pre_state.account.data.clone().into_inner();
@@ -48,7 +48,10 @@ fn write(pre_state: AccountWithMetadata, greeting: &[u8]) -> AccountDiffOutput {
)
}
fn move_data(from_pre: AccountWithMetadata, to_pre: AccountWithMetadata) -> Vec<AccountDiffOutput> {
fn move_data(
from_pre: &AccountWithMetadata,
to_pre: &AccountWithMetadata,
) -> Vec<AccountDiffOutput> {
// Construct the post state account values
let from_data: Vec<u8> = from_pre.account.data.clone().into();
@@ -98,8 +101,7 @@ fn main() {
pre_state,
diff_data,
} => {
let data = update_from_diff(pre_state.clone(), diff_data.clone())
.expect("update_from_diff should not fail");
let data = update_from_diff(pre_state.clone(), diff_data.clone());
write_update_from_diff_output(pre_state, diff_data, data);
return;
}
@@ -107,11 +109,11 @@ fn main() {
let post_states = match (pre_states.as_slice(), function_id, data.len()) {
([account_pre], WRITE_FUNCTION_ID, _) => {
let post = write(account_pre.clone(), &data);
let post = write(account_pre, &data);
vec![post]
}
([account_from_pre, account_to_pre], MOVE_DATA_FUNCTION_ID, 0) => {
move_data(account_from_pre.clone(), account_to_pre.clone())
move_data(account_from_pre, account_to_pre)
}
_ => panic!("invalid params"),
};
@@ -128,9 +130,6 @@ fn main() {
.write();
}
fn update_from_diff(
_pre_state: Account,
diff_data: Data,
) -> Result<Data, std::convert::Infallible> {
Ok(diff_data)
fn update_from_diff(_pre_state: Account, diff_data: Data) -> Data {
diff_data
}