Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

chore: clear the rustc 1.96 clippy lints that fail `cargo xtask ci`

skylar taylor-barricke6587c3f82a2
diff --git a/crates/engine/src/slide_overlay.rs b/crates/engine/src/slide_overlay.rs
index 409739335..a27f75d49 100644
--- a/crates/engine/src/slide_overlay.rs
+++ b/crates/engine/src/slide_overlay.rs
@@ -903,7 +903,7 @@ fn shadow(img: &mut Rgba8, tl: &crate::text::TextLayout, x: f64, y: f64, sigma:
let my0 = (y - pad).floor().max(-pad);
let mx1 = (x + tl.width as f64 + pad).ceil().min(iw + pad);
let my1 = (y + tl.height as f64 + pad).ceil().min(ih + pad);
- if !(mx1 > mx0 && my1 > my0) || !mx0.is_finite() || !my0.is_finite() {
+ if !(mx1 > mx0 && my1 > my0 && mx0.is_finite() && my0.is_finite()) {
return;
}
let (w, h) = ((mx1 - mx0) as usize, (my1 - my0) as usize);
diff --git a/crates/engine/src/tests_export.rs b/crates/engine/src/tests_export.rs
index 2f1a05116..0ac8df804 100644
--- a/crates/engine/src/tests_export.rs
+++ b/crates/engine/src/tests_export.rs
@@ -1024,21 +1024,24 @@ fn same_folder_as_original_refuses_photos_without_a_folder() {
let mut s = Session::with_demo();
let ids: Vec<_> = s.catalog.photos().take(2).map(|p| p.id).collect();
let mut written = Vec::new();
- let mut write = |p: &str, _: &[u8]| -> Result<(), String> {
- written.push(p.to_string());
- Ok(())
+ // the writer lives in a block of its own, so its borrow of `written` has ended by the time
+ // the assertion below reads it
+ let files = {
+ let mut write = |p: &str, _: &[u8]| -> Result<(), String> {
+ written.push(p.to_string());
+ Ok(())
+ };
+ let err = crate::export::export_batch(&mut s, &ids, &o, &to, &mut write, &|_| false).unwrap_err();
+ assert!(err.contains("no folder on disk"), "{err}");
+ // without stopping: one error per photo, nothing written
+ let items = crate::export::prepare_batch(&mut s, &ids, &o).unwrap();
+ crate::export::run_batch(items, &o, &to, &mut write, &|_| false, false, &mut |_, _| true).unwrap()
};
- let err = crate::export::export_batch(&mut s, &ids, &o, &to, &mut write, &|_| false).unwrap_err();
- assert!(err.contains("no folder on disk"), "{err}");
- // without stopping: one error per photo, nothing written
- let items = crate::export::prepare_batch(&mut s, &ids, &o).unwrap();
- let files = crate::export::run_batch(items, &o, &to, &mut write, &|_| false, false, &mut |_, _| true).unwrap();
assert_eq!(files.len(), 2);
for (f, id) in files.iter().zip(&ids) {
assert_eq!(f["photo"], id.0, "{f}");
assert!(f["error"].as_str().unwrap().contains("no folder on disk"), "{f}");
}
- drop(write);
assert!(written.is_empty(), "{written:?}");
// a photo on disk whose folder is gone (moved, an unplugged drive)