chore: fix workspace Clippy collapsible_match warnings (#5190)

Strict workspace Clippy stopped on collapsible_match in affinity, raw, plugins, engine, ui-egui and xtask. Pure conditions become guarded match arms (each falling through to an existing empty arm), and the ruler drag state and the measurement command result are bound to locals, preserving evaluation order, error messages and fallbacks.

The same lint fixes also appear as a side commit in #5157 (David2766), which can drop it on rebase.
This commit is contained in:
Ivan · VanTan
2026-10-16 17:42:36 -07:00
committed by GitHub
parent d900daa0ba
commit 10fdcbbefc
7 changed files with 19 additions and 32 deletions
+2 -5
View File
@@ -94,11 +94,8 @@ pub fn preview(bytes: &[u8]) -> Result<Preview<'_>, Error> {
}
image_data = true;
}
b"IEND" => {
if !image_data {
return Err(Error::Malformed("PNG has no image data"));
}
}
b"IEND" if !image_data => return Err(Error::Malformed("PNG has no image data")),
b"IEND" => {}
_ if kind.first().is_some_and(u8::is_ascii_uppercase) => {
return Err(Error::Unsupported("unknown critical PNG chunk"));
}
+2 -3
View File
@@ -64,10 +64,9 @@ fn validate(p: &Value) -> Result<()> {
Some(Value::String(s)) => {
crate::commands::parse_hex(s).ok_or_else(|| bad(format!("`color` must be \"#rrggbb\", not {s:?}")))?;
}
Some(Value::Array(a)) if (3..=4).contains(&a.len()) && a.iter().all(|v| v.as_f64().is_some_and(|x| x.is_finite() && (0.0..=1.0).contains(&x))) => {}
Some(Value::Array(a)) if (3..=4).contains(&a.len()) => {
if !a.iter().all(|v| v.as_f64().is_some_and(|x| x.is_finite() && (0.0..=1.0).contains(&x))) {
return Err(bad("`color` as an array must hold 3 or 4 numbers in 0..1"));
}
return Err(bad("`color` as an array must hold 3 or 4 numbers in 0..1"));
}
Some(_) => return Err(bad("`color` must be \"#rrggbb\" or [r, g, b] in 0..1")),
}
+2 -4
View File
@@ -122,10 +122,8 @@ impl Manifest {
return Err(Error::Manifest(format!("invalid parameter name {k:?}")));
}
match spec {
ParamSpec::Number { min, max, default } => {
if !(min.is_finite() && max.is_finite() && default.is_finite()) || min > max {
return Err(Error::Manifest(format!("parameter `{k}`: bad range")));
}
ParamSpec::Number { min, max, default } if !(min.is_finite() && max.is_finite() && default.is_finite()) || min > max => {
return Err(Error::Manifest(format!("parameter `{k}`: bad range")));
}
ParamSpec::Int { min, max, .. } if min > max => return Err(Error::Manifest(format!("parameter `{k}`: bad range"))),
ParamSpec::Choice { options, default } => {
+1 -5
View File
@@ -141,11 +141,7 @@ fn walk<'a>(raw: &'a [u8], b: &'a [u8], depth: usize, budget: &mut usize, found:
}
boxes(b, budget, |item, budget| match item.kind {
b"moov" => walk(raw, item.body, depth + 1, budget, found),
b"trak" => {
if found.previews.len() < 128 {
found.previews.extend(track_preview(raw, item.body, budget, &found.media));
}
}
b"trak" if found.previews.len() < 128 => found.previews.extend(track_preview(raw, item.body, budget, &found.media)),
b"uuid" => {
if item.body.get(..16) == Some(META_UUID)
&& let Some(children) = item.body.get(16..)
+4 -2
View File
@@ -281,7 +281,8 @@ pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) ->
set_ruler(app, r);
}
(Tool::Ruler, ToolEvent::Up { .. }) => {
if app.ui.analysis.drag.take() == Some(Drag::RulerNew) && doc.measurement.ruler.is_some_and(|r| dist(r.start, r.end) < 0.5) {
let drag = app.ui.analysis.drag.take();
if drag == Some(Drag::RulerNew) && doc.measurement.ruler.is_some_and(|r| dist(r.start, r.end) < 0.5) {
let _ = app.run("image.analysis.rulerTool", json!({"clear": true}));
}
}
@@ -743,7 +744,8 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
}
Some((id, p)) => {
if app.run(id, p).is_ok() {
let result = app.run(id, p);
if result.is_ok() {
app.ui.analysis.log_selected.clear();
}
}
+6 -8
View File
@@ -5846,14 +5846,12 @@ pub(crate) fn finish_gesture(app: &mut PhotocraftApp, d: Drag) {
let _ = app.run("select.deselect", json!({}));
}
}
Tool::Gradient => {
if (end[0] - d.start[0]).abs() + (end[1] - d.start[1]).abs() >= 2.0 {
let o = app.ui.tool_options.clone();
let _ = app.run(
"paint.gradient",
json!({"from": [d.start[0], d.start[1]], "to": [end[0], end[1]], "style": o.gradient_style, "reverse": o.gradient_reverse, "dither": o.gradient_dither, "opacity": o.fill_opacity, "mode": o.gradient_blend_mode.label(), "target": paint_target(app)}),
);
}
Tool::Gradient if (end[0] - d.start[0]).abs() + (end[1] - d.start[1]).abs() >= 2.0 => {
let o = app.ui.tool_options.clone();
let _ = app.run(
"paint.gradient",
json!({"from": [d.start[0], d.start[1]], "to": [end[0], end[1]], "style": o.gradient_style, "reverse": o.gradient_reverse, "dither": o.gradient_dither, "opacity": o.fill_opacity, "mode": o.gradient_blend_mode.label(), "target": paint_target(app)}),
);
}
Tool::Move => {
let (dx, dy) = ((end[0] - d.start[0]).round(), (end[1] - d.start[1]).round());
+2 -5
View File
@@ -200,11 +200,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)) {