Skip to content

Commit 9e723ee

Browse files
lints: Remove unnecessary qualifications. (#203)
* lints: Remove unnecessary qualifications. * Remove unused code in wops.rs This code is now triggering Rust compiler warnings and breaking CI. * partitioning: Mark code as only for parallel + std This code triggers warnings (and errors in CI) because it isn't used when the `parallel` feature isn't enabled, so correctly mark it as needing `all(feature = "parallel", feature = "std")` * Remove unused import of `na::SimdPartialOrd`
1 parent 5f9bfb0 commit 9e723ee

4 files changed

Lines changed: 10 additions & 239 deletions

File tree

src/partitioning/visitor.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use crate::math::{Real, SimdBool, SimdReal, SIMD_WIDTH};
22

3-
#[cfg(feature = "std")]
4-
use crate::partitioning::qbvh::QbvhNode;
5-
#[cfg(feature = "std")]
6-
use crate::partitioning::SimdNodeIndex;
3+
#[cfg(all(feature = "std", feature = "parallel"))]
4+
use crate::partitioning::{qbvh::QbvhNode, SimdNodeIndex};
75

86
/// The next action to be taken by a BVH traversal algorithm after having visited a node with some data.
97
pub enum SimdBestFirstVisitStatus<Res> {
@@ -119,7 +117,7 @@ pub trait SimdSimultaneousVisitor<T1, T2, SimdBV> {
119117
*/
120118

121119
/// Trait implemented by visitor called during the parallel traversal of a spatial partitioning data structure.
122-
#[cfg(feature = "std")]
120+
#[cfg(all(feature = "std", feature = "parallel"))]
123121
pub trait ParallelSimdVisitor<LeafData>: Sync {
124122
/// Execute an operation on the content of a node of the spatial partitioning structure.
125123
///
@@ -133,7 +131,7 @@ pub trait ParallelSimdVisitor<LeafData>: Sync {
133131
) -> SimdVisitStatus;
134132
}
135133

136-
#[cfg(feature = "std")]
134+
#[cfg(all(feature = "std", feature = "parallel"))]
137135
impl<F, LeafData> ParallelSimdVisitor<LeafData> for F
138136
where
139137
F: Sync + Fn(&QbvhNode, Option<[Option<&LeafData>; SIMD_WIDTH]>) -> SimdVisitStatus,
@@ -150,8 +148,7 @@ where
150148

151149
/// Trait implemented by visitor called during a parallel simultaneous spatial partitioning
152150
/// data structure traversal.
153-
#[cfg(feature = "parallel")]
154-
#[cfg(feature = "std")]
151+
#[cfg(all(feature = "std", feature = "parallel"))]
155152
pub trait ParallelSimdSimultaneousVisitor<LeafData1, LeafData2>: Sync {
156153
/// Visitor state data that will be passed down the recursion.
157154
type Data: Copy + Sync + Default;

src/shape/trimesh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub enum TopologyError {
3737
},
3838
}
3939

40-
impl std::fmt::Display for TopologyError {
41-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40+
impl fmt::Display for TopologyError {
41+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4242
match self {
4343
Self::BadTriangle(fid) => {
4444
f.pad(&format!("the triangle {fid} has at least two identical vertices."))

src/transformation/convex_hull3/initial_mesh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn try_get_initial_mesh(
4646

4747
#[cfg(not(feature = "improved_fixed_point_support"))]
4848
{
49-
let cov_mat = crate::utils::cov(normalized_points);
49+
let cov_mat = utils::cov(normalized_points);
5050
let eig = cov_mat.symmetric_eigen();
5151
eigvec = eig.eigenvectors;
5252
eigval = eig.eigenvalues;
@@ -140,7 +140,7 @@ pub fn try_get_initial_mesh(
140140
3 => {
141141
// The hull is a polyhedron.
142142
// Find a initial triangle lying on the principal halfspace…
143-
let center = crate::utils::center(normalized_points);
143+
let center = utils::center(normalized_points);
144144

145145
for point in normalized_points.iter_mut() {
146146
*point = Point3::from((*point - center) / eigval.amax());

src/utils/wops.rs

Lines changed: 1 addition & 227 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
33
use crate::math::Real;
44
use crate::simd::{SimdBool, SimdReal};
5-
use na::{Matrix3, Point2, Point3, Scalar, SimdRealField, Vector2, Vector3};
5+
use na::{Scalar, SimdRealField, Vector2, Vector3};
66
use simba::simd::SimdValue;
77

8-
#[cfg(feature = "simd-is-enabled")]
9-
use na::SimdPartialOrd;
10-
118
/// Conditionally swaps each lanes of `a` with those of `b`.
129
///
1310
/// For each `i in [0..SIMD_WIDTH[`, if `do_swap.extract(i)` is `true` then
@@ -72,36 +69,6 @@ impl WSign<SimdReal> for SimdReal {
7269
}
7370
}
7471

75-
pub(crate) trait WComponent: Sized {
76-
type Element;
77-
78-
fn min_component(self) -> Self::Element;
79-
fn max_component(self) -> Self::Element;
80-
}
81-
82-
impl WComponent for Real {
83-
type Element = Real;
84-
85-
fn min_component(self) -> Self::Element {
86-
self
87-
}
88-
fn max_component(self) -> Self::Element {
89-
self
90-
}
91-
}
92-
93-
#[cfg(feature = "simd-is-enabled")]
94-
impl WComponent for SimdReal {
95-
type Element = Real;
96-
97-
fn min_component(self) -> Self::Element {
98-
self.simd_horizontal_min()
99-
}
100-
fn max_component(self) -> Self::Element {
101-
self.simd_horizontal_max()
102-
}
103-
}
104-
10572
/// Trait to compute the orthonormal basis of a vector.
10673
pub trait WBasis: Sized {
10774
/// The type of the array of orthonormal vectors.
@@ -137,118 +104,6 @@ impl<N: SimdRealField + Copy + WSign<N>> WBasis for Vector3<N> {
137104
}
138105
}
139106

140-
pub(crate) trait WVec: Sized {
141-
type Element;
142-
143-
fn horizontal_inf(&self) -> Self::Element;
144-
fn horizontal_sup(&self) -> Self::Element;
145-
}
146-
147-
impl<N: Scalar + Copy + WComponent> WVec for Vector2<N>
148-
where
149-
N::Element: Scalar,
150-
{
151-
type Element = Vector2<N::Element>;
152-
153-
fn horizontal_inf(&self) -> Self::Element {
154-
Vector2::new(self.x.min_component(), self.y.min_component())
155-
}
156-
157-
fn horizontal_sup(&self) -> Self::Element {
158-
Vector2::new(self.x.max_component(), self.y.max_component())
159-
}
160-
}
161-
162-
impl<N: Scalar + Copy + WComponent> WVec for Point2<N>
163-
where
164-
N::Element: Scalar,
165-
{
166-
type Element = Point2<N::Element>;
167-
168-
fn horizontal_inf(&self) -> Self::Element {
169-
Point2::new(self.x.min_component(), self.y.min_component())
170-
}
171-
172-
fn horizontal_sup(&self) -> Self::Element {
173-
Point2::new(self.x.max_component(), self.y.max_component())
174-
}
175-
}
176-
177-
impl<N: Scalar + Copy + WComponent> WVec for Vector3<N>
178-
where
179-
N::Element: Scalar,
180-
{
181-
type Element = Vector3<N::Element>;
182-
183-
fn horizontal_inf(&self) -> Self::Element {
184-
Vector3::new(
185-
self.x.min_component(),
186-
self.y.min_component(),
187-
self.z.min_component(),
188-
)
189-
}
190-
191-
fn horizontal_sup(&self) -> Self::Element {
192-
Vector3::new(
193-
self.x.max_component(),
194-
self.y.max_component(),
195-
self.z.max_component(),
196-
)
197-
}
198-
}
199-
200-
impl<N: Scalar + Copy + WComponent> WVec for Point3<N>
201-
where
202-
N::Element: Scalar,
203-
{
204-
type Element = Point3<N::Element>;
205-
206-
fn horizontal_inf(&self) -> Self::Element {
207-
Point3::new(
208-
self.x.min_component(),
209-
self.y.min_component(),
210-
self.z.min_component(),
211-
)
212-
}
213-
214-
fn horizontal_sup(&self) -> Self::Element {
215-
Point3::new(
216-
self.x.max_component(),
217-
self.y.max_component(),
218-
self.z.max_component(),
219-
)
220-
}
221-
}
222-
223-
pub(crate) trait WCrossMatrix: Sized {
224-
type CrossMat;
225-
226-
fn gcross_matrix(self) -> Self::CrossMat;
227-
}
228-
229-
impl WCrossMatrix for Vector3<Real> {
230-
type CrossMat = Matrix3<Real>;
231-
232-
#[inline]
233-
#[rustfmt::skip]
234-
fn gcross_matrix(self) -> Self::CrossMat {
235-
Matrix3::new(
236-
0.0, -self.z, self.y,
237-
self.z, 0.0, -self.x,
238-
-self.y, self.x, 0.0,
239-
)
240-
}
241-
}
242-
243-
impl WCrossMatrix for Vector2<Real> {
244-
type CrossMat = Vector2<Real>;
245-
246-
#[inline]
247-
fn gcross_matrix(self) -> Self::CrossMat {
248-
Vector2::new(-self.y, self.x)
249-
}
250-
}
251-
252107
pub(crate) trait WCross<Rhs>: Sized {
253108
type Result;
254109
fn gcross(&self, rhs: Rhs) -> Self::Result;
@@ -278,60 +133,6 @@ impl WCross<Vector2<Real>> for Real {
278133
}
279134
}
280135

281-
pub(crate) trait WDot<Rhs>: Sized {
282-
type Result;
283-
fn gdot(&self, rhs: Rhs) -> Self::Result;
284-
}
285-
286-
impl WDot<Vector3<Real>> for Vector3<Real> {
287-
type Result = Real;
288-
289-
fn gdot(&self, rhs: Vector3<Real>) -> Self::Result {
290-
self.x * rhs.x + self.y * rhs.y + self.z * rhs.z
291-
}
292-
}
293-
294-
impl WDot<Vector2<Real>> for Vector2<Real> {
295-
type Result = Real;
296-
297-
fn gdot(&self, rhs: Vector2<Real>) -> Self::Result {
298-
self.x * rhs.x + self.y * rhs.y
299-
}
300-
}
301-
302-
impl WDot<Real> for Real {
303-
type Result = Real;
304-
305-
fn gdot(&self, rhs: Real) -> Self::Result {
306-
*self * rhs
307-
}
308-
}
309-
310-
#[cfg(feature = "simd-is-enabled")]
311-
impl WCrossMatrix for Vector3<SimdReal> {
312-
type CrossMat = Matrix3<SimdReal>;
313-
314-
#[inline]
315-
#[rustfmt::skip]
316-
fn gcross_matrix(self) -> Self::CrossMat {
317-
Matrix3::new(
318-
num::zero(), -self.z, self.y,
319-
self.z, num::zero(), -self.x,
320-
-self.y, self.x, num::zero(),
321-
)
322-
}
323-
}
324-
325-
#[cfg(feature = "simd-is-enabled")]
326-
impl WCrossMatrix for Vector2<SimdReal> {
327-
type CrossMat = Vector2<SimdReal>;
328-
329-
#[inline]
330-
fn gcross_matrix(self) -> Self::CrossMat {
331-
Vector2::new(-self.y, self.x)
332-
}
333-
}
334-
335136
#[cfg(feature = "simd-is-enabled")]
336137
impl WCross<Vector3<SimdReal>> for Vector3<SimdReal> {
337138
type Result = Vector3<SimdReal>;
@@ -360,30 +161,3 @@ impl WCross<Vector2<SimdReal>> for Vector2<SimdReal> {
360161
prod.x - prod.y
361162
}
362163
}
363-
364-
#[cfg(feature = "simd-is-enabled")]
365-
impl WDot<Vector3<SimdReal>> for Vector3<SimdReal> {
366-
type Result = SimdReal;
367-
368-
fn gdot(&self, rhs: Vector3<SimdReal>) -> Self::Result {
369-
self.x * rhs.x + self.y * rhs.y + self.z * rhs.z
370-
}
371-
}
372-
373-
#[cfg(feature = "simd-is-enabled")]
374-
impl WDot<Vector2<SimdReal>> for Vector2<SimdReal> {
375-
type Result = SimdReal;
376-
377-
fn gdot(&self, rhs: Vector2<SimdReal>) -> Self::Result {
378-
self.x * rhs.x + self.y * rhs.y
379-
}
380-
}
381-
382-
#[cfg(feature = "simd-is-enabled")]
383-
impl WDot<SimdReal> for SimdReal {
384-
type Result = SimdReal;
385-
386-
fn gdot(&self, rhs: SimdReal) -> Self::Result {
387-
*self * rhs
388-
}
389-
}

0 commit comments

Comments
 (0)