Skip to content

Commit 9debd2b

Browse files
committed
Fix clippy
1 parent d1a99b4 commit 9debd2b

File tree

19 files changed

+74
-76
lines changed

19 files changed

+74
-76
lines changed

crates/fuzzing-corpus-generator/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn main() {
100100

101101
if let Some(path) = path {
102102
std::fs::create_dir_all(&path).expect("mkdir -p");
103-
std::fs::copy(&trace, path.join(format!("{}.data", dump_base_name)))
103+
std::fs::copy(&trace, path.join(format!("{dump_base_name}.data")))
104104
.expect("copy file");
105105
}
106106
}
@@ -110,10 +110,10 @@ fn main() {
110110
}
111111

112112
fn run_command(mut c: Command) {
113-
println!("Running Command[{:?}]", c);
113+
println!("Running Command[{c:?}]");
114114

115115
let output = c.output().unwrap_or_else(|e| {
116-
panic!("Error running Command[{:?}], error: {:?}", c, e);
116+
panic!("Error running Command[{c:?}], error: {e:?}");
117117
});
118118

119119
if !output.status.success() {

crates/intermediate-source-generator/src/bin/generate-c-params-finder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CkbSphincsParams ckb_sphincs_supported_params[] = {{"#
2222

2323
let mut min_nid = u8::MAX;
2424
for param_id in collect_param_ids() {
25-
let name = format!("CKB_{}", param_id)
25+
let name = format!("CKB_{param_id}")
2626
.replace("-", "_")
2727
.replace("SLH_DSA", "SPHINCS")
2828
.to_uppercase();

crates/intermediate-source-generator/src/bin/generate-params-txt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use ckb_fips205_utils::collect_param_ids;
33
fn main() {
44
for param_id in collect_param_ids() {
55
let formatted_id: u8 = param_id.into();
6-
let formatted_name = format!("sphincs-{}", param_id)
6+
let formatted_name = format!("sphincs-{param_id}")
77
.replace("SLH-DSA-", "")
88
.to_lowercase();
99
println!("{formatted_id} {formatted_name}");

crates/intermediate-source-generator/src/bin/generate-rust-params.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn lengths(param_id: ParamId) -> (usize, usize) {{
2626
let mut min_nid = u8::MAX;
2727
for param_id in collect_param_ids() {
2828
let symbol_name = {
29-
let name = format!("{}", param_id).replace("SLH-DSA-", "");
29+
let name = format!("{param_id}").replace("SLH-DSA-", "");
3030
let parts: Vec<_> = name.split("-").collect();
3131
capitalize(parts[0]) + &parts[1].to_uppercase().to_string()
3232
};
@@ -51,7 +51,7 @@ pub fn indices(param_id: ParamId) -> usize {{
5151

5252
for param_id in collect_param_ids() {
5353
let symbol_name = {
54-
let name = format!("{}", param_id).replace("SLH-DSA-", "");
54+
let name = format!("{param_id}").replace("SLH-DSA-", "");
5555
let parts: Vec<_> = name.split("-").collect();
5656
capitalize(parts[0]) + &parts[1].to_uppercase().to_string()
5757
};
@@ -71,12 +71,12 @@ pub fn binary_infos(param_id: ParamId) -> (*const u32, *const u32) {{
7171
);
7272

7373
for param_id in collect_param_ids() {
74-
let name = format!("CKB_{}", param_id)
74+
let name = format!("CKB_{param_id}")
7575
.replace("-", "_")
7676
.replace("SLH_DSA", "SPHINCS")
7777
.to_uppercase();
7878
let symbol_name = {
79-
let name = format!("{}", param_id).replace("SLH-DSA-", "");
79+
let name = format!("{param_id}").replace("SLH-DSA-", "");
8080
let parts: Vec<_> = name.split("-").collect();
8181
capitalize(parts[0]) + &parts[1].to_uppercase().to_string()
8282
};

crates/script-merge-tool/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ fn main() {
226226
root_binary[offset_symbol_offset..offset_symbol_offset + 4]
227227
.copy_from_slice(&p(offset));
228228
} else {
229-
println!("Symbol {} for leaf {} does not exist in root binary, maybe it is not used?", offset_symbol_name, leaf_name);
229+
println!("Symbol {offset_symbol_name} for leaf {leaf_name} does not exist in root binary, maybe it is not used?");
230230
}
231231

232232
let length_symbol_offset =
@@ -235,11 +235,11 @@ fn main() {
235235
root_binary[length_symbol_offset..length_symbol_offset + 4]
236236
.copy_from_slice(&p(leaf_size));
237237
} else {
238-
println!("Symbol {} for leaf {} does not exist in root binary, maybe it is not used?", length_symbol_name, leaf_name);
238+
println!("Symbol {length_symbol_name} for leaf {leaf_name} does not exist in root binary, maybe it is not used?");
239239
}
240240

241241
if offset_symbol_offset.is_none() && length_symbol_offset.is_none() {
242-
println!("Both symbols are missing for leaf {}, we are not merging this leaf script into the final script!", leaf_name);
242+
println!("Both symbols are missing for leaf {leaf_name}, we are not merging this leaf script into the final script!");
243243
} else {
244244
metadata.push(Meta::new(&leaf_name, offset, leaf_binary.len()));
245245

@@ -271,7 +271,7 @@ fn offset_sname(leaf_path: &str, prefix: &str) -> String {
271271
.expect("extract file name")
272272
.to_str()
273273
.expect("to str");
274-
format!("{}{}{}OFFSET", prefix, leaf_name, SYMBOL_COMMON_PART)
274+
format!("{prefix}{leaf_name}{SYMBOL_COMMON_PART}OFFSET")
275275
.replace("-", "_")
276276
.to_uppercase()
277277
}
@@ -282,7 +282,7 @@ fn length_sname(leaf_path: &str, prefix: &str) -> String {
282282
.expect("extract file name")
283283
.to_str()
284284
.expect("to str");
285-
format!("{}{}{}LENGTH", prefix, leaf_name, SYMBOL_COMMON_PART)
285+
format!("{prefix}{leaf_name}{SYMBOL_COMMON_PART}LENGTH")
286286
.replace("-", "_")
287287
.to_uppercase()
288288
}

tests/multisig-tests/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Loader {
8686
path.push(name);
8787
let result = fs::read(&path);
8888
if result.is_err() {
89-
panic!("Binary {:?} is missing!", path);
89+
panic!("Binary {path:?} is missing!");
9090
}
9191
result.unwrap().into()
9292
}
@@ -107,7 +107,7 @@ pub fn verify_and_dump_failed_tx(
107107
let mock_tx = context.dump_tx(tx).expect("dump failed tx");
108108
let json = serde_json::to_string_pretty(&mock_tx).expect("json");
109109
path.push(format!("0x{:x}.json", tx.hash()));
110-
println!("Failed tx written to {:?}", path);
110+
println!("Failed tx written to {path:?}");
111111
std::fs::write(path, json).expect("write");
112112
}
113113
result

tests/multisig-tests/src/tests.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use proptest::{collection::vec, prelude::*};
1414
use rand::{Rng, SeedableRng, rngs::StdRng};
1515
use rand_core::CryptoRngCore;
1616

17-
const C_NAME: &'static str = "c-sphincs-all-in-one-lock";
18-
const HYBRID_NAME: &'static str = "hybrid-sphincs-all-in-one-lock";
19-
const RUST_NAME: &'static str = "sphincs-all-in-one-lock";
17+
const C_NAME: &str = "c-sphincs-all-in-one-lock";
18+
const HYBRID_NAME: &str = "hybrid-sphincs-all-in-one-lock";
19+
const RUST_NAME: &str = "sphincs-all-in-one-lock";
2020

2121
proptest! {
2222
#[test]
@@ -35,7 +35,7 @@ proptest! {
3535
&[0],
3636
rng,
3737
).expect("pass verification");
38-
println!("consume cycles: {}", cycles);
38+
println!("consume cycles: {cycles}");
3939
}
4040

4141
#[test]
@@ -52,7 +52,7 @@ proptest! {
5252
threshold,
5353
0,
5454
);
55-
println!("Selected signer indices: {:?}", selected);
55+
println!("Selected signer indices: {selected:?}");
5656

5757
let cycles = _run_valid_tx(
5858
C_NAME,
@@ -62,7 +62,7 @@ proptest! {
6262
&selected,
6363
rng,
6464
).expect("pass verification");
65-
println!("consume cycles: {}", cycles);
65+
println!("consume cycles: {cycles}");
6666
}
6767

6868
#[test]
@@ -81,7 +81,7 @@ proptest! {
8181
threshold,
8282
first_n,
8383
);
84-
println!("Selected signer indices: {:?}", selected);
84+
println!("Selected signer indices: {selected:?}");
8585

8686
let cycles = _run_valid_tx(
8787
C_NAME,
@@ -91,7 +91,7 @@ proptest! {
9191
&selected,
9292
rng,
9393
).expect("pass verification");
94-
println!("consume cycles: {}", cycles);
94+
println!("consume cycles: {cycles}");
9595
}
9696

9797
#[test]
@@ -110,7 +110,7 @@ proptest! {
110110
&[0],
111111
rng,
112112
).expect("pass verification");
113-
println!("consume cycles: {}", cycles);
113+
println!("consume cycles: {cycles}");
114114
}
115115

116116
#[test]
@@ -127,7 +127,7 @@ proptest! {
127127
threshold,
128128
0,
129129
);
130-
println!("Selected signer indices: {:?}", selected);
130+
println!("Selected signer indices: {selected:?}");
131131

132132
let cycles = _run_valid_tx(
133133
HYBRID_NAME,
@@ -137,7 +137,7 @@ proptest! {
137137
&selected,
138138
rng,
139139
).expect("pass verification");
140-
println!("consume cycles: {}", cycles);
140+
println!("consume cycles: {cycles}");
141141
}
142142

143143
#[test]
@@ -156,7 +156,7 @@ proptest! {
156156
threshold,
157157
first_n,
158158
);
159-
println!("Selected signer indices: {:?}", selected);
159+
println!("Selected signer indices: {selected:?}");
160160

161161
let cycles = _run_valid_tx(
162162
HYBRID_NAME,
@@ -166,7 +166,7 @@ proptest! {
166166
&selected,
167167
rng,
168168
).expect("pass verification");
169-
println!("consume cycles: {}", cycles);
169+
println!("consume cycles: {cycles}");
170170
}
171171

172172
#[test]
@@ -185,7 +185,7 @@ proptest! {
185185
&[0],
186186
rng,
187187
).expect("pass verification");
188-
println!("consume cycles: {}", cycles);
188+
println!("consume cycles: {cycles}");
189189
}
190190

191191
#[test]
@@ -202,7 +202,7 @@ proptest! {
202202
threshold,
203203
0,
204204
);
205-
println!("Selected signer indices: {:?}", selected);
205+
println!("Selected signer indices: {selected:?}");
206206

207207
let cycles = _run_valid_tx(
208208
RUST_NAME,
@@ -212,7 +212,7 @@ proptest! {
212212
&selected,
213213
rng,
214214
).expect("pass verification");
215-
println!("consume cycles: {}", cycles);
215+
println!("consume cycles: {cycles}");
216216
}
217217

218218
#[test]
@@ -231,7 +231,7 @@ proptest! {
231231
threshold,
232232
first_n,
233233
);
234-
println!("Selected signer indices: {:?}", selected);
234+
println!("Selected signer indices: {selected:?}");
235235

236236
let cycles = _run_valid_tx(
237237
RUST_NAME,
@@ -241,7 +241,7 @@ proptest! {
241241
&selected,
242242
rng,
243243
).expect("pass verification");
244-
println!("consume cycles: {}", cycles);
244+
println!("consume cycles: {cycles}");
245245
}
246246
}
247247

@@ -262,7 +262,7 @@ proptest! {
262262
threshold - 1,
263263
0,
264264
);
265-
println!("Selected signer indices: {:?}", selected);
265+
println!("Selected signer indices: {selected:?}");
266266

267267
let e = _run_valid_tx(
268268
C_NAME,
@@ -272,7 +272,7 @@ proptest! {
272272
&selected,
273273
rng,
274274
).unwrap_err();
275-
assert!(!format!("{}", e).contains("ExceededMaximumCycles"));
275+
assert!(!format!("{e}").contains("ExceededMaximumCycles"));
276276
}
277277

278278
#[test]
@@ -291,7 +291,7 @@ proptest! {
291291
threshold - 1,
292292
0,
293293
);
294-
println!("Selected signer indices: {:?}", selected);
294+
println!("Selected signer indices: {selected:?}");
295295

296296
let e = _run_valid_tx(
297297
HYBRID_NAME,
@@ -301,7 +301,7 @@ proptest! {
301301
&selected,
302302
rng,
303303
).unwrap_err();
304-
assert!(!format!("{}", e).contains("ExceededMaximumCycles"));
304+
assert!(!format!("{e}").contains("ExceededMaximumCycles"));
305305
}
306306

307307
#[test]
@@ -320,7 +320,7 @@ proptest! {
320320
threshold - 1,
321321
0,
322322
);
323-
println!("Selected signer indices: {:?}", selected);
323+
println!("Selected signer indices: {selected:?}");
324324

325325
let e = _run_valid_tx(
326326
RUST_NAME,
@@ -330,7 +330,7 @@ proptest! {
330330
&selected,
331331
rng,
332332
).unwrap_err();
333-
assert!(!format!("{}", e).contains("ExceededMaximumCycles"));
333+
assert!(!format!("{e}").contains("ExceededMaximumCycles"));
334334
}
335335

336336
#[test]
@@ -351,7 +351,7 @@ proptest! {
351351
threshold,
352352
first_n - 1,
353353
);
354-
println!("Selected signer indices: {:?}", selected);
354+
println!("Selected signer indices: {selected:?}");
355355

356356
let e = _run_valid_tx(
357357
C_NAME,
@@ -361,7 +361,7 @@ proptest! {
361361
&selected,
362362
rng,
363363
).unwrap_err();
364-
assert!(!format!("{}", e).contains("ExceededMaximumCycles"));
364+
assert!(!format!("{e}").contains("ExceededMaximumCycles"));
365365
}
366366

367367
#[test]
@@ -382,7 +382,7 @@ proptest! {
382382
threshold,
383383
first_n - 1,
384384
);
385-
println!("Selected signer indices: {:?}", selected);
385+
println!("Selected signer indices: {selected:?}");
386386

387387
let e = _run_valid_tx(
388388
HYBRID_NAME,
@@ -392,7 +392,7 @@ proptest! {
392392
&selected,
393393
rng,
394394
).unwrap_err();
395-
assert!(!format!("{}", e).contains("ExceededMaximumCycles"));
395+
assert!(!format!("{e}").contains("ExceededMaximumCycles"));
396396
}
397397

398398
#[test]
@@ -413,7 +413,7 @@ proptest! {
413413
threshold,
414414
first_n - 1,
415415
);
416-
println!("Selected signer indices: {:?}", selected);
416+
println!("Selected signer indices: {selected:?}");
417417

418418
let e = _run_valid_tx(
419419
RUST_NAME,
@@ -423,7 +423,7 @@ proptest! {
423423
&selected,
424424
rng,
425425
).unwrap_err();
426-
assert!(!format!("{}", e).contains("ExceededMaximumCycles"));
426+
assert!(!format!("{e}").contains("ExceededMaximumCycles"));
427427
}
428428
}
429429

@@ -456,7 +456,7 @@ fn _run_valid_tx<R: Rng + CryptoRngCore>(
456456
let val = signed_tx.hash().nth0().as_slice()[0] as u16;
457457
if val < prob {
458458
let directory = std::path::Path::new(&path);
459-
std::fs::create_dir_all(&directory).expect("mkdir -p");
459+
std::fs::create_dir_all(directory).expect("mkdir -p");
460460

461461
let path = directory.join(format!("0x{:x}.json", signed_tx.hash()));
462462
let mock_tx = context.dump_tx(&signed_tx).expect("dump failed tx");

0 commit comments

Comments
 (0)