Skip to content

Commit

Permalink
Auto merge of #295 - nical:clippy, r=kvark
Browse files Browse the repository at this point in the history
Address some clippy lints.

I'd like to be able to run clippy every now and then but right now there is too much noise for me to notice anything. This removes most of the warnings down to a more manageable level.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/295)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Jun 8, 2018
2 parents 2a07641 + b6c59fe commit 54a98c0
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 33 deletions.
10 changes: 5 additions & 5 deletions src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ impl<T, U> TypedPoint2D<T, U> {
#[inline]
pub fn new(x: T, y: T) -> Self {
TypedPoint2D {
x: x,
y: y,
x,
y,
_unit: PhantomData,
}
}
Expand Down Expand Up @@ -455,9 +455,9 @@ impl<T: Copy, U> TypedPoint3D<T, U> {
#[inline]
pub fn new(x: T, y: T, z: T) -> Self {
TypedPoint3D {
x: x,
y: y,
z: z,
x,
y,
z,
_unit: PhantomData,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ impl<T, U> TypedRect<T, U> {
/// Constructor.
pub fn new(origin: TypedPoint2D<T, U>, size: TypedSize2D<T, U>) -> Self {
TypedRect {
origin: origin,
size: size,
origin,
size,
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/side_offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ impl<T: Copy, U> TypedSideOffsets2D<T, U> {
/// Constructor taking a scalar for each side.
pub fn new(top: T, right: T, bottom: T, left: T) -> Self {
TypedSideOffsets2D {
top: top,
right: right,
bottom: bottom,
left: left,
top,
right,
bottom,
left,
_unit: PhantomData,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ impl<T, U> TypedSize2D<T, U> {
/// Constructor taking scalar values.
pub fn new(width: T, height: T) -> Self {
TypedSize2D {
width: width,
height: height,
width,
height,
_unit: PhantomData,
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/transform2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![cfg_attr(feature = "cargo-clippy", allow(just_underscores_and_digits))]

use super::{UnknownUnit, Angle};
use num::{One, Zero};
use point::TypedPoint2D;
Expand Down Expand Up @@ -46,19 +48,19 @@ impl<T: Copy, Src, Dst> TypedTransform2D<T, Src, Dst> {
/// Create a transform specifying its matrix elements in row-major order.
pub fn row_major(m11: T, m12: T, m21: T, m22: T, m31: T, m32: T) -> Self {
TypedTransform2D {
m11: m11, m12: m12,
m21: m21, m22: m22,
m31: m31, m32: m32,
m11, m12,
m21, m22,
m31, m32,
_unit: PhantomData,
}
}

/// Create a transform specifying its matrix elements in column-major order.
pub fn column_major(m11: T, m21: T, m31: T, m12: T, m22: T, m32: T) -> Self {
TypedTransform2D {
m11: m11, m12: m12,
m21: m21, m22: m22,
m31: m31, m32: m32,
m11, m12,
m21, m22,
m31, m32,
_unit: PhantomData,
}
}
Expand Down
20 changes: 12 additions & 8 deletions src/transform3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![cfg_attr(feature = "cargo-clippy", allow(just_underscores_and_digits))]

use super::{UnknownUnit, Angle};
use approxeq::ApproxEq;
use homogen::HomogeneousVector;
Expand Down Expand Up @@ -51,17 +53,18 @@ impl<T, Src, Dst> TypedTransform3D<T, Src, Dst> {
/// For example, the translation terms m41, m42, m43 on the last row with the
/// row-major convention) are the 13rd, 14th and 15th parameters.
#[inline]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn row_major(
m11: T, m12: T, m13: T, m14: T,
m21: T, m22: T, m23: T, m24: T,
m31: T, m32: T, m33: T, m34: T,
m41: T, m42: T, m43: T, m44: T)
-> Self {
TypedTransform3D {
m11: m11, m12: m12, m13: m13, m14: m14,
m21: m21, m22: m22, m23: m23, m24: m24,
m31: m31, m32: m32, m33: m33, m34: m34,
m41: m41, m42: m42, m43: m43, m44: m44,
m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
m41, m42, m43, m44,
_unit: PhantomData,
}
}
Expand All @@ -71,17 +74,18 @@ impl<T, Src, Dst> TypedTransform3D<T, Src, Dst> {
/// For example, the translation terms m41, m42, m43 on the last column with the
/// column-major convention) are the 4th, 8th and 12nd parameters.
#[inline]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn column_major(
m11: T, m21: T, m31: T, m41: T,
m12: T, m22: T, m32: T, m42: T,
m13: T, m23: T, m33: T, m43: T,
m14: T, m24: T, m34: T, m44: T)
-> Self {
TypedTransform3D {
m11: m11, m12: m12, m13: m13, m14: m14,
m21: m21, m22: m22, m23: m23, m24: m24,
m31: m31, m32: m32, m33: m33, m34: m34,
m41: m41, m42: m42, m43: m43, m44: m44,
m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
m41, m42, m43, m44,
_unit: PhantomData,
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/trig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ macro_rules! trig {
/// Note that it does not deal with the case where both x and y are 0.
#[inline]
fn fast_atan2(y: $ty, x: $ty) -> $ty {
// This macro is used with f32 and f64 and clippy warns about the extra
// precision with f32.
#![cfg_attr(feature = "cargo-clippy", allow(excessive_precision))]

// See https://math.stackexchange.com/questions/1098487/atan2-faster-approximation#1105038
use core::$ty::consts;
let x_abs = x.abs();
let y_abs = y.abs();
let a = x_abs.min(y_abs) / x_abs.max(y_abs);
let s = a * a;
let mut result = ((-0.0464964749 * s + 0.15931422) * s - 0.327622764) * s * a + a;
let mut result = ((-0.046_496_474_9 * s + 0.159_314_22) * s - 0.327_622_764) * s * a + a;
if y_abs > x_abs {
result = consts::FRAC_PI_2 - result;
}
Expand Down
10 changes: 5 additions & 5 deletions src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ impl<T, U> TypedVector2D<T, U> {
#[inline]
pub fn new(x: T, y: T) -> Self {
TypedVector2D {
x: x,
y: y,
x,
y,
_unit: PhantomData,
}
}
Expand Down Expand Up @@ -479,9 +479,9 @@ impl<T, U> TypedVector3D<T, U> {
#[inline]
pub fn new(x: T, y: T, z: T) -> Self {
TypedVector3D {
x: x,
y: y,
z: z,
x,
y,
z,
_unit: PhantomData,
}
}
Expand Down

0 comments on commit 54a98c0

Please sign in to comment.