From 389c71bb1b25f72767966a2b9933246f87da4182 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Thu, 7 Mar 2024 12:21:52 +0700 Subject: [PATCH] clippy: Fix semicolon_if_nothing_returned lints, enable it. --- examples/cubic_arclen.rs | 2 +- src/bezpath.rs | 44 ++++++++++++++++++++-------------------- src/cubicbez.rs | 8 ++++---- src/lib.rs | 1 + src/mindist.rs | 10 ++++----- src/param_curve.rs | 2 +- src/point.rs | 8 ++++---- src/svg.rs | 2 +- 8 files changed, 39 insertions(+), 38 deletions(-) diff --git a/examples/cubic_arclen.rs b/examples/cubic_arclen.rs index cb3c1e4b..d6b42069 100644 --- a/examples/cubic_arclen.rs +++ b/examples/cubic_arclen.rs @@ -133,7 +133,7 @@ fn est_min_deriv_norm2(c: CubicBez) -> f64 { let mut min = d.eval(1.0).to_vec2().hypot2(); for i in 0..n { let t = (i as f64) * (n as f64).recip(); - min = min.min(d.eval(t).to_vec2().hypot2()) + min = min.min(d.eval(t).to_vec2().hypot2()); } min } diff --git a/src/bezpath.rs b/src/bezpath.rs index 973021be..9edd6e83 100644 --- a/src/bezpath.rs +++ b/src/bezpath.rs @@ -210,7 +210,7 @@ impl BezPath { debug_assert!( matches!(self.0.first(), Some(PathEl::MoveTo(_))), "BezPath must begin with MoveTo" - ) + ); } /// Push a "move to" element onto the path. @@ -822,7 +822,7 @@ impl> Segments { if let Some(bb) = bbox { bbox = Some(bb.union(seg_bb)); } else { - bbox = Some(seg_bb) + bbox = Some(seg_bb); } } bbox.unwrap_or_default() @@ -1681,7 +1681,7 @@ mod tests { PathEl::ClosePath, PathEl::MoveTo((4.0, 4.0).into()), ], - ) + ); } // The following are direct port of fonttools' @@ -1707,7 +1707,7 @@ mod tests { PathEl::LineTo((0.0, 0.0).into()), // closing line NOT implied PathEl::ClosePath, ], - ) + ); } #[test] @@ -1727,7 +1727,7 @@ mod tests { PathEl::LineTo((0.0, 0.0).into()), // closing line NOT implied PathEl::ClosePath, ], - ) + ); } #[test] @@ -1747,7 +1747,7 @@ mod tests { PathEl::LineTo((0.0, 0.0).into()), PathEl::ClosePath, ], - ) + ); } #[test] @@ -1763,7 +1763,7 @@ mod tests { PathEl::LineTo((0.0, 0.0).into()), // closing line NOT implied PathEl::ClosePath, ], - ) + ); } #[test] @@ -1781,7 +1781,7 @@ mod tests { PathEl::CurveTo((2.0, 2.0).into(), (1.0, 1.0).into(), (0.0, 0.0).into()), PathEl::ClosePath, ], - ) + ); } #[test] @@ -1799,7 +1799,7 @@ mod tests { PathEl::CurveTo((2.0, 2.0).into(), (1.0, 1.0).into(), (0.0, 0.0).into()), PathEl::ClosePath, ], - ) + ); } #[test] @@ -1819,7 +1819,7 @@ mod tests { PathEl::LineTo((0.0, 0.0).into()), // ... does NOT become implied PathEl::ClosePath, ], - ) + ); } #[test] @@ -1837,7 +1837,7 @@ mod tests { PathEl::QuadTo((1.0, 1.0).into(), (0.0, 0.0).into()), PathEl::ClosePath, ], - ) + ); } #[test] @@ -1855,7 +1855,7 @@ mod tests { PathEl::QuadTo((1.0, 1.0).into(), (0.0, 0.0).into()), PathEl::ClosePath, ], - ) + ); } #[test] @@ -1873,12 +1873,12 @@ mod tests { PathEl::LineTo((0.0, 0.0).into()), // ... does NOT become implied PathEl::ClosePath, ], - ) + ); } #[test] fn test_reverse_empty() { - reverse_test_helper(vec![], vec![]) + reverse_test_helper(vec![], vec![]); } #[test] @@ -1886,7 +1886,7 @@ mod tests { reverse_test_helper( vec![PathEl::MoveTo((0.0, 0.0).into())], vec![PathEl::MoveTo((0.0, 0.0).into())], - ) + ); } #[test] @@ -1894,7 +1894,7 @@ mod tests { reverse_test_helper( vec![PathEl::MoveTo((0.0, 0.0).into()), PathEl::ClosePath], vec![PathEl::MoveTo((0.0, 0.0).into()), PathEl::ClosePath], - ) + ); } #[test] @@ -1908,7 +1908,7 @@ mod tests { PathEl::MoveTo((1.0, 1.0).into()), PathEl::LineTo((0.0, 0.0).into()), ], - ) + ); } #[test] @@ -1922,7 +1922,7 @@ mod tests { PathEl::MoveTo((3.0, 3.0).into()), PathEl::CurveTo((2.0, 2.0).into(), (1.0, 1.0).into(), (0.0, 0.0).into()), ], - ) + ); } #[test] @@ -1938,7 +1938,7 @@ mod tests { PathEl::LineTo((3.0, 3.0).into()), PathEl::CurveTo((2.0, 2.0).into(), (1.0, 1.0).into(), (0.0, 0.0).into()), ], - ) + ); } #[test] @@ -1954,7 +1954,7 @@ mod tests { PathEl::CurveTo((3.0, 3.0).into(), (2.0, 2.0).into(), (1.0, 1.0).into()), PathEl::LineTo((0.0, 0.0).into()), ], - ) + ); } #[test] @@ -1976,7 +1976,7 @@ mod tests { PathEl::LineTo((848.0, 348.0).into()), PathEl::ClosePath, ], - ) + ); } #[test] @@ -1999,7 +1999,7 @@ mod tests { PathEl::LineTo((0.0, 651.0).into()), PathEl::ClosePath, ], - ) + ); } fn reverse_test_helper(contour: Vec, expected: Vec) { diff --git a/src/cubicbez.rs b/src/cubicbez.rs index 1408e616..16fe485c 100644 --- a/src/cubicbez.rs +++ b/src/cubicbez.rs @@ -978,7 +978,7 @@ mod tests { ]; assert_eq!(spline.points().len(), expected.len()); for (got, &wanted) in spline.points().iter().zip(expected.iter()) { - assert!(got.distance(wanted) < 5.0) + assert!(got.distance(wanted) < 5.0); } let spline = c1.approx_spline(5.0); @@ -996,7 +996,7 @@ mod tests { let spline = spline.unwrap(); assert_eq!(spline.points().len(), expected.len()); for (got, &wanted) in spline.points().iter().zip(expected.iter()) { - assert!(got.distance(wanted) < 5.0) + assert!(got.distance(wanted) < 5.0); } } @@ -1057,7 +1057,7 @@ mod tests { Point::new(301.0, 560.0), Point::new(260.0, 560.0) ] - ) + ); } #[test] @@ -1131,6 +1131,6 @@ mod tests { (274.0, 485.95).into(), ]), ] - ) + ); } } diff --git a/src/lib.rs b/src/lib.rs index 3c5563a8..e9e777c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,6 +71,7 @@ #![forbid(unsafe_code)] #![deny(missing_docs, clippy::trivially_copy_pass_by_ref)] #![warn(clippy::doc_markdown, rustdoc::broken_intra_doc_links)] +#![warn(clippy::semicolon_if_nothing_returned)] #![allow( clippy::unreadable_literal, clippy::many_single_char_names, diff --git a/src/mindist.rs b/src/mindist.rs index 360dea56..f8500dcf 100644 --- a/src/mindist.rs +++ b/src/mindist.rs @@ -75,19 +75,19 @@ pub(crate) fn min_dist_param( let dij = D_rk(i, j, bez1, bez2); let dkj = D_rk(0, j, bez1, bez2); if dij < dkj { - at_boundary0on_bez1 = false + at_boundary0on_bez1 = false; } let dkj = D_rk(2 * n, j, bez1, bez2); if dij < dkj { - at_boundary1on_bez1 = false + at_boundary1on_bez1 = false; } let dkj = D_rk(i, 0, bez1, bez2); if dij < dkj { - at_boundary0on_bez2 = false + at_boundary0on_bez2 = false; } let dkj = D_rk(i, 2 * n, bez1, bez2); if dij < dkj { - at_boundary1on_bez2 = false + at_boundary1on_bez2 = false; } } } @@ -160,7 +160,7 @@ fn S(u: f64, v: f64, bez1: &[Vec2], bez2: &[Vec2]) -> f64 { for r in 0..=2 * n { for k in 0..=2 * m { summand += - D_rk(r, k, bez1, bez2) * basis_function(2 * n, r, u) * basis_function(2 * m, k, v) + D_rk(r, k, bez1, bez2) * basis_function(2 * n, r, u) * basis_function(2 * m, k, v); } } summand diff --git a/src/param_curve.rs b/src/param_curve.rs index 4faab7b5..99b05ceb 100644 --- a/src/param_curve.rs +++ b/src/param_curve.rs @@ -214,7 +214,7 @@ pub trait ParamCurveExtrema: ParamCurve { fn bounding_box(&self) -> Rect { let mut bbox = Rect::from_points(self.start(), self.end()); for t in self.extrema() { - bbox = bbox.union_pt(self.eval(t)) + bbox = bbox.union_pt(self.eval(t)); } bbox } diff --git a/src/point.rs b/src/point.rs index 3e618b0b..cd4909b4 100644 --- a/src/point.rs +++ b/src/point.rs @@ -223,7 +223,7 @@ impl Add for Point { impl AddAssign for Point { #[inline] fn add_assign(&mut self, other: Vec2) { - *self = Point::new(self.x + other.x, self.y + other.y) + *self = Point::new(self.x + other.x, self.y + other.y); } } @@ -239,7 +239,7 @@ impl Sub for Point { impl SubAssign for Point { #[inline] fn sub_assign(&mut self, other: Vec2) { - *self = Point::new(self.x - other.x, self.y - other.y) + *self = Point::new(self.x - other.x, self.y - other.y); } } @@ -255,7 +255,7 @@ impl Add<(f64, f64)> for Point { impl AddAssign<(f64, f64)> for Point { #[inline] fn add_assign(&mut self, (x, y): (f64, f64)) { - *self = Point::new(self.x + x, self.y + y) + *self = Point::new(self.x + x, self.y + y); } } @@ -271,7 +271,7 @@ impl Sub<(f64, f64)> for Point { impl SubAssign<(f64, f64)> for Point { #[inline] fn sub_assign(&mut self, (x, y): (f64, f64)) { - *self = Point::new(self.x - x, self.y - y) + *self = Point::new(self.x - x, self.y - y); } } diff --git a/src/svg.rs b/src/svg.rs index 37951898..80c219d3 100644 --- a/src/svg.rs +++ b/src/svg.rs @@ -340,7 +340,7 @@ impl<'a> SvgLexer<'a> { if c == b'e' || c == b'E' { let mut c = self.get_byte().ok_or(SvgParseError::Wrong)?; if c == b'-' || c == b'+' { - c = self.get_byte().ok_or(SvgParseError::Wrong)? + c = self.get_byte().ok_or(SvgParseError::Wrong)?; } if c.is_ascii_digit() { return Err(SvgParseError::Wrong);