Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: Fix semicolon_if_nothing_returned lints, enable it. #341

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/cubic_arclen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
44 changes: 22 additions & 22 deletions src/bezpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -822,7 +822,7 @@ impl<I: Iterator<Item = PathEl>> Segments<I> {
if let Some(bb) = bbox {
bbox = Some(bb.union(seg_bb));
} else {
bbox = Some(seg_bb)
bbox = Some(seg_bb);
}
}
bbox.unwrap_or_default()
Expand Down Expand Up @@ -1681,7 +1681,7 @@ mod tests {
PathEl::ClosePath,
PathEl::MoveTo((4.0, 4.0).into()),
],
)
);
}

// The following are direct port of fonttools'
Expand All @@ -1707,7 +1707,7 @@ mod tests {
PathEl::LineTo((0.0, 0.0).into()), // closing line NOT implied
PathEl::ClosePath,
],
)
);
}

#[test]
Expand All @@ -1727,7 +1727,7 @@ mod tests {
PathEl::LineTo((0.0, 0.0).into()), // closing line NOT implied
PathEl::ClosePath,
],
)
);
}

#[test]
Expand All @@ -1747,7 +1747,7 @@ mod tests {
PathEl::LineTo((0.0, 0.0).into()),
PathEl::ClosePath,
],
)
);
}

#[test]
Expand All @@ -1763,7 +1763,7 @@ mod tests {
PathEl::LineTo((0.0, 0.0).into()), // closing line NOT implied
PathEl::ClosePath,
],
)
);
}

#[test]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -1819,7 +1819,7 @@ mod tests {
PathEl::LineTo((0.0, 0.0).into()), // ... does NOT become implied
PathEl::ClosePath,
],
)
);
}

#[test]
Expand All @@ -1837,7 +1837,7 @@ mod tests {
PathEl::QuadTo((1.0, 1.0).into(), (0.0, 0.0).into()),
PathEl::ClosePath,
],
)
);
}

#[test]
Expand All @@ -1855,7 +1855,7 @@ mod tests {
PathEl::QuadTo((1.0, 1.0).into(), (0.0, 0.0).into()),
PathEl::ClosePath,
],
)
);
}

#[test]
Expand All @@ -1873,28 +1873,28 @@ 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]
fn test_reverse_single_point() {
reverse_test_helper(
vec![PathEl::MoveTo((0.0, 0.0).into())],
vec![PathEl::MoveTo((0.0, 0.0).into())],
)
);
}

#[test]
fn test_reverse_single_point_closed() {
reverse_test_helper(
vec![PathEl::MoveTo((0.0, 0.0).into()), PathEl::ClosePath],
vec![PathEl::MoveTo((0.0, 0.0).into()), PathEl::ClosePath],
)
);
}

#[test]
Expand All @@ -1908,7 +1908,7 @@ mod tests {
PathEl::MoveTo((1.0, 1.0).into()),
PathEl::LineTo((0.0, 0.0).into()),
],
)
);
}

#[test]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -1976,7 +1976,7 @@ mod tests {
PathEl::LineTo((848.0, 348.0).into()),
PathEl::ClosePath,
],
)
);
}

#[test]
Expand All @@ -1999,7 +1999,7 @@ mod tests {
PathEl::LineTo((0.0, 651.0).into()),
PathEl::ClosePath,
],
)
);
}

fn reverse_test_helper(contour: Vec<PathEl>, expected: Vec<PathEl>) {
Expand Down
8 changes: 4 additions & 4 deletions src/cubicbez.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -1057,7 +1057,7 @@ mod tests {
Point::new(301.0, 560.0),
Point::new(260.0, 560.0)
]
)
);
}

#[test]
Expand Down Expand Up @@ -1131,6 +1131,6 @@ mod tests {
(274.0, 485.95).into(),
]),
]
)
);
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/mindist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/param_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl Add<Vec2> for Point {
impl AddAssign<Vec2> 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);
}
}

Expand All @@ -239,7 +239,7 @@ impl Sub<Vec2> for Point {
impl SubAssign<Vec2> 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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading