Skip to content

Commit b7a4dd2

Browse files
authored
chore(clippy): Place identifiers in format string (#663)
Newer clippy wants the identifiers in the format string when possible. Boring change but why not.
1 parent 7a11aa8 commit b7a4dd2

File tree

18 files changed

+78
-80
lines changed

18 files changed

+78
-80
lines changed

iroh-api/benches/add.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn add_benchmark(c: &mut Criterion) {
2424
{
2525
let value = vec![8u8; *file_size];
2626
let dir = tempfile::tempdir().unwrap();
27-
let path = dir.path().join(format!("{}.raw", file_size));
27+
let path = dir.path().join(format!("{file_size}.raw"));
2828
std::fs::write(&path, value).unwrap();
2929

3030
group.throughput(criterion::Throughput::Bytes(*file_size as u64));

iroh-bitswap/src/peer_task_queue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ mod tests {
289289
// add blocks for all letters
290290
for letter in shuffled_alphabet {
291291
let i = alphabet.iter().position(|c| *c == letter).unwrap();
292-
println!("{} - {}", letter, i);
292+
println!("{letter} - {i}");
293293
ptq.push_task(
294294
partner,
295295
Task {
@@ -633,7 +633,7 @@ mod tests {
633633
let mut targets = Vec::new();
634634
for i in 0..n {
635635
let (peer, tasks, _) = ptq.pop_tasks(1).await.unwrap();
636-
assert_eq!(tasks.len(), 1, "task {} did not match: {:?}", i, tasks);
636+
assert_eq!(tasks.len(), 1, "task {i} did not match: {tasks:?}");
637637
targets.push(peer);
638638
}
639639
assert_eq_unordered(expected, targets);

iroh-one/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async fn main() -> Result<()> {
6262
};
6363

6464
config.metrics = metrics::metrics_config_with_compile_time_info(config.metrics);
65-
println!("{:#?}", config);
65+
println!("{config:#?}");
6666

6767
let metrics_config = config.metrics.clone();
6868

iroh-p2p/src/keys.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ fn path_is_private_key<P: AsRef<Path>>(path: P) -> bool {
299299
fn print_algorithm(alg: ssh_key::Algorithm) -> &'static str {
300300
match alg {
301301
ssh_key::Algorithm::Ed25519 => "ed25519",
302-
_ => panic!("unusupported algorithm {}", alg),
302+
_ => panic!("unusupported algorithm {alg}"),
303303
}
304304
}
305305

iroh-p2p/src/node.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<KeyStorage: Storage> Node<KeyStorage> {
155155

156156
for addr in &libp2p_config.listening_multiaddrs {
157157
Swarm::listen_on(&mut swarm, addr.clone())?;
158-
println!("{}", addr);
158+
println!("{addr}");
159159
}
160160

161161
Ok(Node {
@@ -1310,12 +1310,12 @@ mod tests {
13101310
assert!(!new_providers.is_empty());
13111311

13121312
for p in &new_providers {
1313-
println!("{}", p);
1313+
println!("{p}");
13141314
providers.push(*p);
13151315
}
13161316
}
13171317

1318-
println!("{:?}", providers);
1318+
println!("{providers:?}");
13191319
assert!(!providers.is_empty());
13201320
assert!(
13211321
providers.len() >= DEFAULT_PROVIDER_LIMIT,

iroh-resolver/src/resolver.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ mod tests {
11781178
];
11791179

11801180
for test in roundtrip_tests {
1181-
println!("{}", test);
1181+
println!("{test}");
11821182
let p: Path = test.parse().unwrap();
11831183
assert_eq!(p.to_string(), test);
11841184
}
@@ -1188,7 +1188,7 @@ mod tests {
11881188
"/ipfs/bafkreigh2akiscaildcqabsyg3dfr6chu3fgpregiymsck7e7aqa4s52zy",
11891189
)];
11901190
for (test_in, test_out) in valid_tests {
1191-
println!("{}", test_in);
1191+
println!("{test_in}");
11921192
let p: Path = test_in.parse().unwrap();
11931193
assert_eq!(p.to_string(), test_out);
11941194
}
@@ -1200,7 +1200,7 @@ mod tests {
12001200
"/ipfs/ipfs.io",
12011201
];
12021202
for test in invalid_tests {
1203-
println!("{}", test);
1203+
println!("{test}");
12041204
assert!(test.parse::<Path>().is_err());
12051205
}
12061206
}
@@ -1452,7 +1452,7 @@ mod tests {
14521452
"hello\n"
14531453
);
14541454
} else {
1455-
panic!("invalid result: {:?}", ipld_hello_txt);
1455+
panic!("invalid result: {ipld_hello_txt:?}");
14561456
}
14571457
}
14581458

@@ -1488,7 +1488,7 @@ mod tests {
14881488
"hello\n"
14891489
);
14901490
} else {
1491-
panic!("invalid result: {:?}", ipld_hello_txt);
1491+
panic!("invalid result: {ipld_hello_txt:?}");
14921492
}
14931493
}
14941494

@@ -1551,7 +1551,7 @@ mod tests {
15511551
"world\n"
15521552
);
15531553
} else {
1554-
panic!("invalid result: {:?}", ipld_bar_txt);
1554+
panic!("invalid result: {ipld_bar_txt:?}");
15551555
}
15561556
}
15571557
}
@@ -1609,7 +1609,7 @@ mod tests {
16091609
let cr = seek_and_clip(ctx.clone(), &node, resolver.clone(), 1..3).await;
16101610
assert_eq!(read_to_string(cr).await, "el");
16111611
} else {
1612-
panic!("invalid result: {:?}", ipld_hello_txt);
1612+
panic!("invalid result: {ipld_hello_txt:?}");
16131613
}
16141614
}
16151615

@@ -1676,7 +1676,7 @@ mod tests {
16761676
assert!(content.starts_with("2.0</a>"));
16771677
assert!(content.ends_with("the Apac"));
16781678
} else {
1679-
panic!("invalid result: {:?}", ipld_readme);
1679+
panic!("invalid result: {ipld_readme:?}");
16801680
}
16811681
}
16821682
}
@@ -1845,7 +1845,7 @@ mod tests {
18451845
"hello\n"
18461846
);
18471847
} else {
1848-
panic!("invalid result: {:?}", ipld_hello_txt);
1848+
panic!("invalid result: {ipld_hello_txt:?}");
18491849
}
18501850
}
18511851

@@ -1888,7 +1888,7 @@ mod tests {
18881888
"world\n"
18891889
);
18901890
} else {
1891-
panic!("invalid result: {:?}", ipld_bar_txt);
1891+
panic!("invalid result: {ipld_bar_txt:?}");
18921892
}
18931893
}
18941894
}
@@ -1952,12 +1952,12 @@ mod tests {
19521952
.unwrap(),
19531953
)
19541954
.await;
1955-
print!("{}", content);
1955+
print!("{content}");
19561956
assert_eq!(content.len(), 426);
19571957
assert!(content.starts_with("# iroh"));
19581958
assert!(content.ends_with("</sub>\n\n"));
19591959
} else {
1960-
panic!("invalid result: {:?}", ipld_readme);
1960+
panic!("invalid result: {ipld_readme:?}");
19611961
}
19621962
}
19631963
}
@@ -2123,7 +2123,7 @@ mod tests {
21232123
"hello\n"
21242124
);
21252125
} else {
2126-
panic!("invalid result: {:?}", ipld_hello_txt);
2126+
panic!("invalid result: {ipld_hello_txt:?}");
21272127
}
21282128
}
21292129

@@ -2180,7 +2180,7 @@ mod tests {
21802180
"world\n"
21812181
);
21822182
} else {
2183-
panic!("invalid result: {:?}", ipld_bar_txt);
2183+
panic!("invalid result: {ipld_bar_txt:?}");
21842184
}
21852185
}
21862186

@@ -2218,7 +2218,7 @@ mod tests {
22182218
"./bar.txt"
22192219
);
22202220
} else {
2221-
panic!("invalid result: {:?}", ipld_bar_txt);
2221+
panic!("invalid result: {ipld_bar_txt:?}");
22222222
}
22232223
}
22242224

@@ -2256,7 +2256,7 @@ mod tests {
22562256
"../../hello.txt"
22572257
);
22582258
} else {
2259-
panic!("invalid result: {:?}", ipld_bar_txt);
2259+
panic!("invalid result: {ipld_bar_txt:?}");
22602260
}
22612261
}
22622262

@@ -2294,7 +2294,7 @@ mod tests {
22942294
"../hello.txt"
22952295
);
22962296
} else {
2297-
panic!("invalid result: {:?}", ipld_bar_txt);
2297+
panic!("invalid result: {ipld_bar_txt:?}");
22982298
}
22992299

23002300
let path = format!("/ipfs/{my_symlink_cid_str}");
@@ -2322,7 +2322,7 @@ mod tests {
23222322
"../hello.txt"
23232323
);
23242324
} else {
2325-
panic!("invalid result: {:?}", ipld_bar_txt);
2325+
panic!("invalid result: {ipld_bar_txt:?}");
23262326
}
23272327
}
23282328
}
@@ -2388,7 +2388,7 @@ mod tests {
23882388
"world\n",
23892389
);
23902390
} else {
2391-
panic!("invalid result: {:?}", ipld_txt);
2391+
panic!("invalid result: {ipld_txt:?}");
23922392
}
23932393
}
23942394
// read the directory listing
@@ -2429,7 +2429,7 @@ mod tests {
24292429

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

24352435
assert!(ipld_txt
@@ -2456,10 +2456,10 @@ mod tests {
24562456
.unwrap()
24572457
)
24582458
.await,
2459-
format!("{}\n", i),
2459+
format!("{i}\n"),
24602460
);
24612461
} else {
2462-
panic!("invalid result: {:?}", ipld_txt);
2462+
panic!("invalid result: {ipld_txt:?}");
24632463
}
24642464
}
24652465
}

iroh-resolver/tests/roundtrip.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async fn symlink_roundtrip_test() -> Result<()> {
167167
let mut reader = out.pretty(resolver, OutMetrics::default(), None)?;
168168
let mut t = String::new();
169169
reader.read_to_string(&mut t).await?;
170-
println!("{}", t);
170+
println!("{t}");
171171
assert_eq!(target, t);
172172
Ok(())
173173
}
@@ -248,7 +248,7 @@ fn test_hamt_roundtrip_3() {
248248
async fn test_hamt_roundtrip_large() {
249249
let mut dir = TestDir::new();
250250
for i in 0..10000 {
251-
dir.insert(format!("file_{}", i), TestDirEntry::File(Bytes::new()));
251+
dir.insert(format!("file_{i}"), TestDirEntry::File(Bytes::new()));
252252
}
253253
assert!(dir_roundtrip_test(dir, true).await.unwrap());
254254
}

iroh-resolver/tests/unixfs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async fn test_dagger_testdata() -> Result<()> {
5959

6060
for source in sources {
6161
for param in &params {
62-
println!("== {:?} ==", source);
62+
println!("== {source:?} ==");
6363
println!("Degree: {}", param.degree);
6464
println!("Chunker: {}", param.chunker);
6565

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

84-
println!("Root: {}", root);
84+
println!("Root: {root}");
8585
println!("Len: {}", data.len());
8686
println!("Elapsed: {}s", start.elapsed().as_secs_f32());
8787

iroh-share/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async fn main() -> Result<()> {
7575
let ticket = sender_transfer.ticket();
7676
let ticket_bytes = ticket.as_bytes();
7777
let ticket_str = multibase::encode(multibase::Base::Base64, &ticket_bytes);
78-
println!("Ticket:\n{}\n", ticket_str);
78+
println!("Ticket:\n{ticket_str}\n");
7979
sender_transfer.done().await?;
8080
}
8181
Commands::Receive { ticket, out } => {
@@ -102,10 +102,10 @@ async fn main() -> Result<()> {
102102
while let Some(ev) = progress.next().await {
103103
match ev {
104104
Ok(ProgressEvent::Piece { index, total }) => {
105-
println!("transferred: {}/{}", index, total);
105+
println!("transferred: {index}/{total}");
106106
}
107107
Err(e) => {
108-
eprintln!("transfer failed: {}", e);
108+
eprintln!("transfer failed: {e}");
109109
}
110110
}
111111
}

iroh-share/src/sender.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Sender {
5757
gossip_task,
5858
} = self;
5959

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

6363
let (done_sender, done_receiver) = oneshot();

iroh-store/benches/rpc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn put_benchmark(c: &mut Criterion) {
4848
group.bench_with_input(
4949
BenchmarkId::new(
5050
"(transport, value_size)",
51-
format!("({:?}, {})", transport, value_size),
51+
format!("({transport:?}, {value_size})"),
5252
),
5353
&(key, value),
5454
|b, (key, value)| {
@@ -101,7 +101,7 @@ pub fn get_benchmark(c: &mut Criterion) {
101101
group.bench_with_input(
102102
BenchmarkId::new(
103103
"(transport, value_size)",
104-
format!("({:?}, {})", transport, value_size),
104+
format!("({transport:?}, {value_size})"),
105105
),
106106
&(),
107107
|b, _| {

iroh-unixfs/src/balanced_tree.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ mod tests {
331331

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

@@ -414,7 +414,7 @@ mod tests {
414414
let node = node.expect("unexpected error in balanced tree stream");
415415
let (got_cid, got_bytes, _) = node.into_parts();
416416
let len = got_bytes.len() as u64;
417-
println!("node index {}", i);
417+
println!("node index {i}");
418418
assert_eq!(expect_cid, got_cid);
419419
assert_eq!(expect_bytes, got_bytes);
420420
i += 1;

iroh/src/fixture.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,6 @@ pub fn get_fixture_api() -> Api {
275275
let fixture_name = env::var("IROH_CTL_FIXTURE").expect("IROH_CTL_FIXTURE must be set");
276276
let fixture = registry
277277
.get(&fixture_name)
278-
.unwrap_or_else(|| panic!("unknown fixture: {}", fixture_name));
278+
.unwrap_or_else(|| panic!("unknown fixture: {fixture_name}"));
279279
fixture()
280280
}

iroh/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async fn main() -> Result<()> {
1717
match r {
1818
Ok(_) => Ok(()),
1919
Err(e) => {
20-
eprintln!("Error: {:?}", e);
20+
eprintln!("Error: {e:?}");
2121
std::process::exit(1);
2222
}
2323
}
@@ -42,7 +42,7 @@ fn transform_error(r: Result<()>) -> Result<()> {
4242
return Err(anyhow!(
4343
"Connection refused. This command requires a running {} service.\n{}",
4444
service,
45-
format!("hint: try 'iroh start {}'", service).yellow(),
45+
format!("hint: try 'iroh start {service}'").yellow(),
4646
));
4747
}
4848
Err(e)

0 commit comments

Comments
 (0)