Skip to content

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

CI-RUST195: keep strict Clippy clean on Rust 1.95

Myrarccebaade144b7
diff --git a/crates/codecs/src/jpeg.rs b/crates/codecs/src/jpeg.rs
index e40cf7e73..ce2d0480b 100644
--- a/crates/codecs/src/jpeg.rs
+++ b/crates/codecs/src/jpeg.rs
@@ -75,14 +75,12 @@ pub(crate) fn parse_markers(b: &[u8]) -> Option<Markers> {
let end = (p + 2 + len).min(b.len());
let seg = &b[start..end];
match marker {
- 0xC0..=0xCF if marker != 0xC4 && marker != 0xC8 && marker != 0xCC => {
- if seg.len() >= 6 && m.components == 0 {
- m.precision = seg[0];
- m.sof = marker;
- m.height = u16::from_be_bytes([seg[1], seg[2]]) as u32;
- m.width = u16::from_be_bytes([seg[3], seg[4]]) as u32;
- m.components = seg[5];
- }
+ 0xC0..=0xCF if marker != 0xC4 && marker != 0xC8 && marker != 0xCC && seg.len() >= 6 && m.components == 0 => {
+ m.precision = seg[0];
+ m.sof = marker;
+ m.height = u16::from_be_bytes([seg[1], seg[2]]) as u32;
+ m.width = u16::from_be_bytes([seg[3], seg[4]]) as u32;
+ m.components = seg[5];
}
0xE1 => {
if seg.starts_with(b"Exif\0\0") && m.exif.is_none() {
diff --git a/crates/engine/src/camera_preview.rs b/crates/engine/src/camera_preview.rs
index c4824997c..400774184 100644
--- a/crates/engine/src/camera_preview.rs
+++ b/crates/engine/src/camera_preview.rs
@@ -136,7 +136,7 @@ fn dng_colour(tags: &ColorData, t: &CameraTransform, look: Option<&CameraLook>)
// into the baseline exposure
let white = m.apply([1.0; 3]);
let k = (white[0] + white[1] + white[2]) / 3.0;
- if !(k.is_finite() && k > 1e-6) || !t.wb.iter().all(|w| w.is_finite() && *w > 0.0) {
+ if !(k.is_finite() && k > 1e-6 && t.wb.iter().all(|w| w.is_finite() && *w > 0.0)) {
return None;
}
let m = Mat3(m.0.map(|r| r.map(|v| v / k)));
diff --git a/crates/engine/src/media.rs b/crates/engine/src/media.rs
index 0688410ed..0d0677b53 100644
--- a/crates/engine/src/media.rs
+++ b/crates/engine/src/media.rs
@@ -1525,7 +1525,7 @@ impl crate::Session {
/// says and what a smart preview renders with. Only for raws edited in Kelvin.
fn learn_as_shot_wb(&mut self, id: PhotoId, info: &SourceInfo) {
let Some(p) = self.catalog.photo(id) else { return };
- if !(info.raw && !info.relative_wb && p.develops_raw() && !p.relative_wb()) {
+ if !info.raw || info.relative_wb || !p.develops_raw() || p.relative_wb() {
return;
}
let read = (info.as_shot_temp, info.as_shot_tint);
diff --git a/crates/engine/src/sidecar.rs b/crates/engine/src/sidecar.rs
index c67a2c84f..cd09f8813 100644
--- a/crates/engine/src/sidecar.rs
+++ b/crates/engine/src/sidecar.rs
@@ -502,10 +502,10 @@ pub fn read_packet(original: &str, kind: MediaKind, naming: SidecarNaming) -> Op
/// Photo ids touched by an op (for auto-write).
pub(crate) fn op_photos(op: &Op, out: &mut Vec<PhotoId>) {
match op {
- Op::SetRating { id, .. } | Op::SetFlag { id, .. } | Op::SetLabel { id, .. } | Op::SetDevelop { id, .. } | Op::SetMeta { id, .. } => {
- if !out.contains(id) {
- out.push(*id);
- }
+ Op::SetRating { id, .. } | Op::SetFlag { id, .. } | Op::SetLabel { id, .. } | Op::SetDevelop { id, .. } | Op::SetMeta { id, .. }
+ if !out.contains(id) =>
+ {
+ out.push(*id);
}
Op::Batch { ops } => ops.iter().for_each(|o| op_photos(o, out)),
_ => {}
diff --git a/crates/faces/src/net/shape.rs b/crates/faces/src/net/shape.rs
index d76271bc7..89ffaba7a 100644
--- a/crates/faces/src/net/shape.rs
+++ b/crates/faces/src/net/shape.rs
@@ -186,11 +186,7 @@ pub(super) fn check(n: &Node, g: &Graph) -> Result<()> {
floats(n, g, 2)?;
}
}
- "Dropout" => {
- if !(0.0..1.0).contains(&float(n, "ratio", 0.5)) {
- return shape_err("Dropout ratio is invalid");
- }
- }
+ "Dropout" if !(0.0..1.0).contains(&float(n, "ratio", 0.5)) => return shape_err("Dropout ratio is invalid"),
"MaxPool" => {
pair(n, "kernel_shape", 1)?;
pair(n, "strides", 1)?;
diff --git a/crates/meta/src/gpx.rs b/crates/meta/src/gpx.rs
index e63499033..abfc9ebd4 100644
--- a/crates/meta/src/gpx.rs
+++ b/crates/meta/src/gpx.rs
@@ -114,11 +114,7 @@ pub fn parse_gpx(s: &str) -> Result<Tracklog, GpxError> {
match name.as_slice() {
b"gpx" if path.is_empty() => seen_gpx = true,
b"trk" if parent == Some(b"gpx") => log.tracks += 1,
- b"trkseg" if parent == Some(b"trk") => {
- if log.points.last().is_some_and(|p| p.segment == segment) {
- segment += 1;
- }
- }
+ b"trkseg" if parent == Some(b"trk") && log.points.last().is_some_and(|p| p.segment == segment) => segment += 1,
b"trkpt" if parent == Some(b"trkseg") => {
let mut p = Pending::default();
for a in e.attributes().with_checks(false).flatten() {
diff --git a/crates/meta/src/xmp.rs b/crates/meta/src/xmp.rs
index 2a4d753dc..924b5fce0 100644
--- a/crates/meta/src/xmp.rs
+++ b/crates/meta/src/xmp.rs
@@ -252,13 +252,11 @@ fn parse_tree(s: &str) -> Result<Node, XmpError> {
stack.push(node);
}
}
- Event::End(_) => {
- if stack.len() > 1 {
- let n = stack.pop().expect("len > 1");
- scopes.pop();
- if let Some(parent) = stack.last_mut() {
- parent.children.push(n);
- }
+ Event::End(_) if stack.len() > 1 => {
+ let n = stack.pop().expect("len > 1");
+ scopes.pop();
+ if let Some(parent) = stack.last_mut() {
+ parent.children.push(n);
}
}
Event::Text(t) => {
diff --git a/crates/pipeline/src/local.rs b/crates/pipeline/src/local.rs
index a99530777..e46085955 100644
--- a/crates/pipeline/src/local.rs
+++ b/crates/pipeline/src/local.rs
@@ -147,7 +147,7 @@ pub fn legacy_to_kelvin(temp: f64, tint: f64, as_shot: (f64, f64)) -> (f64, f64)
/// edited on a rendered photo or a raw without matrices never pass for Kelvin when pasted onto one that has them.
pub fn normalize_wb(d: &mut DevelopSettings, info: &SourceInfo) {
use lightcraft_develop::{WbMode, WbScale};
- if !(info.raw && !info.relative_wb) {
+ if !info.raw || info.relative_wb {
d.wb.scale = WbScale::Legacy;
return;
}
diff --git a/crates/ui-egui/src/panels/detail.rs b/crates/ui-egui/src/panels/detail.rs
index 151d4a57a..a7c8c1968 100644
--- a/crates/ui-egui/src/panels/detail.rs
+++ b/crates/ui-egui/src/panels/detail.rs
@@ -780,7 +780,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {
// the render failed while a stand-in is up: what is on screen is all there will be (also while
// a library change retries it)
let failed = (!rendering
- && !(show_before && !split)
+ && (!show_before || split)
&& !matches!(shown, "render" | "none" | "hover")
&& (!app.renderer.is_pending(Slot::Main) || app.renderer.retrying(Slot::Main)))
.then(|| app.renderer.failure_of(Slot::Main, id))
diff --git a/xtask/src/layers.rs b/xtask/src/layers.rs
index 714b47a2f..88113e27b 100644
--- a/xtask/src/layers.rs
+++ b/xtask/src/layers.rs
@@ -191,11 +191,8 @@ pub fn check(crates: &[Crate]) -> Vec<Violation> {
match classify(&d.name) {
// Unregistered deps are reported on their own entry.
None => {}
- Some(Class::Testkit) => {
- if d.kind != DepKind::Dev {
- out.push(Violation::TestkitAsNormalDep { krate: c.name.clone() });
- }
- }
+ Some(Class::Testkit) if d.kind != DepKind::Dev => out.push(Violation::TestkitAsNormalDep { krate: c.name.clone() }),
+ Some(Class::Testkit) => {}
Some(dc) => {
let to = dc.layer().unwrap_or(u8::MAX);
if to >= layer && !(to == layer && intra_layer_allowed(&c.name, &d.name)) {