Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
patches errors from clippy::uninlined_format_args
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri committed Dec 6, 2022
1 parent 9433c06 commit 9524c9d
Show file tree
Hide file tree
Showing 214 changed files with 1,307 additions and 1,863 deletions.
2 changes: 1 addition & 1 deletion account-decoder/src/parse_account_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn parse_account_data(
ParsableAccount::Vote => serde_json::to_value(parse_vote(data)?)?,
};
Ok(ParsedAccount {
program: format!("{:?}", program_name).to_kebab_case(),
program: format!("{program_name:?}").to_kebab_case(),
parsed: parsed_json,
space: data.len() as u64,
})
Expand Down
10 changes: 5 additions & 5 deletions accounts-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ fn main() {
let num_accounts = value_t!(matches, "num_accounts", usize).unwrap_or(10_000);
let iterations = value_t!(matches, "iterations", usize).unwrap_or(20);
let clean = matches.is_present("clean");
println!("clean: {:?}", clean);
println!("clean: {clean:?}");

let path = PathBuf::from(env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_owned()))
.join("accounts-bench");
println!("cleaning file system: {:?}", path);
println!("cleaning file system: {path:?}");
if fs::remove_dir_all(path.clone()).is_err() {
println!("Warning: Couldn't remove {:?}", path);
println!("Warning: Couldn't remove {path:?}");
}
let accounts = Accounts::new_with_config_for_benches(
vec![path],
Expand All @@ -75,7 +75,7 @@ fn main() {
false,
AccountShrinkThreshold::default(),
);
println!("Creating {} accounts", num_accounts);
println!("Creating {num_accounts} accounts");
let mut create_time = Measure::start("create accounts");
let pubkeys: Vec<_> = (0..num_slots)
.into_par_iter()
Expand Down Expand Up @@ -112,7 +112,7 @@ fn main() {
let mut time = Measure::start("clean");
accounts.accounts_db.clean_accounts_for_tests();
time.stop();
println!("{}", time);
println!("{time}");
for slot in 0..num_slots {
update_accounts_bench(&accounts, &pubkeys, ((x + 1) * num_slots + slot) as u64);
accounts.add_root((x * num_slots + slot) as u64);
Expand Down
18 changes: 8 additions & 10 deletions accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,20 @@ pub fn airdrop_lamports(
}
if tries >= 5 {
panic!(
"Error requesting airdrop: to addr: {:?} amount: {} {:?}",
faucet_addr, airdrop_amount, result
"Error requesting airdrop: to addr: {faucet_addr:?} amount: {airdrop_amount} {result:?}"
)
}
}
}
Err(err) => {
panic!(
"Error requesting airdrop: {:?} to addr: {:?} amount: {}",
err, faucet_addr, airdrop_amount
"Error requesting airdrop: {err:?} to addr: {faucet_addr:?} amount: {airdrop_amount}"
);
}
};

let current_balance = client.get_balance(&id.pubkey()).unwrap_or_else(|e| {
panic!("airdrop error {}", e);
panic!("airdrop error {e}");
});
info!("current balance {}...", current_balance);

Expand Down Expand Up @@ -575,14 +573,14 @@ fn main() {
let mut entrypoint_addr = SocketAddr::from(([127, 0, 0, 1], port));
if let Some(addr) = matches.value_of("entrypoint") {
entrypoint_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
eprintln!("failed to parse entrypoint address: {}", e);
eprintln!("failed to parse entrypoint address: {e}");
exit(1)
});
}
let mut faucet_addr = SocketAddr::from(([127, 0, 0, 1], FAUCET_PORT));
if let Some(addr) = matches.value_of("faucet_addr") {
faucet_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
eprintln!("failed to parse entrypoint address: {}", e);
eprintln!("failed to parse entrypoint address: {e}");
exit(1)
});
}
Expand All @@ -594,7 +592,7 @@ fn main() {
let iterations = value_t!(matches, "iterations", usize).unwrap_or(10);
let num_instructions = value_t!(matches, "num_instructions", usize).unwrap_or(1);
if num_instructions == 0 || num_instructions > 500 {
eprintln!("bad num_instructions: {}", num_instructions);
eprintln!("bad num_instructions: {num_instructions}");
exit(1);
}

Expand All @@ -604,7 +602,7 @@ fn main() {
.iter()
.map(|keypair_string| {
read_keypair_file(keypair_string)
.unwrap_or_else(|_| panic!("bad keypair {:?}", keypair_string))
.unwrap_or_else(|_| panic!("bad keypair {keypair_string:?}"))
})
.collect();
let mut payer_keypair_refs: Vec<&Keypair> = vec![];
Expand All @@ -626,7 +624,7 @@ fn main() {
SocketAddrSpace::Unspecified,
)
.unwrap_or_else(|err| {
eprintln!("Failed to discover {} node: {:?}", entrypoint_addr, err);
eprintln!("Failed to discover {entrypoint_addr} node: {err:?}");
exit(1);
});

Expand Down
4 changes: 2 additions & 2 deletions banking-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ fn main() {
.iter()
.for_each(|tx| {
let res = bank.process_transaction(tx);
assert!(res.is_ok(), "sanity test transactions error: {:?}", res);
assert!(res.is_ok(), "sanity test transactions error: {res:?}");
});
});
bank.clear_signatures();
Expand All @@ -395,7 +395,7 @@ fn main() {
let res =
bank.process_transactions(packets_for_single_iteration.transactions.iter());
for r in res {
assert!(r.is_ok(), "sanity parallel execution error: {:?}", r);
assert!(r.is_ok(), "sanity parallel execution error: {r:?}");
}
bank.clear_signatures();
});
Expand Down
4 changes: 2 additions & 2 deletions bench-tps/src/bench_tps_client/bank_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl BenchTpsClient for BankClient {
.map_err(|err| err.into())
.and_then(|account| {
account.ok_or_else(|| {
BenchTpsError::Custom(format!("AccountNotFound: pubkey={}", pubkey))
BenchTpsError::Custom(format!("AccountNotFound: pubkey={pubkey}"))
})
})
}
Expand All @@ -103,7 +103,7 @@ impl BenchTpsClient for BankClient {
.map_err(|err| err.into())
.and_then(|account| {
account.ok_or_else(|| {
BenchTpsError::Custom(format!("AccountNotFound: pubkey={}", pubkey))
BenchTpsError::Custom(format!("AccountNotFound: pubkey={pubkey}"))
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/bench_tps_client/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl BenchTpsClient for RpcClient {
.map_err(|err| err.into())
.and_then(|account| {
account.ok_or_else(|| {
BenchTpsError::Custom(format!("AccountNotFound: pubkey={}", pubkey))
BenchTpsError::Custom(format!("AccountNotFound: pubkey={pubkey}"))
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/bench_tps_client/thin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl BenchTpsClient for ThinClient {
.map_err(|err| err.into())
.and_then(|account| {
account.ok_or_else(|| {
BenchTpsError::Custom(format!("AccountNotFound: pubkey={}", pubkey))
BenchTpsError::Custom(format!("AccountNotFound: pubkey={pubkey}"))
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/bench_tps_client/tpu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl BenchTpsClient for TpuClient {
.map_err(|err| err.into())
.and_then(|account| {
account.ok_or_else(|| {
BenchTpsError::Custom(format!("AccountNotFound: pubkey={}", pubkey))
BenchTpsError::Custom(format!("AccountNotFound: pubkey={pubkey}"))
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ pub fn extract_args(matches: &ArgMatches) -> Config {

if let Some(addr) = matches.value_of("entrypoint") {
args.entrypoint_addr = solana_net_utils::parse_host_port(addr).unwrap_or_else(|e| {
eprintln!("failed to parse entrypoint address: {}", e);
eprintln!("failed to parse entrypoint address: {e}");
exit(1)
});
}
Expand Down
4 changes: 2 additions & 2 deletions bench-tps/src/keypairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ where
last_balance,
)
.unwrap_or_else(|e| {
eprintln!("Error could not fund keys: {:?}", e);
eprintln!("Error could not fund keys: {e:?}");
exit(1);
});
keypairs
} else {
generate_and_fund_keypairs(client, id, keypair_count, num_lamports_per_account)
.unwrap_or_else(|e| {
eprintln!("Error could not fund keys: {:?}", e);
eprintln!("Error could not fund keys: {e:?}");
exit(1);
})
}
Expand Down
13 changes: 6 additions & 7 deletions bench-tps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ fn create_client(
let nodes =
discover_cluster(entrypoint_addr, num_nodes, SocketAddrSpace::Unspecified)
.unwrap_or_else(|err| {
eprintln!("Failed to discover {} nodes: {:?}", num_nodes, err);
eprintln!("Failed to discover {num_nodes} nodes: {err:?}");
exit(1);
});
if multi_client {
let (client, num_clients) =
get_multi_client(&nodes, &SocketAddrSpace::Unspecified, connection_cache);
if nodes.len() < num_clients {
eprintln!(
"Error: Insufficient nodes discovered. Expecting {} or more",
num_nodes
"Error: Insufficient nodes discovered. Expecting {num_nodes} or more"
);
exit(1);
}
Expand All @@ -90,7 +89,7 @@ fn create_client(
}
}
Arc::new(target_client.unwrap_or_else(|| {
eprintln!("Target node {} not found", target_node);
eprintln!("Target node {target_node} not found");
exit(1);
}))
} else {
Expand Down Expand Up @@ -120,7 +119,7 @@ fn create_client(
Arc::new(connection_cache),
)
.unwrap_or_else(|err| {
eprintln!("Could not create TpuClient {:?}", err);
eprintln!("Could not create TpuClient {err:?}");
exit(1);
}),
)
Expand Down Expand Up @@ -198,14 +197,14 @@ fn main() {
let rpc_tpu_sockets: Option<(SocketAddr, SocketAddr)> =
if let Ok(rpc_addr) = value_t!(matches, "rpc_addr", String) {
let rpc = rpc_addr.parse().unwrap_or_else(|e| {
eprintln!("RPC address should parse as socketaddr {:?}", e);
eprintln!("RPC address should parse as socketaddr {e:?}");
exit(1);
});
let tpu = value_t!(matches, "tpu_addr", String)
.unwrap()
.parse()
.unwrap_or_else(|e| {
eprintln!("TPU address should parse to a socket: {:?}", e);
eprintln!("TPU address should parse to a socket: {e:?}");
exit(1);
});
Some((rpc, tpu))
Expand Down
12 changes: 6 additions & 6 deletions bloom/src/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ mod test {
let mut b: Bloom<Hash> = Bloom::new(3, vec![100]);
b.add(&Hash::default());
assert_eq!(
format!("{:?}", b),
format!("{b:?}"),
"Bloom { keys.len: 1 bits.len: 3 num_set: 1 bits: 001 }"
);

let mut b: Bloom<Hash> = Bloom::new(1000, vec![100]);
b.add(&Hash::default());
b.add(&hash(&[1, 2]));
assert_eq!(
format!("{:?}", b),
format!("{b:?}"),
"Bloom { keys.len: 1 bits.len: 1000 num_set: 2 bits: 0000000000.. }"
);
}
Expand Down Expand Up @@ -345,7 +345,7 @@ mod test {
.take(10_000)
.filter(|hash_value| bloom.contains(hash_value))
.count();
assert!(false_positive < 2_000, "false_positive: {}", false_positive);
assert!(false_positive < 2_000, "false_positive: {false_positive}");
}

#[test]
Expand All @@ -360,7 +360,7 @@ mod test {
bloom.add(hash_value);
}
let num_bits_set = bloom.num_bits_set;
assert!(num_bits_set > 2000, "# bits set: {}", num_bits_set);
assert!(num_bits_set > 2000, "# bits set: {num_bits_set}");
// Round-trip with no inserts.
let bloom: AtomicBloom<_> = bloom.into();
assert_eq!(bloom.num_bits, 9731);
Expand Down Expand Up @@ -408,7 +408,7 @@ mod test {
.take(10_000)
.filter(|hash_value| bloom.contains(hash_value))
.count();
assert!(false_positive < 2000, "false_positive: {}", false_positive);
assert!(false_positive < 2000, "false_positive: {false_positive}");
let bloom: Bloom<_> = bloom.into();
assert_eq!(bloom.bits.len(), 9731);
assert!(bloom.num_bits_set > num_bits_set);
Expand All @@ -427,7 +427,7 @@ mod test {
.take(10_000)
.filter(|hash_value| bloom.contains(hash_value))
.count();
assert!(false_positive < 2000, "false_positive: {}", false_positive);
assert!(false_positive < 2000, "false_positive: {false_positive}");
// Assert that the bits vector precisely match if no atomic ops were
// used.
let bits = bloom.bits;
Expand Down
2 changes: 1 addition & 1 deletion bucket_map/src/bucket_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ mod tests {
map.insert(&k, (&v, rc))
} else {
map.update(&k, |current| {
assert_eq!(current, v_old.map(|(v, rc)| (&v[..], *rc)), "{}", k);
assert_eq!(current, v_old.map(|(v, rc)| (&v[..], *rc)), "{k}");
Some((v.clone(), rc))
})
}
Expand Down
6 changes: 3 additions & 3 deletions clap-utils/src/input_parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ mod tests {
use std::env;
let out_dir = env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string());

format!("{}/tmp/{}-{}", out_dir, name, pubkey)
format!("{out_dir}/tmp/{name}-{pubkey}")
}

#[test]
Expand Down Expand Up @@ -338,8 +338,8 @@ mod tests {
let key2 = solana_sdk::pubkey::new_rand();
let sig1 = Keypair::new().sign_message(&[0u8]);
let sig2 = Keypair::new().sign_message(&[1u8]);
let signer1 = format!("{}={}", key1, sig1);
let signer2 = format!("{}={}", key2, sig2);
let signer1 = format!("{key1}={sig1}");
let signer2 = format!("{key2}={sig2}");
let matches = app().clone().get_matches_from(vec![
"test",
"--multiple",
Expand Down
Loading

0 comments on commit 9524c9d

Please sign in to comment.