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 fixes #781

Merged
merged 2 commits into from Oct 26, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/geometry/isometry_ops.rs
Expand Up @@ -149,6 +149,7 @@ isometry_binop_impl_all!(
[ref ref] => {
let shift = self.rotation.transform_vector(&rhs.translation.vector);

#[allow(clippy::suspicious_arithmetic_impl)]
Isometry::from_parts(Translation::from(&self.translation.vector + shift),
self.rotation.clone() * rhs.rotation.clone()) // FIXME: too bad we have to clone.
};
Expand All @@ -157,10 +158,10 @@ isometry_binop_impl_all!(
isometry_binop_impl_all!(
Div, div;
self: Isometry<N, D, R>, rhs: Isometry<N, D, R>, Output = Isometry<N, D, R>;
[val val] => self * rhs.inverse();
[ref val] => self * rhs.inverse();
[val ref] => self * rhs.inverse();
[ref ref] => self * rhs.inverse();
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
);

// Isometry ×= Translation
Expand Down Expand Up @@ -289,6 +290,7 @@ isometry_binop_impl_all!(
[ref val] => self * &right;
[val ref] => &self * right;
[ref ref] => {
#[allow(clippy::suspicious_arithmetic_impl)]
let new_tr = &self.translation.vector + self.rotation.transform_vector(&right.vector);
Isometry::from_parts(Translation::from(new_tr), self.rotation.clone())
};
Expand Down Expand Up @@ -427,10 +429,10 @@ isometry_from_composition_impl_all!(
self: Rotation<N, D>, right: Isometry<N, D, Rotation<N, D>>,
Output = Isometry<N, D, Rotation<N, D>>;
// FIXME: don't call inverse explicitly?
[val val] => self * right.inverse();
[ref val] => self * right.inverse();
[val ref] => self * right.inverse();
[ref ref] => self * right.inverse();
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
);

// Isometry × UnitQuaternion
Expand Down Expand Up @@ -479,10 +481,10 @@ isometry_from_composition_impl_all!(
self: UnitQuaternion<N>, right: Isometry<N, U3, UnitQuaternion<N>>,
Output = Isometry<N, U3, UnitQuaternion<N>>;
// FIXME: don't call inverse explicitly?
[val val] => self * right.inverse();
[ref val] => self * right.inverse();
[val ref] => self * right.inverse();
[ref ref] => self * right.inverse();
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
);

// Translation × Rotation
Expand Down
1 change: 1 addition & 0 deletions src/geometry/quaternion.rs
Expand Up @@ -389,6 +389,7 @@ where
/// ```
#[inline]
pub fn outer(&self, other: &Self) -> Self {
#[allow(clippy::eq_op)]
(self * other - other * self).half()
}

Expand Down
124 changes: 56 additions & 68 deletions src/geometry/quaternion_ops.rs
Expand Up @@ -121,11 +121,10 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Add, add;
(U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
Quaternion::from(self.coords + rhs.coords);
);
Add, add;
(U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
Quaternion::from(self.coords + rhs.coords); );

// Quaternion - Quaternion
quaternion_op_impl!(
Expand All @@ -150,11 +149,10 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Sub, sub;
(U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
Quaternion::from(self.coords - rhs.coords);
);
Sub, sub;
(U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
Quaternion::from(self.coords - rhs.coords); );

// Quaternion × Quaternion
quaternion_op_impl!(
Expand Down Expand Up @@ -183,11 +181,10 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Mul, mul;
(U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
&self * &rhs;
);
Mul, mul;
(U4, U1), (U4, U1);
self: Quaternion<N>, rhs: Quaternion<N>, Output = Quaternion<N>;
&self * &rhs; );

// UnitQuaternion × UnitQuaternion
quaternion_op_impl!(
Expand All @@ -212,18 +209,17 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Mul, mul;
(U4, U1), (U4, U1);
self: UnitQuaternion<N>, rhs: UnitQuaternion<N>, Output = UnitQuaternion<N>;
&self * &rhs;
);
Mul, mul;
(U4, U1), (U4, U1);
self: UnitQuaternion<N>, rhs: UnitQuaternion<N>, Output = UnitQuaternion<N>;
&self * &rhs; );

// UnitQuaternion ÷ UnitQuaternion
quaternion_op_impl!(
Div, div;
(U4, U1), (U4, U1);
self: &'a UnitQuaternion<N>, rhs: &'b UnitQuaternion<N>, Output = UnitQuaternion<N>;
self * rhs.inverse();
#[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
'a, 'b);

quaternion_op_impl!(
Expand All @@ -241,11 +237,10 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Div, div;
(U4, U1), (U4, U1);
self: UnitQuaternion<N>, rhs: UnitQuaternion<N>, Output = UnitQuaternion<N>;
&self / &rhs;
);
Div, div;
(U4, U1), (U4, U1);
self: UnitQuaternion<N>, rhs: UnitQuaternion<N>, Output = UnitQuaternion<N>;
&self / &rhs; );

// UnitQuaternion × Rotation
quaternion_op_impl!(
Expand Down Expand Up @@ -274,12 +269,11 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Mul, mul;
(U4, U1), (U3, U3);
self: UnitQuaternion<N>, rhs: Rotation<N, U3>,
Output = UnitQuaternion<N> => U3, U3;
self * UnitQuaternion::<N>::from_rotation_matrix(&rhs);
);
Mul, mul;
(U4, U1), (U3, U3);
self: UnitQuaternion<N>, rhs: Rotation<N, U3>,
Output = UnitQuaternion<N> => U3, U3;
self * UnitQuaternion::<N>::from_rotation_matrix(&rhs); );

// UnitQuaternion ÷ Rotation
quaternion_op_impl!(
Expand Down Expand Up @@ -308,12 +302,11 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Div, div;
(U4, U1), (U3, U3);
self: UnitQuaternion<N>, rhs: Rotation<N, U3>,
Output = UnitQuaternion<N> => U3, U3;
self / UnitQuaternion::<N>::from_rotation_matrix(&rhs);
);
Div, div;
(U4, U1), (U3, U3);
self: UnitQuaternion<N>, rhs: Rotation<N, U3>,
Output = UnitQuaternion<N> => U3, U3;
self / UnitQuaternion::<N>::from_rotation_matrix(&rhs); );

// Rotation × UnitQuaternion
quaternion_op_impl!(
Expand Down Expand Up @@ -342,12 +335,11 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Mul, mul;
(U3, U3), (U4, U1);
self: Rotation<N, U3>, rhs: UnitQuaternion<N>,
Output = UnitQuaternion<N> => U3, U3;
UnitQuaternion::<N>::from_rotation_matrix(&self) * rhs;
);
Mul, mul;
(U3, U3), (U4, U1);
self: Rotation<N, U3>, rhs: UnitQuaternion<N>,
Output = UnitQuaternion<N> => U3, U3;
UnitQuaternion::<N>::from_rotation_matrix(&self) * rhs; );

// Rotation ÷ UnitQuaternion
quaternion_op_impl!(
Expand Down Expand Up @@ -376,12 +368,11 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Div, div;
(U3, U3), (U4, U1);
self: Rotation<N, U3>, rhs: UnitQuaternion<N>,
Output = UnitQuaternion<N> => U3, U3;
UnitQuaternion::<N>::from_rotation_matrix(&self) / rhs;
);
Div, div;
(U3, U3), (U4, U1);
self: Rotation<N, U3>, rhs: UnitQuaternion<N>,
Output = UnitQuaternion<N> => U3, U3;
UnitQuaternion::<N>::from_rotation_matrix(&self) / rhs; );

// UnitQuaternion × Vector
quaternion_op_impl!(
Expand Down Expand Up @@ -415,12 +406,11 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Mul, mul;
(U4, U1), (U3, U1) for SB: Storage<N, U3> ;
self: UnitQuaternion<N>, rhs: Vector<N, U3, SB>,
Output = Vector3<N> => U3, U4;
&self * &rhs;
);
Mul, mul;
(U4, U1), (U3, U1) for SB: Storage<N, U3> ;
self: UnitQuaternion<N>, rhs: Vector<N, U3, SB>,
Output = Vector3<N> => U3, U4;
&self * &rhs; );

// UnitQuaternion × Point
quaternion_op_impl!(
Expand Down Expand Up @@ -448,12 +438,11 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Mul, mul;
(U4, U1), (U3, U1);
self: UnitQuaternion<N>, rhs: Point3<N>,
Output = Point3<N> => U3, U4;
Point3::from(self * rhs.coords);
);
Mul, mul;
(U4, U1), (U3, U1);
self: UnitQuaternion<N>, rhs: Point3<N>,
Output = Point3<N> => U3, U4;
Point3::from(self * rhs.coords); );

// UnitQuaternion × Unit<Vector>
quaternion_op_impl!(
Expand Down Expand Up @@ -481,12 +470,11 @@ quaternion_op_impl!(
'b);

quaternion_op_impl!(
Mul, mul;
(U4, U1), (U3, U1) for SB: Storage<N, U3> ;
self: UnitQuaternion<N>, rhs: Unit<Vector<N, U3, SB>>,
Output = Unit<Vector3<N>> => U3, U4;
Unit::new_unchecked(self * rhs.into_inner());
);
Mul, mul;
(U4, U1), (U3, U1) for SB: Storage<N, U3> ;
self: UnitQuaternion<N>, rhs: Unit<Vector<N, U3, SB>>,
Output = Unit<Vector3<N>> => U3, U4;
Unit::new_unchecked(self * rhs.into_inner()); );

macro_rules! scalar_op_impl(
($($Op: ident, $op: ident, $OpAssign: ident, $op_assign: ident);* $(;)*) => {$(
Expand Down
16 changes: 8 additions & 8 deletions src/geometry/rotation_ops.rs
Expand Up @@ -59,10 +59,10 @@ md_impl_all!(
Div, div;
(D, D), (D, D) for D: DimName;
self: Rotation<N, D>, right: Rotation<N, D>, Output = Rotation<N, D>;
[val val] => self * right.inverse();
[ref val] => self * right.inverse();
[val ref] => self * right.inverse();
[ref ref] => self * right.inverse();
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
);

// Rotation × Matrix
Expand Down Expand Up @@ -98,10 +98,10 @@ md_impl_all!(
where DefaultAllocator: Allocator<N, R1, D2>
where ShapeConstraint: AreMultipliable<R1, C1, D2, D2>;
self: Matrix<N, R1, C1, SA>, right: Rotation<N, D2>, Output = MatrixMN<N, R1, D2>;
[val val] => self * right.inverse();
[ref val] => self * right.inverse();
[val ref] => self * right.inverse();
[ref ref] => self * right.inverse();
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * right.inverse() };
);

// Rotation × Point
Expand Down