Skip to content

Commit 36d9e8d

Browse files
committed
Fix more Clippy lints
1 parent 59f4df1 commit 36d9e8d

File tree

15 files changed

+40
-21
lines changed

15 files changed

+40
-21
lines changed

examples/aobench/src/intersection/ray_plane.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ impl Intersect<Plane> for RayxN {
5353
}
5454
}
5555

56-
debug_assert!({
56+
#[cfg(debug_assertions)]
57+
{
5758
// Check that the vector and the scalar version produce the same results
5859
// for the same inputs in debug builds
5960
for i in 0..f32xN::lanes() {
@@ -62,8 +63,7 @@ impl Intersect<Plane> for RayxN {
6263
let isect_i = ray_i.intersect(plane, old_isect_i);
6364
assert!(isect_i.almost_eq(&isect.get(i)), "{:?} !~= {:?}\n\nplane: {:?}\n\nold_isect: {:?}\n\nrays: {:?}\n\ni: {:?}\nold_isect_i: {:?}\nray_i: {:?}\n\n", isect_i, isect.get(i), plane, old_isect, self, i, old_isect_i, ray_i);
6465
}
65-
true
66-
});
66+
}
6767

6868
isect
6969
}

examples/aobench/src/intersection/ray_sphere.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ impl Intersect<Sphere> for RayxN {
5959
}
6060
}
6161

62-
debug_assert!({
62+
#[cfg(debug_assertions)]
63+
{
6364
// Check that the vector and the scalar version produce the same results
6465
// for the same inputs in debug builds
6566
for i in 0..f32xN::lanes() {
@@ -68,8 +69,7 @@ impl Intersect<Sphere> for RayxN {
6869
let isect_i = ray_i.intersect(sphere, old_isect_i);
6970
assert!(isect_i.almost_eq(&isect.get(i)), "{:?} !~= {:?}\n\nsphere: {:?}\n\nold_isect: {:?}\n\nrays: {:?}\n\ni: {:?}\nold_isect_i: {:?}\nray_i: {:?}\n\n", isect_i, isect.get(i), sphere, old_isect, self, i, old_isect_i, ray_i);
7071
}
71-
true
72-
});
72+
}
7373

7474
isect
7575
}

examples/aobench/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
clippy::cast_possible_truncation,
1313
clippy::cast_sign_loss,
1414
clippy::identity_op,
15-
clippy::erasing_op
15+
clippy::erasing_op,
16+
clippy::must_use_candidate
1617
)]
1718

1819
pub mod ambient_occlusion;

examples/dot_product/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Vector dot product
22
#![deny(warnings, rust_2018_idioms)]
33
#![feature(custom_inner_attributes)]
4+
#![allow(clippy::must_use_candidate)]
45

56
pub mod scalar;
67
pub mod simd;

examples/fannkuch_redux/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
clippy::many_single_char_names,
77
clippy::cast_possible_truncation,
88
clippy::cast_sign_loss,
9-
clippy::cast_possible_wrap
9+
clippy::cast_possible_wrap,
10+
clippy::must_use_candidate
1011
)]
1112

1213
pub mod scalar;

examples/mandelbrot/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#![allow(
77
clippy::cast_precision_loss,
88
clippy::cast_sign_loss,
9-
clippy::cast_possible_truncation
9+
clippy::cast_possible_truncation,
10+
clippy::must_use_candidate
1011
)]
1112

1213
use rayon::prelude::*;

examples/mandelbrot/src/simd_par.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ pub fn generate(dims: Dimensions, xr: Range, yr: Range) -> Vec<u32> {
145145
});
146146
});
147147

148+
// This is safe, we're transmuting from a more-aligned type to a
149+
// less-aligned one.
150+
#[allow(clippy::unsound_collection_transmute)]
148151
unsafe {
149152
let mut out: Vec<u32> = std::mem::transmute(out);
150-
// This is safe, we're transmuting from a more-aligned type to a
151-
// less-aligned one.
152153
out.set_len(width * height);
153154
out
154155
}

examples/matrix_inverse/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! 4x4 matrix inverse
22
#![feature(custom_inner_attributes)]
33
#![deny(warnings, rust_2018_idioms)]
4+
#![allow(clippy::must_use_candidate)]
45

56
pub mod scalar;
67
pub mod simd;

examples/nbody/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
//!
33
//! [bg]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/nbody.html#nbody
44
#![deny(warnings, rust_2018_idioms)]
5-
#![allow(clippy::similar_names, clippy::excessive_precision)]
5+
#![allow(
6+
clippy::similar_names,
7+
clippy::excessive_precision,
8+
clippy::must_use_candidate
9+
)]
610

711
pub mod scalar;
812
pub mod simd;

examples/options_pricing/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
clippy::cast_precision_loss,
77
clippy::cast_possible_truncation,
88
clippy::cast_possible_wrap,
9+
clippy::must_use_candidate,
910
clippy::too_many_arguments
1011
)]
1112

examples/spectral_norm/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! Spectral Norm
22
#![deny(warnings, rust_2018_idioms)]
33
#![allow(non_snake_case, non_camel_case_types)]
4-
#![allow(clippy::cast_precision_loss)]
4+
#![allow(
5+
clippy::cast_precision_loss,
6+
clippy::must_use_candidate
7+
)]
58

69
pub mod scalar;
710
pub mod simd;

examples/stencil/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
clippy::too_many_arguments,
88
clippy::cast_possible_wrap,
99
clippy::cast_possible_truncation,
10-
clippy::inline_always
10+
clippy::inline_always,
11+
clippy::must_use_candidate
1112
)]
1213

1314
#[cfg(feature = "ispc")]

examples/triangle_xform/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::must_use_candidate)]
2+
13
/// Simple matrix type.
24
/// The memory layout is the same as the one for Direct3D/OpenGL: fourth vector
35
/// represents the translation vector `[x, y, z]`.

src/api/minimal/ptr.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ macro_rules! impl_minimal_p {
6868

6969
/// Extracts the value at `index`.
7070
///
71-
/// # Precondition
71+
/// # Safety
7272
///
7373
/// If `index >= Self::lanes()` the behavior is undefined.
7474
#[inline]
@@ -96,7 +96,7 @@ macro_rules! impl_minimal_p {
9696

9797
/// Returns a new vector where the value at `index` is replaced by `new_value`.
9898
///
99-
/// # Precondition
99+
/// # Safety
100100
///
101101
/// If `index >= Self::lanes()` the behavior is undefined.
102102
#[inline]
@@ -611,7 +611,7 @@ macro_rules! impl_minimal_p {
611611

612612
/// Instantiates a new vector with the values of the `slice`.
613613
///
614-
/// # Precondition
614+
/// # Safety
615615
///
616616
/// If `slice.len() < Self::lanes()` or `&slice[0]` is not aligned
617617
/// to an `align_of::<Self>()` boundary, the behavior is undefined.
@@ -624,7 +624,7 @@ macro_rules! impl_minimal_p {
624624

625625
/// Instantiates a new vector with the values of the `slice`.
626626
///
627-
/// # Precondition
627+
/// # Safety
628628
///
629629
/// If `slice.len() < Self::lanes()` the behavior is undefined.
630630
#[inline]
@@ -827,7 +827,7 @@ macro_rules! impl_minimal_p {
827827

828828
/// Writes the values of the vector to the `slice`.
829829
///
830-
/// # Precondition
830+
/// # Safety
831831
///
832832
/// If `slice.len() < Self::lanes()` or `&slice[0]` is not
833833
/// aligned to an `align_of::<Self>()` boundary, the behavior is
@@ -843,7 +843,7 @@ macro_rules! impl_minimal_p {
843843

844844
/// Writes the values of the vector to the `slice`.
845845
///
846-
/// # Precondition
846+
/// # Safety
847847
///
848848
/// If `slice.len() < Self::lanes()` the behavior is undefined.
849849
#[inline]
@@ -1151,7 +1151,7 @@ macro_rules! impl_minimal_p {
11511151
/// As such, memory acquired directly from allocators or memory
11521152
/// mapped files may be too large to handle with this function.
11531153
///
1154-
/// Consider using wrapping_offset_from instead if these constraints
1154+
/// Consider using `wrapping_offset_from` instead if these constraints
11551155
/// are difficult to satisfy. The only advantage of this method is
11561156
/// that it enables more aggressive compiler optimizations.
11571157
#[inline]

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@
218218
clippy::cast_lossless,
219219
clippy::cast_possible_wrap,
220220
clippy::cast_precision_loss,
221+
// TODO: manually add the `#[must_use]` attribute where appropiate
222+
clippy::must_use_candidate,
221223
// This lint is currently broken for generic code
222224
// See https://github.com/rust-lang/rust-clippy/issues/3410
223225
clippy::use_self,

0 commit comments

Comments
 (0)