From 75cc264ccffc6edcb5cef903117c032e9e45a4ff Mon Sep 17 00:00:00 2001 From: tylerjenningsw Date: Sat, 10 Oct 2026 16:54:16 -0400 Subject: [PATCH] Lint: clippy's collapsible_match passes on Rust 1.95 cargo +1.95 clippy --workspace --all-targets --release -- -D warnings stopped on seven `if` blocks that clippy wants folded into their match arm (psd, text, effects x2, pdf x2, render). Each becomes a match guard. The behaviour is unchanged: when a guard is false the value falls through to arms that can't match it and then to `_ => {}`. The one exception is the PDF PostScript calculator, where a `{` past the nesting limit would fall through to the operator arm; it keeps its own no-op arm, so it is still skipped rather than pushed as an operator. --- crates/effects/src/audio_fx.rs | 6 ++---- crates/effects/src/generate3.rs | 6 ++---- crates/pdf/src/color.rs | 8 +++----- crates/pdf/src/page.rs | 8 +++----- crates/psd/src/lib.rs | 6 ++---- crates/render/src/masks.rs | 6 ++---- crates/text/src/path_text.rs | 6 ++---- 7 files changed, 16 insertions(+), 30 deletions(-) diff --git a/crates/effects/src/audio_fx.rs b/crates/effects/src/audio_fx.rs index a5e1fc4e..cd9153d6 100644 --- a/crates/effects/src/audio_fx.rs +++ b/crates/effects/src/audio_fx.rs @@ -245,10 +245,8 @@ pub fn process(id: &str, params: &Params, buf: &mut [f32], rate: u32, start: f64 } let sr = rate as f64; match id { - "ec.audio.backwards" => { - if params.b("swapChannels") { - buf.as_chunks_mut::<2>().0.iter_mut().for_each(|f| f.swap(0, 1)); - } + "ec.audio.backwards" if params.b("swapChannels") => { + buf.as_chunks_mut::<2>().0.iter_mut().for_each(|f| f.swap(0, 1)); } "ec.audio.basstreble" => { let bass = params.f("bass") / 100.0 * 12.0; diff --git a/crates/effects/src/generate3.rs b/crates/effects/src/generate3.rs index 926846a9..81797d9c 100644 --- a/crates/effects/src/generate3.rs +++ b/crates/effects/src/generate3.rs @@ -503,10 +503,8 @@ fn scan_runs(polys: &[(Vec<[f64; 2]>, bool, bool)], fill: u32, ew: f64, d: [f64; let entering = k % 2 == 0; let l = ew / sin; match mode { - 0 => { - if entering && k + 1 < xs.len() { - out.push((t, xs[k + 1].0)); - } + 0 if entering && k + 1 < xs.len() => { + out.push((t, xs[k + 1].0)); } 1 => out.push((t - l * 0.5, t + l * 0.5)), 2 => out.push(if entering { (t, t + l) } else { (t - l, t) }), diff --git a/crates/pdf/src/color.rs b/crates/pdf/src/color.rs index 019121e0..6943476b 100644 --- a/crates/pdf/src/color.rs +++ b/crates/pdf/src/color.rs @@ -221,11 +221,9 @@ fn ps_parse(lx: &mut crate::object::Lexer, depth: usize) -> Vec { match o { Obj::Num(n) => out.push(PsOp::Num(n)), Obj::Bool(b) => out.push(PsOp::Num(if b { 1.0 } else { 0.0 })), - Obj::Op(op) if op == "{" => { - if depth < 32 { - out.push(PsOp::Proc(ps_parse(lx, depth + 1))); - } - } + Obj::Op(op) if op == "{" && depth < 32 => out.push(PsOp::Proc(ps_parse(lx, depth + 1))), + // Nested too deep: skip the procedure's opening brace (never push it as an operator). + Obj::Op(op) if op == "{" => {} Obj::Op(op) if op == "}" => return out, Obj::Op(op) => out.push(PsOp::Op(op)), _ => {} diff --git a/crates/pdf/src/page.rs b/crates/pdf/src/page.rs index 94f62933..13e98b3c 100644 --- a/crates/pdf/src/page.rs +++ b/crates/pdf/src/page.rs @@ -313,11 +313,9 @@ impl<'a> Interp<'a> { self.path.curve_to(Point::new(n(0), n(1)), p, p); self.cur = Some(p); } - "h" => { - if self.cur.is_some() { - self.path.close_path(); - self.cur = self.start; - } + "h" if self.cur.is_some() => { + self.path.close_path(); + self.cur = self.start; } "re" => { let (x, y, w, h) = (n(0), n(1), n(2), n(3)); diff --git a/crates/psd/src/lib.rs b/crates/psd/src/lib.rs index 422c3153..1c0fd3d4 100644 --- a/crates/psd/src/lib.rs +++ b/crates/psd/src/lib.rs @@ -656,10 +656,8 @@ impl Psd { let gamma = r.f32()? as f64; l.adjustment = Some(Adjustment::Exposure { exposure, offset, gamma }); } - b"curv" | b"blnc" | b"post" | b"thrs" | b"selc" | b"mixr" | b"phfl" | b"vibA" | b"blwh" | b"grdm" | b"clrL" => { - if l.adjustment.is_none() { - l.adjustment = Some(Adjustment::Other(String::from_utf8_lossy(key).into_owned())); - } + b"curv" | b"blnc" | b"post" | b"thrs" | b"selc" | b"mixr" | b"phfl" | b"vibA" | b"blwh" | b"grdm" | b"clrL" if l.adjustment.is_none() => { + l.adjustment = Some(Adjustment::Other(String::from_utf8_lossy(key).into_owned())); } b"SoLd" | b"SoLE" => { let _id = r.tag()?; diff --git a/crates/render/src/masks.rs b/crates/render/src/masks.rs index 980e6475..f36c6d9e 100644 --- a/crates/render/src/masks.rs +++ b/crates/render/src/masks.rs @@ -114,10 +114,8 @@ pub fn shapes(ctx: &EvalCtx, layer: &Layer) -> Vec = Vec::new(); let mut closed = false; kurbo::flatten(path.iter(), 0.25, |el| match el { - effectcraft_path::PathEl::MoveTo(p) | effectcraft_path::PathEl::LineTo(p) => { - if pts.last() != Some(&[p.x, p.y]) { - pts.push([p.x, p.y]); - } + effectcraft_path::PathEl::MoveTo(p) | effectcraft_path::PathEl::LineTo(p) if pts.last() != Some(&[p.x, p.y]) => { + pts.push([p.x, p.y]); } effectcraft_path::PathEl::ClosePath => closed = true, _ => {} diff --git a/crates/text/src/path_text.rs b/crates/text/src/path_text.rs index 5c2b4338..85cab071 100644 --- a/crates/text/src/path_text.rs +++ b/crates/text/src/path_text.rs @@ -32,10 +32,8 @@ impl PathMeasure { pts.push(p); } } - PathEl::LineTo(p) => { - if pts.last().is_none_or(|q| q.distance(p) > 1e-9) { - pts.push(p); - } + PathEl::LineTo(p) if pts.last().is_none_or(|q| q.distance(p) > 1e-9) => { + pts.push(p); } PathEl::ClosePath => { closed = true;