Skip to content

Commit 768ade1

Browse files
fix: Clippy warnings for Rust 1.88 (#1204)
1 parent 7618532 commit 768ade1

File tree

29 files changed

+109
-124
lines changed

29 files changed

+109
-124
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,11 @@ jobs:
487487
- name: Install nightly toolchain
488488
uses: dtolnay/rust-toolchain@master
489489
with:
490-
toolchain: nightly-2025-06-05
490+
toolchain: nightly-2025-06-28
491491
components: rustfmt
492-
# Pinning to specific nightly build for now. More recent versions
493-
# introduce a lifetime check that creates a whole slew of build
494-
# errors.
495492

496493
- name: Check format
497-
run: cargo +nightly-2025-06-05 fmt --all -- --check
494+
run: cargo +nightly-2025-06-28 fmt --all -- --check
498495

499496
docs_rs:
500497
name: Preflight docs.rs build

c2pa_c_ffi/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222

2323
// Get the workspace target directory.
2424
let out_dir = env::var("OUT_DIR").expect("OUT_DIR environment variable not set");
25-
println!("Running c2pa_c_ffi folder build script: {:?}", out_dir);
25+
println!("Running c2pa_c_ffi folder build script: {out_dir:?}");
2626

2727
let workspace_target_dir = Path::new(&out_dir)
2828
.ancestors()
@@ -38,10 +38,10 @@ fn main() {
3838
// Add a version string to the header.
3939
config.header = match config.header {
4040
Some(ref mut header) => {
41-
header.push_str(&format!("\n// Version: {}\n", version));
41+
header.push_str(&format!("\n// Version: {version}\n"));
4242
Some(header.clone())
4343
}
44-
None => Some(format!("\n// Version: {}\n", version)),
44+
None => Some(format!("\n// Version: {version}\n")),
4545
};
4646

4747
// Generate the header file.
@@ -50,7 +50,7 @@ fn main() {
5050
cbindgen::Error::ParseSyntaxError { .. } => {
5151
eprintln!("Warning: ParseSyntaxError encountered while generating bindings");
5252
}
53-
e => panic!("{:?}", e),
53+
e => panic!("{e:?}"),
5454
},
5555
|bindings| {
5656
println!(

c2pa_c_ffi/src/c_api.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ pub unsafe extern "C" fn c2pa_signer_create(
11181118
signed_len_max,
11191119
)
11201120
};
1121-
println!("c_callback: signed_size: {}", signed_size);
1121+
println!("c_callback: signed_size: {signed_size}");
11221122
if signed_size < 0 {
11231123
return Err(c2pa::Error::CoseSignature); // todo:: return errors from callback
11241124
}
@@ -1604,11 +1604,8 @@ mod tests {
16041604
#[cfg(feature = "file_io")]
16051605
fn test_reader_from_file_cawg_identity() {
16061606
let base = env!("CARGO_MANIFEST_DIR");
1607-
let path = CString::new(format!(
1608-
"{}/../sdk/tests/fixtures/C_with_CAWG_data.jpg",
1609-
base
1610-
))
1611-
.unwrap();
1607+
let path =
1608+
CString::new(format!("{base}/../sdk/tests/fixtures/C_with_CAWG_data.jpg")).unwrap();
16121609
let reader = unsafe { c2pa_reader_from_file(path.as_ptr()) };
16131610
if reader.is_null() {
16141611
let error = unsafe { c2pa_error() };

c2pa_c_ffi/src/json_api.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ mod tests {
8383
/// returns a path to a file in the fixtures folder
8484
pub fn test_path(path: &str) -> String {
8585
let base = env!("CARGO_MANIFEST_DIR");
86-
format!("{}/../sdk/{}", base, path)
86+
format!("{base}/../sdk/{path}")
8787
}
8888

8989
#[test]
@@ -92,7 +92,7 @@ mod tests {
9292
let result = read_file(&path, None);
9393
assert!(result.is_ok());
9494
let json_report = result.unwrap();
95-
println!("{}", json_report);
95+
println!("{json_report}");
9696
assert!(json_report.contains("C.jpg"));
9797
assert!(!json_report.contains("validation_status"));
9898
}
@@ -107,7 +107,7 @@ mod tests {
107107
let result = read_file(&path, Some(data_dir.to_owned()));
108108
//assert!(result.is_ok());
109109
let json_report = result.unwrap();
110-
println!("{}", json_report);
110+
println!("{json_report}");
111111
assert!(json_report.contains("C.jpg"));
112112
assert!(PathBuf::from(data_dir).exists());
113113
assert!(json_report.contains("thumbnail"));
@@ -119,7 +119,7 @@ mod tests {
119119
let result = read_file(&path, None);
120120
assert!(result.is_ok());
121121
let json_report = result.unwrap();
122-
println!("{}", json_report);
122+
println!("{json_report}");
123123
assert!(json_report.contains("cawg.identity"));
124124
assert!(json_report.contains("cawg.ica.credential_valid"));
125125
}

cli/src/callback_signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a> CallbackSigner<'a> {
149149
impl Signer for CallbackSigner<'_> {
150150
fn sign(&self, data: &[u8]) -> c2pa::Result<Vec<u8>> {
151151
self.callback.sign(data).map_err(|e| {
152-
eprintln!("Unable to embed signature into asset. {}", e);
152+
eprintln!("Unable to embed signature into asset. {e}");
153153
Error::EmbeddingError
154154
})
155155
}

cli/src/main.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,15 @@ fn load_trust_resource(resource: &TrustResource) -> Result<String> {
253253
match resource {
254254
TrustResource::File(path) => {
255255
let data = std::fs::read_to_string(path)
256-
.with_context(|| format!("Failed to read trust resource from path: {:?}", path))?;
256+
.with_context(|| format!("Failed to read trust resource from path: {path:?}"))?;
257257

258258
Ok(data)
259259
}
260260
TrustResource::Url(url) => {
261261
#[cfg(not(target_os = "wasi"))]
262262
let data = reqwest::blocking::get(url.to_string())?
263263
.text()
264-
.with_context(|| format!("Failed to read trust resource from URL: {}", url))?;
264+
.with_context(|| format!("Failed to read trust resource from URL: {url}"))?;
265265

266266
#[cfg(target_os = "wasi")]
267267
let data = blocking_get(&url.to_string())?;
@@ -376,7 +376,7 @@ fn configure_sdk(args: &CliArgs) -> Result<()> {
376376
{
377377
if let Some(trust_list) = &trust_anchors {
378378
let data = load_trust_resource(trust_list)?;
379-
debug!("Using trust anchors from {:?}", trust_list);
379+
debug!("Using trust anchors from {trust_list:?}");
380380
let replacement_val = serde_json::Value::String(data).to_string(); // escape string
381381
let setting = TA.replace("replacement_val", &replacement_val);
382382

@@ -387,7 +387,7 @@ fn configure_sdk(args: &CliArgs) -> Result<()> {
387387

388388
if let Some(allowed_list) = &allowed_list {
389389
let data = load_trust_resource(allowed_list)?;
390-
debug!("Using allowed list from {:?}", allowed_list);
390+
debug!("Using allowed list from {allowed_list:?}");
391391
let replacement_val = serde_json::Value::String(data).to_string(); // escape string
392392
let setting = AL.replace("replacement_val", &replacement_val);
393393

@@ -398,7 +398,7 @@ fn configure_sdk(args: &CliArgs) -> Result<()> {
398398

399399
if let Some(trust_config) = &trust_config {
400400
let data = load_trust_resource(trust_config)?;
401-
debug!("Using trust config from {:?}", trust_config);
401+
debug!("Using trust config from {trust_config:?}");
402402
let replacement_val = serde_json::Value::String(data).to_string(); // escape string
403403
let setting = TC.replace("replacement_val", &replacement_val);
404404

@@ -456,7 +456,7 @@ fn sign_fragmented(
456456
}
457457
}
458458

459-
println!("Adding manifest to: {:?}", p);
459+
println!("Adding manifest to: {p:?}");
460460
let new_output_path =
461461
output_path.join(init_dir.file_name().context("invalid file name")?);
462462
builder.sign_fragmented_files(signer, &p, &fragments, &new_output_path)?;
@@ -467,7 +467,7 @@ fn sign_fragmented(
467467
}
468468
}
469469
if count == 0 {
470-
println!("No files matching pattern: {}", ip);
470+
println!("No files matching pattern: {ip}");
471471
}
472472
Ok(())
473473
}
@@ -499,11 +499,11 @@ fn verify_fragmented(init_pattern: &Path, frag_pattern: &Path) -> Result<Vec<Rea
499499
}
500500
}
501501

502-
println!("Verifying manifest: {:?}", p);
502+
println!("Verifying manifest: {p:?}");
503503
let reader = Reader::from_fragmented_files(p, &fragments)?;
504504
if let Some(vs) = reader.validation_status() {
505505
if let Some(e) = vs.iter().find(|v| !v.passed()) {
506-
eprintln!("Error validating segments: {:?}", e);
506+
eprintln!("Error validating segments: {e:?}");
507507
return Ok(readers);
508508
}
509509
}
@@ -517,7 +517,7 @@ fn verify_fragmented(init_pattern: &Path, frag_pattern: &Path) -> Result<Vec<Rea
517517
}
518518

519519
if count == 0 {
520-
println!("No files matching pattern: {}", ip);
520+
println!("No files matching pattern: {ip}");
521521
}
522522

523523
Ok(readers)
@@ -739,9 +739,9 @@ fn main() -> Result<()> {
739739
let mut reader = Reader::from_file(&output).map_err(special_errs)?;
740740
validate_cawg(&mut reader)?;
741741
if args.detailed {
742-
println!("{:#?}", reader);
742+
println!("{reader:#?}");
743743
} else {
744-
println!("{}", reader)
744+
println!("{reader}")
745745
}
746746
}
747747
} else {
@@ -775,7 +775,7 @@ fn main() -> Result<()> {
775775
if args.detailed {
776776
// for a detailed report first call the above to generate the thumbnails
777777
// then call this to add the detailed report
778-
let detailed = format!("{:#?}", reader);
778+
let detailed = format!("{reader:#?}");
779779
File::create(output.join("detailed.json"))?.write_all(&detailed.into_bytes())?;
780780
}
781781
File::create(output.join("manifest_store.json"))?.write_all(&report.into_bytes())?;
@@ -789,7 +789,7 @@ fn main() -> Result<()> {
789789
} else if args.detailed {
790790
let mut reader = Reader::from_file(&args.path).map_err(special_errs)?;
791791
validate_cawg(&mut reader)?;
792-
println!("{:#?}", reader);
792+
println!("{reader:#?}");
793793
} else if let Some(Commands::Fragment {
794794
fragments_glob: Some(fg),
795795
}) = &args.command
@@ -807,7 +807,7 @@ fn main() -> Result<()> {
807807
} else {
808808
let mut reader = Reader::from_file(&args.path).map_err(special_errs)?;
809809
validate_cawg(&mut reader)?;
810-
println!("{}", reader);
810+
println!("{reader}");
811811
}
812812

813813
Ok(())
@@ -862,7 +862,7 @@ pub mod tests {
862862
let ms = Reader::from_file(output_path)
863863
.expect("from_file")
864864
.to_string();
865-
println!("{}", ms);
865+
println!("{ms}");
866866
//let ms = report_from_path(&OUTPUT_PATH, false).expect("report_from_path");
867867
assert!(ms.contains("my_key"));
868868
}

cli/src/tree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ fn populate_node(
3434
if let Some(label) = ingredient.active_manifest() {
3535
// create new node
3636
let data = if name_only {
37-
format!("{}_{}", title, label)
37+
format!("{title}_{label}")
3838
} else {
39-
format!("Asset:{}, Manifest:{}", title, label)
39+
format!("Asset:{title}, Manifest:{label}")
4040
};
4141

4242
let new_token = current_token.append(tree, data);
@@ -83,7 +83,7 @@ pub fn tree<P: AsRef<Path>>(path: P) -> Result<String> {
8383

8484
// walk through the manifests and show the contents
8585
Ok(if let Some(manifest_label) = reader.active_label() {
86-
let data = format!("Asset:{}, Manifest:{}", asset_name, manifest_label);
86+
let data = format!("Asset:{asset_name}, Manifest:{manifest_label}");
8787
let (mut tree, root_token) = Arena::with_data(data);
8888
populate_node(&mut tree, &reader, manifest_label, &root_token, false)?;
8989
// print tree

export_schema/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ use c2pa::{settings::Settings, Builder, ManifestDefinition, Reader};
55
use schemars::{schema::RootSchema, schema_for};
66

77
fn write_schema(schema: &RootSchema, name: &str) {
8-
println!("Exporting JSON schema for {}", name);
8+
println!("Exporting JSON schema for {name}");
99
let output = serde_json::to_string_pretty(schema).expect("Failed to serialize schema");
1010
let output_dir = Path::new("./target/schema");
1111
fs::create_dir_all(output_dir).expect("Could not create schema directory");
12-
let output_path = output_dir.join(format!("{}.schema.json", name));
12+
let output_path = output_dir.join(format!("{name}.schema.json"));
1313
fs::write(&output_path, output).expect("Unable to write schema");
1414
println!("Wrote schema to {}", output_path.display());
1515
}

make_test_images/src/compare_manifests.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ pub fn compare_folders<P: AsRef<Path>, Q: AsRef<Path>>(folder1: P, folder2: Q) -
2727
if folder1.is_file() && folder2.is_file() {
2828
let issues = compare_image_manifests(folder1, folder2)?;
2929
if !issues.is_empty() {
30-
eprintln!("Failed {:?}", folder1);
30+
eprintln!("Failed {folder1:?}");
3131
for issue in issues {
32-
eprintln!(" {}", issue);
32+
eprintln!(" {issue}");
3333
}
3434
} else {
35-
println!("Passed {:?}", folder1);
35+
println!("Passed {folder1:?}");
3636
}
3737
return Ok(());
3838
} else if !(folder1.is_dir() && folder2.is_dir()) {
@@ -61,12 +61,12 @@ pub fn compare_folders<P: AsRef<Path>, Q: AsRef<Path>>(folder1: P, folder2: Q) -
6161
));
6262
}
6363
if !issues.is_empty() {
64-
eprintln!("Failed {:?}", relative_path);
64+
eprintln!("Failed {relative_path:?}");
6565
for issue in issues {
66-
eprintln!(" {}", issue);
66+
eprintln!(" {issue}");
6767
}
6868
} else {
69-
println!("Passed {:?}", relative_path);
69+
println!("Passed {relative_path:?}");
7070
}
7171
}
7272
}
@@ -126,7 +126,7 @@ pub fn compare_manifests(
126126
let value1 = serde_json::to_value(manifest_store1.get_manifest(label1))?;
127127
let value2 = serde_json::to_value(manifest_store2.get_manifest(label2))?;
128128
compare_json_values(
129-
&format!("manifests.{}", label1),
129+
&format!("manifests.{label1}"),
130130
&value1,
131131
&value2,
132132
&mut issues,
@@ -181,18 +181,18 @@ fn compare_json_values(
181181
(serde_json::Value::Object(map1), serde_json::Value::Object(map2)) => {
182182
for (key, val1) in map1 {
183183
let val2 = map2.get(key).unwrap_or(&serde_json::Value::Null);
184-
compare_json_values(&format!("{}.{}", path, key), val1, val2, issues);
184+
compare_json_values(&format!("{path}.{key}"), val1, val2, issues);
185185
}
186186

187187
for (key, value) in map2 {
188188
if map1.get(key).is_none() {
189-
issues.push(format!("Added {}.{}: {}", path, key, value));
189+
issues.push(format!("Added {path}.{key}: {value}"));
190190
}
191191
}
192192
}
193193
(serde_json::Value::Array(arr1), serde_json::Value::Array(arr2)) => {
194194
for (i, (val1, val2)) in arr1.iter().zip(arr2.iter()).enumerate() {
195-
compare_json_values(&format!("{}[{}]", path, i), val1, val2, issues);
195+
compare_json_values(&format!("{path}[{i}]"), val1, val2, issues);
196196
}
197197
}
198198
(val1, val2) if val1 != val2 => {
@@ -265,11 +265,11 @@ fn compare_json_values(
265265
}
266266

267267
if val2.is_null() {
268-
issues.push(format!("Missing {}: {}", path, val1));
268+
issues.push(format!("Missing {path}: {val1}"));
269269
} else if val2.is_null() {
270-
issues.push(format!("Added {}: {}", path, val2));
270+
issues.push(format!("Added {path}: {val2}"));
271271
} else {
272-
issues.push(format!("Changed {}: {} vs {}", path, val1, val2));
272+
issues.push(format!("Changed {path}: {val1} vs {val2}"));
273273
}
274274
}
275275
_ => (),

sdk/examples/fragmented_bmff.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ mod cawg {
154154
}
155155
}
156156

157-
println!("Adding manifest to: {:?}", p);
157+
println!("Adding manifest to: {p:?}");
158158
let new_output_path =
159159
output_path.join(init_dir.file_name().context("invalid file name")?);
160160
builder.sign_fragmented_files(signer, &p, &fragments, &new_output_path)?;
@@ -165,7 +165,7 @@ mod cawg {
165165
}
166166
}
167167
if count == 0 {
168-
println!("No files matching pattern: {}", ip);
168+
println!("No files matching pattern: {ip}");
169169
}
170170
Ok(())
171171
}

0 commit comments

Comments
 (0)