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(clippy): Place identifiers in format string #663

Merged
merged 2 commits into from
Jan 2, 2023
Merged
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
2 changes: 1 addition & 1 deletion iroh-api/benches/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn add_benchmark(c: &mut Criterion) {
{
let value = vec![8u8; *file_size];
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join(format!("{}.raw", file_size));
let path = dir.path().join(format!("{file_size}.raw"));
std::fs::write(&path, value).unwrap();

group.throughput(criterion::Throughput::Bytes(*file_size as u64));
Expand Down
4 changes: 2 additions & 2 deletions iroh-bitswap/src/peer_task_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ mod tests {
// add blocks for all letters
for letter in shuffled_alphabet {
let i = alphabet.iter().position(|c| *c == letter).unwrap();
println!("{} - {}", letter, i);
println!("{letter} - {i}");
ptq.push_task(
partner,
Task {
Expand Down Expand Up @@ -633,7 +633,7 @@ mod tests {
let mut targets = Vec::new();
for i in 0..n {
let (peer, tasks, _) = ptq.pop_tasks(1).await.unwrap();
assert_eq!(tasks.len(), 1, "task {} did not match: {:?}", i, tasks);
assert_eq!(tasks.len(), 1, "task {i} did not match: {tasks:?}");
targets.push(peer);
}
assert_eq_unordered(expected, targets);
Expand Down
2 changes: 1 addition & 1 deletion iroh-one/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async fn main() -> Result<()> {
};

config.metrics = metrics::metrics_config_with_compile_time_info(config.metrics);
println!("{:#?}", config);
println!("{config:#?}");

let metrics_config = config.metrics.clone();

Expand Down
2 changes: 1 addition & 1 deletion iroh-p2p/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ fn path_is_private_key<P: AsRef<Path>>(path: P) -> bool {
fn print_algorithm(alg: ssh_key::Algorithm) -> &'static str {
match alg {
ssh_key::Algorithm::Ed25519 => "ed25519",
_ => panic!("unusupported algorithm {}", alg),
_ => panic!("unusupported algorithm {alg}"),
}
}

Expand Down
6 changes: 3 additions & 3 deletions iroh-p2p/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<KeyStorage: Storage> Node<KeyStorage> {

for addr in &libp2p_config.listening_multiaddrs {
Swarm::listen_on(&mut swarm, addr.clone())?;
println!("{}", addr);
println!("{addr}");
}

Ok(Node {
Expand Down Expand Up @@ -1310,12 +1310,12 @@ mod tests {
assert!(!new_providers.is_empty());

for p in &new_providers {
println!("{}", p);
println!("{p}");
providers.push(*p);
}
}

println!("{:?}", providers);
println!("{providers:?}");
assert!(!providers.is_empty());
assert!(
providers.len() >= DEFAULT_PROVIDER_LIMIT,
Expand Down
44 changes: 22 additions & 22 deletions iroh-resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ mod tests {
];

for test in roundtrip_tests {
println!("{}", test);
println!("{test}");
let p: Path = test.parse().unwrap();
assert_eq!(p.to_string(), test);
}
Expand All @@ -1188,7 +1188,7 @@ mod tests {
"/ipfs/bafkreigh2akiscaildcqabsyg3dfr6chu3fgpregiymsck7e7aqa4s52zy",
)];
for (test_in, test_out) in valid_tests {
println!("{}", test_in);
println!("{test_in}");
let p: Path = test_in.parse().unwrap();
assert_eq!(p.to_string(), test_out);
}
Expand All @@ -1200,7 +1200,7 @@ mod tests {
"/ipfs/ipfs.io",
];
for test in invalid_tests {
println!("{}", test);
println!("{test}");
assert!(test.parse::<Path>().is_err());
}
}
Expand Down Expand Up @@ -1452,7 +1452,7 @@ mod tests {
"hello\n"
);
} else {
panic!("invalid result: {:?}", ipld_hello_txt);
panic!("invalid result: {ipld_hello_txt:?}");
}
}

Expand Down Expand Up @@ -1488,7 +1488,7 @@ mod tests {
"hello\n"
);
} else {
panic!("invalid result: {:?}", ipld_hello_txt);
panic!("invalid result: {ipld_hello_txt:?}");
}
}

Expand Down Expand Up @@ -1551,7 +1551,7 @@ mod tests {
"world\n"
);
} else {
panic!("invalid result: {:?}", ipld_bar_txt);
panic!("invalid result: {ipld_bar_txt:?}");
}
}
}
Expand Down Expand Up @@ -1609,7 +1609,7 @@ mod tests {
let cr = seek_and_clip(ctx.clone(), &node, resolver.clone(), 1..3).await;
assert_eq!(read_to_string(cr).await, "el");
} else {
panic!("invalid result: {:?}", ipld_hello_txt);
panic!("invalid result: {ipld_hello_txt:?}");
}
}

Expand Down Expand Up @@ -1676,7 +1676,7 @@ mod tests {
assert!(content.starts_with("2.0</a>"));
assert!(content.ends_with("the Apac"));
} else {
panic!("invalid result: {:?}", ipld_readme);
panic!("invalid result: {ipld_readme:?}");
}
}
}
Expand Down Expand Up @@ -1845,7 +1845,7 @@ mod tests {
"hello\n"
);
} else {
panic!("invalid result: {:?}", ipld_hello_txt);
panic!("invalid result: {ipld_hello_txt:?}");
}
}

Expand Down Expand Up @@ -1888,7 +1888,7 @@ mod tests {
"world\n"
);
} else {
panic!("invalid result: {:?}", ipld_bar_txt);
panic!("invalid result: {ipld_bar_txt:?}");
}
}
}
Expand Down Expand Up @@ -1952,12 +1952,12 @@ mod tests {
.unwrap(),
)
.await;
print!("{}", content);
print!("{content}");
assert_eq!(content.len(), 426);
assert!(content.starts_with("# iroh"));
assert!(content.ends_with("</sub>\n\n"));
} else {
panic!("invalid result: {:?}", ipld_readme);
panic!("invalid result: {ipld_readme:?}");
}
}
}
Expand Down Expand Up @@ -2123,7 +2123,7 @@ mod tests {
"hello\n"
);
} else {
panic!("invalid result: {:?}", ipld_hello_txt);
panic!("invalid result: {ipld_hello_txt:?}");
}
}

Expand Down Expand Up @@ -2180,7 +2180,7 @@ mod tests {
"world\n"
);
} else {
panic!("invalid result: {:?}", ipld_bar_txt);
panic!("invalid result: {ipld_bar_txt:?}");
}
}

Expand Down Expand Up @@ -2218,7 +2218,7 @@ mod tests {
"./bar.txt"
);
} else {
panic!("invalid result: {:?}", ipld_bar_txt);
panic!("invalid result: {ipld_bar_txt:?}");
}
}

Expand Down Expand Up @@ -2256,7 +2256,7 @@ mod tests {
"../../hello.txt"
);
} else {
panic!("invalid result: {:?}", ipld_bar_txt);
panic!("invalid result: {ipld_bar_txt:?}");
}
}

Expand Down Expand Up @@ -2294,7 +2294,7 @@ mod tests {
"../hello.txt"
);
} else {
panic!("invalid result: {:?}", ipld_bar_txt);
panic!("invalid result: {ipld_bar_txt:?}");
}

let path = format!("/ipfs/{my_symlink_cid_str}");
Expand Down Expand Up @@ -2322,7 +2322,7 @@ mod tests {
"../hello.txt"
);
} else {
panic!("invalid result: {:?}", ipld_bar_txt);
panic!("invalid result: {ipld_bar_txt:?}");
}
}
}
Expand Down Expand Up @@ -2388,7 +2388,7 @@ mod tests {
"world\n",
);
} else {
panic!("invalid result: {:?}", ipld_txt);
panic!("invalid result: {ipld_txt:?}");
}
}
// read the directory listing
Expand Down Expand Up @@ -2429,7 +2429,7 @@ mod tests {

for i in 1..=10000 {
tokio::task::yield_now().await; // yield so sessions can be closed
let path = format!("/ipfs/{root_cid_str}/{}.txt", i);
let path = format!("/ipfs/{root_cid_str}/{i}.txt");
let ipld_txt = resolver.resolve(path.parse().unwrap()).await.unwrap();

assert!(ipld_txt
Expand All @@ -2456,10 +2456,10 @@ mod tests {
.unwrap()
)
.await,
format!("{}\n", i),
format!("{i}\n"),
);
} else {
panic!("invalid result: {:?}", ipld_txt);
panic!("invalid result: {ipld_txt:?}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions iroh-resolver/tests/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async fn symlink_roundtrip_test() -> Result<()> {
let mut reader = out.pretty(resolver, OutMetrics::default(), None)?;
let mut t = String::new();
reader.read_to_string(&mut t).await?;
println!("{}", t);
println!("{t}");
assert_eq!(target, t);
Ok(())
}
Expand Down Expand Up @@ -248,7 +248,7 @@ fn test_hamt_roundtrip_3() {
async fn test_hamt_roundtrip_large() {
let mut dir = TestDir::new();
for i in 0..10000 {
dir.insert(format!("file_{}", i), TestDirEntry::File(Bytes::new()));
dir.insert(format!("file_{i}"), TestDirEntry::File(Bytes::new()));
}
assert!(dir_roundtrip_test(dir, true).await.unwrap());
}
Expand Down
4 changes: 2 additions & 2 deletions iroh-resolver/tests/unixfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async fn test_dagger_testdata() -> Result<()> {

for source in sources {
for param in &params {
println!("== {:?} ==", source);
println!("== {source:?} ==");
println!("Degree: {}", param.degree);
println!("Chunker: {}", param.chunker);

Expand All @@ -81,7 +81,7 @@ async fn test_dagger_testdata() -> Result<()> {
let out = resolver.resolve(Path::from_cid(root)).await?;
let t = read_to_vec(out.pretty(resolver, OutMetrics::default(), None)?).await?;

println!("Root: {}", root);
println!("Root: {root}");
println!("Len: {}", data.len());
println!("Elapsed: {}s", start.elapsed().as_secs_f32());

Expand Down
6 changes: 3 additions & 3 deletions iroh-share/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async fn main() -> Result<()> {
let ticket = sender_transfer.ticket();
let ticket_bytes = ticket.as_bytes();
let ticket_str = multibase::encode(multibase::Base::Base64, &ticket_bytes);
println!("Ticket:\n{}\n", ticket_str);
println!("Ticket:\n{ticket_str}\n");
sender_transfer.done().await?;
}
Commands::Receive { ticket, out } => {
Expand All @@ -102,10 +102,10 @@ async fn main() -> Result<()> {
while let Some(ev) = progress.next().await {
match ev {
Ok(ProgressEvent::Piece { index, total }) => {
println!("transferred: {}/{}", index, total);
println!("transferred: {index}/{total}");
}
Err(e) => {
eprintln!("transfer failed: {}", e);
eprintln!("transfer failed: {e}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion iroh-share/src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Sender {
gossip_task,
} = self;

let t = Sha256Topic::new(format!("iroh-share-{}", id));
let t = Sha256Topic::new(format!("iroh-share-{id}"));
let root_dir = dir_builder.build().await?;

let (done_sender, done_receiver) = oneshot();
Expand Down
4 changes: 2 additions & 2 deletions iroh-store/benches/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn put_benchmark(c: &mut Criterion) {
group.bench_with_input(
BenchmarkId::new(
"(transport, value_size)",
format!("({:?}, {})", transport, value_size),
format!("({transport:?}, {value_size})"),
),
&(key, value),
|b, (key, value)| {
Expand Down Expand Up @@ -101,7 +101,7 @@ pub fn get_benchmark(c: &mut Criterion) {
group.bench_with_input(
BenchmarkId::new(
"(transport, value_size)",
format!("({:?}, {})", transport, value_size),
format!("({transport:?}, {value_size})"),
),
&(),
|b, _| {
Expand Down
4 changes: 2 additions & 2 deletions iroh-unixfs/src/balanced_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ mod tests {

async fn build_expect(num_chunks: usize, degree: usize) -> Vec<Block> {
let tree = build_expect_tree(num_chunks, degree).await;
println!("{:?}", tree);
println!("{tree:?}");
build_expect_vec_from_tree(tree, num_chunks, degree).await
}

Expand Down Expand Up @@ -414,7 +414,7 @@ mod tests {
let node = node.expect("unexpected error in balanced tree stream");
let (got_cid, got_bytes, _) = node.into_parts();
let len = got_bytes.len() as u64;
println!("node index {}", i);
println!("node index {i}");
assert_eq!(expect_cid, got_cid);
assert_eq!(expect_bytes, got_bytes);
i += 1;
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,6 @@ pub fn get_fixture_api() -> Api {
let fixture_name = env::var("IROH_CTL_FIXTURE").expect("IROH_CTL_FIXTURE must be set");
let fixture = registry
.get(&fixture_name)
.unwrap_or_else(|| panic!("unknown fixture: {}", fixture_name));
.unwrap_or_else(|| panic!("unknown fixture: {fixture_name}"));
fixture()
}
4 changes: 2 additions & 2 deletions iroh/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn main() -> Result<()> {
match r {
Ok(_) => Ok(()),
Err(e) => {
eprintln!("Error: {:?}", e);
eprintln!("Error: {e:?}");
std::process::exit(1);
}
}
Expand All @@ -42,7 +42,7 @@ fn transform_error(r: Result<()>) -> Result<()> {
return Err(anyhow!(
"Connection refused. This command requires a running {} service.\n{}",
service,
format!("hint: try 'iroh start {}'", service).yellow(),
format!("hint: try 'iroh start {service}'").yellow(),
));
}
Err(e)
Expand Down
Loading