Merge branch 'tygyh/Resolve-clippy-error-supressions' into 'master'

Tygyh/resolve clippy error supressions

See merge request veloren/veloren!2675
This commit is contained in:
Joshua Barretto 2021-07-25 15:35:14 +00:00
commit 3ba6abfcb4
14 changed files with 24 additions and 47 deletions

View File

@ -187,7 +187,6 @@ impl MatSegment {
})
}
#[allow(clippy::identity_op)]
pub fn from_vox(dot_vox_data: &DotVoxData, flipped: bool) -> Self {
if let Some(model) = dot_vox_data.models.get(0) {
let palette = dot_vox_data

View File

@ -1,19 +1,17 @@
use vek::{Mat3, Rgb, Rgba, Vec3};
#[inline(always)]
#[allow(clippy::excessive_precision)]
pub fn srgb_to_linear(col: Rgb<f32>) -> Rgb<f32> {
col.map(|c| {
if c <= 0.104 {
c * 0.08677088
} else {
0.012522878 * c + 0.682171111 * c * c + 0.305306011 * c * c * c
0.012522878 * c + 0.682_171_1 * c * c + 0.305_306_02 * c * c * c
}
})
}
#[inline(always)]
#[allow(clippy::excessive_precision)]
pub fn linear_to_srgb(col: Rgb<f32>) -> Rgb<f32> {
col.map(|c| {
if c <= 0.0060 {
@ -22,7 +20,7 @@ pub fn linear_to_srgb(col: Rgb<f32>) -> Rgb<f32> {
let s1 = c.sqrt();
let s2 = s1.sqrt();
let s3 = s2.sqrt();
0.585122381 * s1 + 0.783140355 * s2 - 0.368262736 * s3
0.585_122_4 * s1 + 0.783_140_36 * s2 - 0.368_262_74 * s3
}
})
}

View File

@ -145,8 +145,7 @@ impl<V: RectRasterableVol> VolGrid2d<V> {
}
}
#[allow(clippy::needless_lifetimes)] // TODO: Pending review in #587
pub fn cached<'a>(&'a self) -> CachedVolGrid2d<'a, V> { CachedVolGrid2d::new(self) }
pub fn cached(&self) -> CachedVolGrid2d<V> { CachedVolGrid2d::new(self) }
}
pub struct CachedVolGrid2d<'a, V: RectRasterableVol> {

View File

@ -952,7 +952,6 @@ impl Hud {
self.fonts = Fonts::load(i18n.fonts(), &mut self.ui).expect("Impossible to load fonts!");
}
#[allow(clippy::assign_op_pattern)] // TODO: Pending review in #587
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update_layout(
&mut self,
@ -972,7 +971,7 @@ impl Hud {
let (ref mut ui_widgets, ref mut item_tooltip_manager, ref mut tooltip_manager) =
&mut self.ui.set_widgets();
// self.ui.set_item_widgets(); pulse time for pulsating elements
self.pulse = self.pulse + dt.as_secs_f32();
self.pulse += dt.as_secs_f32();
// FPS
let fps = global_state.clock.stats().average_tps;
let version = common::util::DISPLAY_VERSION_LONG.clone();

View File

@ -23,8 +23,7 @@ impl Vertex {
const EXTRA_NEG_Z: f32 = 65536.0;
Self {
pos_norm: 0
| ((pos.x as u32) & 0x003F) << 0
pos_norm: ((pos.x as u32) & 0x003F)
| ((pos.y as u32) & 0x003F) << 6
| (((pos.z + EXTRA_NEG_Z).max(0.0).min((1 << 17) as f32) as u32) & 0x1FFFF) << 12
| (norm_bits & 0x7) << 29,

View File

@ -11,7 +11,6 @@ pub struct Vertex {
}
impl Vertex {
#[allow(clippy::identity_op)] // TODO: Pending review in #587
/// NOTE: meta is true when the terrain vertex is touching water.
pub fn new(atlas_pos: Vec2<u16>, pos: Vec3<f32>, norm: Vec3<f32>, meta: bool) -> Self {
const EXTRA_NEG_Z: f32 = 32768.0;
@ -26,12 +25,12 @@ impl Vertex {
5
};
Self {
pos_norm: ((pos.x as u32) & 0x003F) << 0
pos_norm: ((pos.x as u32) & 0x003F)
| ((pos.y as u32) & 0x003F) << 6
| (((pos + EXTRA_NEG_Z).z.max(0.0).min((1 << 16) as f32) as u32) & 0xFFFF) << 12
| if meta { 1 } else { 0 } << 28
| (norm_bits & 0x7) << 29,
atlas_pos: ((atlas_pos.x as u32) & 0xFFFF) << 0 | ((atlas_pos.y as u32) & 0xFFFF) << 16,
atlas_pos: ((atlas_pos.x as u32) & 0xFFFF) | ((atlas_pos.y as u32) & 0xFFFF) << 16,
}
}
@ -97,7 +96,6 @@ impl Vertex {
]
}
#[allow(clippy::identity_op)]
pub fn make_col_light_figure(
// 0 to 31
light: u8,
@ -105,7 +103,7 @@ impl Vertex {
shiny: bool,
col: Rgb<u8>,
) -> [u8; 4] {
let attr = 0 | ((glowy as u8) << 0) | ((shiny as u8) << 1);
let attr = (glowy as u8) | ((shiny as u8) << 1);
[
(light.min(31) << 3) | ((col.r >> 1) & 0b111),
(attr.min(31) << 3) | ((col.b >> 1) & 0b111),

View File

@ -168,8 +168,7 @@ impl<'a> BlockGen<'a> {
.or_else(|| {
// Rocks
if (height + 2.5 - wposf.z as f32).div(7.5).abs().powi(2) < rock {
#[allow(clippy::identity_op)]
let field0 = RandomField::new(world.seed + 0);
let field0 = RandomField::new(world.seed);
let field1 = RandomField::new(world.seed + 1);
let field2 = RandomField::new(world.seed + 2);

View File

@ -128,10 +128,9 @@ pub struct Noise {
}
impl Noise {
#[allow(clippy::identity_op)]
fn new(seed: u32) -> Self {
Self {
cave_nz: SuperSimplex::new().set_seed(seed + 0),
cave_nz: SuperSimplex::new().set_seed(seed),
scatter_nz: SuperSimplex::new().set_seed(seed + 1),
}
}

View File

@ -405,7 +405,6 @@ pub fn diffusion(
INTEGER n
double precision a(n),b(n),c(n),r(n),u(n)
*/
#[allow(clippy::assign_op_pattern)] // TODO: Pending review in #587
#[allow(clippy::many_single_char_names)]
pub fn tridag(a: &[f64], b: &[f64], c: &[f64], r: &[f64], u: &mut [f64], n: usize) {
/*
@ -462,7 +461,7 @@ pub fn tridag(a: &[f64], b: &[f64], c: &[f64], r: &[f64], u: &mut [f64], n: usiz
12 continue
*/
for j in (0..n - 1).rev() {
u[j] = u[j] - gam[j + 1] * u[j + 1];
u[j] -= gam[j + 1] * u[j + 1];
}
/*
deallocate (gam)

View File

@ -1825,7 +1825,6 @@ pub(crate) fn fill_sinks<F: Float + Send + Sync>(
/// adjacency list).
/// - The adjacency list (stored in a single vector), indexed by the second
/// indirection vector.
#[allow(clippy::filter_next)] // TODO: Pending review in #587
pub fn get_lakes<F: Float>(
map_size_lg: MapSizeLg,
h: impl Fn(usize) -> F,
@ -1957,8 +1956,7 @@ pub fn get_lakes<F: Float>(
// the neighbor lake in our lake.
*neighbor_lake
.iter_mut()
.filter(|neighbor_pass| neighbor_pass.0 == -1)
.next()
.find(|neighbor_pass| neighbor_pass.0 == -1)
.unwrap() = (neighbor_idx as i32, chunk_idx_);
// panic!("Should never happen; maybe didn't reserve enough space in
// lakes?")

View File

@ -561,8 +561,6 @@ impl Settlement {
}
}
#[allow(clippy::identity_op)] // TODO: Pending review in #587
#[allow(clippy::modulo_one)] // TODO: Pending review in #587
pub fn apply_to<'a>(
&'a self,
index: IndexRef,
@ -658,16 +656,12 @@ impl Settlement {
}
}
Some(Rgb::from(colors.plot_town_path).map2(
Rgb::iota(),
|e: u8, i: i32| {
e.saturating_add(
(self.noise.get(Vec3::new(wpos2d.x, wpos2d.y, i * 5)) % 1)
as u8,
)
.saturating_sub(8)
},
))
Some(
Rgb::from(colors.plot_town_path)
.map2(Rgb::iota(), |e: u8, _i: i32| {
e.saturating_add(0_u8).saturating_sub(8)
}),
)
},
Some(Plot::Field { seed, crop, .. }) => {
let furrow_dirs = [
@ -680,7 +674,7 @@ impl Settlement {
let in_furrow = (wpos2d * furrow_dir).sum().rem_euclid(5) < 2;
let dirt = Rgb::<u8>::from(colors.plot_field_dirt).map(|e| {
e + (self.noise.get(Vec3::broadcast((seed % 4096 + 0) as i32)) % 32)
e + (self.noise.get(Vec3::broadcast((seed % 4096) as i32)) % 32)
as u8
});
let mound = Rgb::<u8>::from(colors.plot_field_mound)

View File

@ -42,7 +42,6 @@ impl Castle {
}
impl Structure for Castle {
#[allow(clippy::identity_op)]
fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>(
&self,
site: &Site,
@ -127,7 +126,7 @@ impl Structure for Castle {
.with_z(self.alt + wall_height / 4 + 12),
}));
let window_bottom = prim(Primitive::Aabb(Aabb {
min: (wpos + 1 * dir).with_z(self.alt + wall_height / 4),
min: (wpos + dir).with_z(self.alt + wall_height / 4),
max: (wpos + (ts - 1) * dir + dir.yx())
.with_z(self.alt + wall_height / 4 + 9),
}));
@ -138,7 +137,7 @@ impl Structure for Castle {
.with_z(self.alt + wall_height / 4 + 12),
}));
let window_bottom2 = prim(Primitive::Aabb(Aabb {
min: (wpos + 1 * dir + (ts - 1) * dir.yx())
min: (wpos + dir + (ts - 1) * dir.yx())
.with_z(self.alt + wall_height / 4),
max: (wpos + (ts - 1) * dir + ts * dir.yx())
.with_z(self.alt + wall_height / 4 + 9),

View File

@ -13,9 +13,8 @@ impl FastNoise {
}
}
#[allow(clippy::excessive_precision)] // TODO: Pending review in #587
fn noise_at(&self, pos: Vec3<i32>) -> f32 {
(self.noise.get(pos) & 4095) as f32 * 0.000244140625
(self.noise.get(pos) & 4095) as f32 * 0.000_244_140_63
}
}
@ -87,9 +86,8 @@ impl FastNoise2d {
}
}
#[allow(clippy::excessive_precision)] // TODO: Pending review in #587
fn noise_at(&self, pos: Vec2<i32>) -> f32 {
(self.noise.get(Vec3::new(pos.x, pos.y, 0)) & 4095) as f32 * 0.000244140625
(self.noise.get(Vec3::new(pos.x, pos.y, 0)) & 4095) as f32 * 0.000_244_140_63
}
}

View File

@ -13,12 +13,11 @@ pub struct StructureGen2d {
pub type StructureField = (Vec2<i32>, u32);
impl StructureGen2d {
#[allow(clippy::identity_op)] // TODO: Pending review in #587
pub fn new(seed: u32, freq: u32, spread: u32) -> Self {
Self {
freq,
spread,
x_field: RandomField::new(seed + 0),
x_field: RandomField::new(seed),
y_field: RandomField::new(seed + 1),
seed_field: RandomField::new(seed + 2),
}