fixes errors from clippy::redundant_clone (#29536)
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
This commit is contained in:
parent
3b7ebfe50e
commit
12da2da389
|
@ -87,8 +87,7 @@ mod test {
|
|||
meta: lookup_table_meta,
|
||||
addresses: Cow::Owned(addresses),
|
||||
};
|
||||
let lookup_table_data =
|
||||
AddressLookupTable::serialize_for_tests(lookup_table.clone()).unwrap();
|
||||
let lookup_table_data = AddressLookupTable::serialize_for_tests(lookup_table).unwrap();
|
||||
|
||||
let parsing_result = parse_address_lookup_table(&lookup_table_data).unwrap();
|
||||
if let LookupTableAccountType::LookupTable(ui_lookup_table) = parsing_result {
|
||||
|
|
|
@ -224,16 +224,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_values_of() {
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--multiple", "50", "--multiple", "39"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--multiple", "50", "--multiple", "39"]);
|
||||
assert_eq!(values_of(&matches, "multiple"), Some(vec![50, 39]));
|
||||
assert_eq!(values_of::<u64>(&matches, "single"), None);
|
||||
|
||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let matches = app().clone().get_matches_from(vec![
|
||||
let matches = app().get_matches_from(vec![
|
||||
"test",
|
||||
"--multiple",
|
||||
&pubkey0.to_string(),
|
||||
|
@ -248,16 +245,12 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_value_of() {
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "50"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "50"]);
|
||||
assert_eq!(value_of(&matches, "single"), Some(50));
|
||||
assert_eq!(value_of::<u64>(&matches, "multiple"), None);
|
||||
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &pubkey.to_string()]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", &pubkey.to_string()]);
|
||||
assert_eq!(value_of(&matches, "single"), Some(pubkey));
|
||||
}
|
||||
|
||||
|
@ -267,19 +260,14 @@ mod tests {
|
|||
let outfile = tmp_file_path("test_keypair_of.json", &keypair.pubkey());
|
||||
let _ = write_keypair_file(&keypair, &outfile).unwrap();
|
||||
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &outfile]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", &outfile]);
|
||||
assert_eq!(
|
||||
keypair_of(&matches, "single").unwrap().pubkey(),
|
||||
keypair.pubkey()
|
||||
);
|
||||
assert!(keypair_of(&matches, "multiple").is_none());
|
||||
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
assert!(keypair_of(&matches, "single").is_none());
|
||||
|
||||
fs::remove_file(&outfile).unwrap();
|
||||
|
@ -291,22 +279,15 @@ mod tests {
|
|||
let outfile = tmp_file_path("test_pubkey_of.json", &keypair.pubkey());
|
||||
let _ = write_keypair_file(&keypair, &outfile).unwrap();
|
||||
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &outfile]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", &outfile]);
|
||||
assert_eq!(pubkey_of(&matches, "single"), Some(keypair.pubkey()));
|
||||
assert_eq!(pubkey_of(&matches, "multiple"), None);
|
||||
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &keypair.pubkey().to_string()]);
|
||||
app().get_matches_from(vec!["test", "--single", &keypair.pubkey().to_string()]);
|
||||
assert_eq!(pubkey_of(&matches, "single"), Some(keypair.pubkey()));
|
||||
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
assert_eq!(pubkey_of(&matches, "single"), None);
|
||||
|
||||
fs::remove_file(&outfile).unwrap();
|
||||
|
@ -318,7 +299,7 @@ mod tests {
|
|||
let outfile = tmp_file_path("test_pubkeys_of.json", &keypair.pubkey());
|
||||
let _ = write_keypair_file(&keypair, &outfile).unwrap();
|
||||
|
||||
let matches = app().clone().get_matches_from(vec![
|
||||
let matches = app().get_matches_from(vec![
|
||||
"test",
|
||||
"--multiple",
|
||||
&keypair.pubkey().to_string(),
|
||||
|
@ -340,13 +321,8 @@ mod tests {
|
|||
let sig2 = Keypair::new().sign_message(&[1u8]);
|
||||
let signer1 = format!("{key1}={sig1}");
|
||||
let signer2 = format!("{key2}={sig2}");
|
||||
let matches = app().clone().get_matches_from(vec![
|
||||
"test",
|
||||
"--multiple",
|
||||
&signer1,
|
||||
"--multiple",
|
||||
&signer2,
|
||||
]);
|
||||
let matches =
|
||||
app().get_matches_from(vec!["test", "--multiple", &signer1, "--multiple", &signer2]);
|
||||
assert_eq!(
|
||||
pubkeys_sigs_of(&matches, "multiple"),
|
||||
Some(vec![(key1, sig1), (key2, sig2)])
|
||||
|
@ -355,19 +331,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_lamports_of_sol() {
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "50"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "50"]);
|
||||
assert_eq!(lamports_of_sol(&matches, "single"), Some(50_000_000_000));
|
||||
assert_eq!(lamports_of_sol(&matches, "multiple"), None);
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "1.5"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "1.5"]);
|
||||
assert_eq!(lamports_of_sol(&matches, "single"), Some(1_500_000_000));
|
||||
assert_eq!(lamports_of_sol(&matches, "multiple"), None);
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "0.03"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "0.03"]);
|
||||
assert_eq!(lamports_of_sol(&matches, "single"), Some(30_000_000));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,16 +225,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_values_of() {
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--multiple", "50", "--multiple", "39"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--multiple", "50", "--multiple", "39"]);
|
||||
assert_eq!(values_of(&matches, "multiple"), Some(vec![50, 39]));
|
||||
assert_eq!(values_of::<u64>(&matches, "single"), None);
|
||||
|
||||
let pubkey0 = solana_sdk::pubkey::new_rand();
|
||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
||||
let matches = app().clone().get_matches_from(vec![
|
||||
let matches = app().get_matches_from(vec![
|
||||
"test",
|
||||
"--multiple",
|
||||
&pubkey0.to_string(),
|
||||
|
@ -249,16 +246,12 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_value_of() {
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "50"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "50"]);
|
||||
assert_eq!(value_of(&matches, "single"), Some(50));
|
||||
assert_eq!(value_of::<u64>(&matches, "multiple"), None);
|
||||
|
||||
let pubkey = solana_sdk::pubkey::new_rand();
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &pubkey.to_string()]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", &pubkey.to_string()]);
|
||||
assert_eq!(value_of(&matches, "single"), Some(pubkey));
|
||||
}
|
||||
|
||||
|
@ -268,19 +261,14 @@ mod tests {
|
|||
let outfile = tmp_file_path("test_keypair_of.json", &keypair.pubkey());
|
||||
let _ = write_keypair_file(&keypair, &outfile).unwrap();
|
||||
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &outfile]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", &outfile]);
|
||||
assert_eq!(
|
||||
keypair_of(&matches, "single").unwrap().pubkey(),
|
||||
keypair.pubkey()
|
||||
);
|
||||
assert!(keypair_of(&matches, "multiple").is_none());
|
||||
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
assert!(keypair_of(&matches, "single").is_none());
|
||||
|
||||
fs::remove_file(&outfile).unwrap();
|
||||
|
@ -292,22 +280,15 @@ mod tests {
|
|||
let outfile = tmp_file_path("test_pubkey_of.json", &keypair.pubkey());
|
||||
let _ = write_keypair_file(&keypair, &outfile).unwrap();
|
||||
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &outfile]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", &outfile]);
|
||||
assert_eq!(pubkey_of(&matches, "single"), Some(keypair.pubkey()));
|
||||
assert_eq!(pubkey_of(&matches, "multiple"), None);
|
||||
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", &keypair.pubkey().to_string()]);
|
||||
app().get_matches_from(vec!["test", "--single", &keypair.pubkey().to_string()]);
|
||||
assert_eq!(pubkey_of(&matches, "single"), Some(keypair.pubkey()));
|
||||
|
||||
let matches =
|
||||
app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "random_keypair_file.json"]);
|
||||
assert_eq!(pubkey_of(&matches, "single"), None);
|
||||
|
||||
fs::remove_file(&outfile).unwrap();
|
||||
|
@ -319,7 +300,7 @@ mod tests {
|
|||
let outfile = tmp_file_path("test_pubkeys_of.json", &keypair.pubkey());
|
||||
let _ = write_keypair_file(&keypair, &outfile).unwrap();
|
||||
|
||||
let matches = app().clone().get_matches_from(vec![
|
||||
let matches = app().get_matches_from(vec![
|
||||
"test",
|
||||
"--multiple",
|
||||
&keypair.pubkey().to_string(),
|
||||
|
@ -341,13 +322,8 @@ mod tests {
|
|||
let sig2 = Keypair::new().sign_message(&[1u8]);
|
||||
let signer1 = format!("{key1}={sig1}");
|
||||
let signer2 = format!("{key2}={sig2}");
|
||||
let matches = app().clone().get_matches_from(vec![
|
||||
"test",
|
||||
"--multiple",
|
||||
&signer1,
|
||||
"--multiple",
|
||||
&signer2,
|
||||
]);
|
||||
let matches =
|
||||
app().get_matches_from(vec!["test", "--multiple", &signer1, "--multiple", &signer2]);
|
||||
assert_eq!(
|
||||
pubkeys_sigs_of(&matches, "multiple"),
|
||||
Some(vec![(key1, sig1), (key2, sig2)])
|
||||
|
@ -356,19 +332,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_lamports_of_sol() {
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "50"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "50"]);
|
||||
assert_eq!(lamports_of_sol(&matches, "single"), Some(50_000_000_000));
|
||||
assert_eq!(lamports_of_sol(&matches, "multiple"), None);
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "1.5"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "1.5"]);
|
||||
assert_eq!(lamports_of_sol(&matches, "single"), Some(1_500_000_000));
|
||||
assert_eq!(lamports_of_sol(&matches, "multiple"), None);
|
||||
let matches = app()
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "--single", "0.03"]);
|
||||
let matches = app().get_matches_from(vec!["test", "--single", "0.03"]);
|
||||
assert_eq!(lamports_of_sol(&matches, "single"), Some(30_000_000));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1788,7 +1788,7 @@ fn initialize_rpc_transaction_history_services(
|
|||
transaction_status_receiver,
|
||||
max_complete_transaction_status_slot.clone(),
|
||||
enable_rpc_transaction_history,
|
||||
transaction_notifier.clone(),
|
||||
transaction_notifier,
|
||||
blockstore.clone(),
|
||||
enable_extended_tx_metadata_storage,
|
||||
exit,
|
||||
|
|
|
@ -7339,7 +7339,7 @@ mod tests {
|
|||
&stake_account,
|
||||
&authorized_staker,
|
||||
&new_vote_address,
|
||||
&uninitialized_stake_account.clone(), // <-- Invalid vote account
|
||||
&uninitialized_stake_account, // <-- Invalid vote account
|
||||
&uninitialized_stake_address,
|
||||
&uninitialized_stake_account,
|
||||
Err(InstructionError::IncorrectProgramId),
|
||||
|
@ -7350,7 +7350,7 @@ mod tests {
|
|||
//
|
||||
let _ = process_instruction_redelegate(
|
||||
&stake_address,
|
||||
&uninitialized_stake_account.clone(), // <-- Uninitialized stake account
|
||||
&uninitialized_stake_account, // <-- Uninitialized stake account
|
||||
&authorized_staker,
|
||||
&new_vote_address,
|
||||
&new_vote_account,
|
||||
|
|
|
@ -327,9 +327,7 @@ mod tests {
|
|||
// are broken, so unset the requires() to recreate that condition
|
||||
.arg(sign_only_arg().requires(""));
|
||||
|
||||
let matches = test_commands
|
||||
.clone()
|
||||
.get_matches_from(vec!["blockhash_query_test", "--sign-only"]);
|
||||
let matches = test_commands.get_matches_from(vec!["blockhash_query_test", "--sign-only"]);
|
||||
BlockhashQuery::new_from_matches(&matches);
|
||||
}
|
||||
|
||||
|
@ -344,7 +342,7 @@ mod tests {
|
|||
let nonce_pubkey = Pubkey::new(&[1u8; 32]);
|
||||
let nonce_string = nonce_pubkey.to_string();
|
||||
|
||||
let matches = test_commands.clone().get_matches_from(vec![
|
||||
let matches = test_commands.get_matches_from(vec![
|
||||
"blockhash_query_test",
|
||||
"--sign-only",
|
||||
"--nonce",
|
||||
|
|
|
@ -259,9 +259,7 @@ mod tests {
|
|||
// are broken, so unset the requires() to recreate that condition
|
||||
.arg(sign_only_arg().requires(""));
|
||||
|
||||
let matches = test_commands
|
||||
.clone()
|
||||
.get_matches_from(vec!["blockhash_query_test", "--sign-only"]);
|
||||
let matches = test_commands.get_matches_from(vec!["blockhash_query_test", "--sign-only"]);
|
||||
BlockhashQuery::new_from_matches(&matches);
|
||||
}
|
||||
|
||||
|
@ -276,7 +274,7 @@ mod tests {
|
|||
let nonce_pubkey = Pubkey::new(&[1u8; 32]);
|
||||
let nonce_string = nonce_pubkey.to_string();
|
||||
|
||||
let matches = test_commands.clone().get_matches_from(vec![
|
||||
let matches = test_commands.get_matches_from(vec![
|
||||
"blockhash_query_test",
|
||||
"--sign-only",
|
||||
"--nonce",
|
||||
|
|
|
@ -3475,7 +3475,7 @@ mod tests {
|
|||
Some((&nonce, true)),
|
||||
&DurableNonce::default(),
|
||||
1,
|
||||
&post_fee_payer_account.clone(),
|
||||
&post_fee_payer_account,
|
||||
));
|
||||
|
||||
assert!(run_prepare_if_nonce_account_test(
|
||||
|
@ -3486,7 +3486,7 @@ mod tests {
|
|||
Some((&nonce, true)),
|
||||
&DurableNonce::default(),
|
||||
1,
|
||||
&post_fee_payer_account.clone(),
|
||||
&post_fee_payer_account,
|
||||
));
|
||||
|
||||
assert!(run_prepare_if_nonce_account_test(
|
||||
|
@ -3500,7 +3500,7 @@ mod tests {
|
|||
None,
|
||||
&DurableNonce::default(),
|
||||
1,
|
||||
&post_fee_payer_account.clone(),
|
||||
&post_fee_payer_account,
|
||||
));
|
||||
|
||||
assert!(run_prepare_if_nonce_account_test(
|
||||
|
|
|
@ -278,7 +278,6 @@ impl RangeProof {
|
|||
|
||||
let gs = s.iter().map(|s_i| minus_z - a * s_i);
|
||||
let hs = s_inv
|
||||
.clone()
|
||||
.zip(util::exp_iter(y.invert()))
|
||||
.zip(concat_z_and_2.iter())
|
||||
.map(|((s_i_inv, exp_y_inv), z_and_2)| z + exp_y_inv * (zz * z_and_2 - b * s_i_inv));
|
||||
|
|
Loading…
Reference in New Issue