Fix/silence various clippy warnings.

This commit is contained in:
Nathan Vegdahl 2019-08-01 14:18:26 +09:00
parent ecbdf5d609
commit c753890bb0
10 changed files with 23 additions and 17 deletions

View File

@ -64,7 +64,7 @@ impl<'a> BVH4<'a> {
where
F: 'b + Fn(&T) -> &'b [BBox],
{
if objects.len() == 0 {
if objects.is_empty() {
BVH4 {
root: None,
depth: 0,
@ -116,8 +116,8 @@ impl<'a> BVH4<'a> {
let mut stack_ptr = 1;
while stack_ptr > 0 {
match node_stack[stack_ptr] {
&BVH4Node::Internal {
match *node_stack[stack_ptr] {
BVH4Node::Internal {
bounds,
children,
traversal_code,
@ -143,7 +143,7 @@ impl<'a> BVH4<'a> {
rays.max_t(ray_idx),
)
};
all_hits = all_hits | hits;
all_hits |= hits;
hits
}
});
@ -168,7 +168,7 @@ impl<'a> BVH4<'a> {
}
}
&BVH4Node::Leaf { object_range } => {
BVH4Node::Leaf { object_range } => {
// Do the ray tests.
obj_ray_test(object_range.0..object_range.1, rays, ray_stack);
@ -191,12 +191,12 @@ impl<'a> BVH4<'a> {
) -> usize {
let mut node_count = 0;
match node {
match *node {
// Create internal node
&BVHBaseNode::Internal {
bounds_range: _,
BVHBaseNode::Internal {
children_indices,
split_axis,
..
} => {
let child_l = &base.nodes[children_indices.0];
let child_r = &base.nodes[children_indices.1];
@ -274,7 +274,7 @@ impl<'a> BVH4<'a> {
let bounds_len = children
.iter()
.map(|c| {
if let &Some(n) = c {
if let Some(n) = *c {
let len = n.bounds_range().1 - n.bounds_range().0;
debug_assert!(len >= 1);
len
@ -345,7 +345,7 @@ impl<'a> BVH4<'a> {
}
// Create internal node
&BVHBaseNode::Leaf { object_range, .. } => {
BVHBaseNode::Leaf { object_range, .. } => {
unsafe {
*fill_node.as_mut_ptr() = BVH4Node::Leaf {
object_range: object_range,

View File

@ -11,7 +11,7 @@ use crate::{
use glam::{Vec4, Vec4Mask};
const BBOX_MAXT_ADJUST: f32 = 1.00000024;
const BBOX_MAXT_ADJUST: f32 = 1.000_000_24;
/// A SIMD set of 4 3D axis-aligned bounding boxes.
#[derive(Debug, Copy, Clone)]

View File

@ -337,8 +337,8 @@ impl Lerp for Color {
fn plancks_law(temperature: f32, wavelength: f32) -> f32 {
const C: f32 = 299_792_458.0; // Speed of light
const H: f32 = 6.62607015e-34; // Planck constant
const KB: f32 = 1.38064852e-23; // Boltzmann constant
const H: f32 = 6.626_070_15e-34; // Planck constant
const KB: f32 = 1.380_648_52e-23; // Boltzmann constant
// At 400 kelvin and below, the spectrum is black anyway,
// but the equations become numerically unstable somewhere

View File

@ -10,6 +10,7 @@
#![allow(clippy::cast_lossless)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::excessive_precision)]
#![allow(clippy::transmute_ptr_to_ptr)]
extern crate lazy_static;
@ -57,7 +58,7 @@ use crate::{
const VERSION: &str = env!("CARGO_PKG_VERSION");
#[allow(clippy::cyclomatic_complexity)]
#[allow(clippy::cognitive_complexity)]
fn main() {
let mut t = Timer::new();

View File

@ -580,7 +580,7 @@ pub fn make_transform_format_error(byte_offset: usize) -> PsyParseError {
}
pub fn parse_color(contents: &str) -> Result<Color, PsyParseError> {
let items: Vec<_> = contents.split(",").map(|s| s.trim()).collect();
let items: Vec<_> = contents.split(',').map(|s| s.trim()).collect();
if items.len() != 2 {
return Err(PsyParseError::UnknownError(0));
}

View File

@ -1,6 +1,7 @@
#![allow(clippy::redundant_field_names)]
#![allow(clippy::needless_return)]
#![allow(clippy::mut_from_ref)]
#![allow(clippy::transmute_ptr_to_ptr)]
use std::{
cell::{Cell, RefCell},

View File

@ -51,6 +51,7 @@ pub fn aces_to_spectrum_p4(lambdas: Vec4, rgb: (f32, f32, f32)) -> Vec4 {
// Core functions, specialized above for specific color spaces.
#[inline(always)]
#[allow(clippy::many_single_char_names)]
fn small_rgb_to_spectrum_p4(
table: &[[(f32, f32, f32); 2]],
table_res: usize,

View File

@ -2,7 +2,7 @@
// clippy warnings that stem from the C code.
#![allow(clippy::needless_return)]
#![allow(clippy::useless_let_if_seq)]
#![allow(clippy::cyclomatic_complexity)]
#![allow(clippy::cognitive_complexity)]
pub mod jakob;
pub mod meng;

View File

@ -2,7 +2,7 @@
// clippy warnings that stem from the C code.
#![allow(clippy::needless_return)]
#![allow(clippy::useless_let_if_seq)]
#![allow(clippy::cyclomatic_complexity)]
#![allow(clippy::cognitive_complexity)]
use std::f32;

View File

@ -13,6 +13,8 @@
//! All integers in the range `[-8192, 8192]` can be represented exactly in the
//! largest value.
#![allow(clippy::cast_lossless)]
use crate::{fiddle_exp2, fiddle_log2};
/// Largest representable number.
@ -27,6 +29,7 @@ pub const MIN: f32 = -274_844_352_512.0;
/// Smallest representable positive number.
///
/// This is the number with the smallest possible magnitude (aside from zero).
#[allow(clippy::excessive_precision)]
pub const MIN_POSITIVE: f32 = 0.000_000_000_003_637_978_807_091_713;
/// Difference between 1.0 and the next largest representable number.