From b15f426ee56a47f2eb64ddcdcaf0645830cd5d9c Mon Sep 17 00:00:00 2001 From: Jonathan Berglin Date: Sun, 18 Jul 2021 17:11:46 +0000 Subject: [PATCH] Resolve all approved error supressions --- common/src/terrain/map.rs | 1 - common/src/terrain/mod.rs | 1 - common/src/volumes/chunk.rs | 1 - common/systems/src/phys.rs | 11 ++++------- server/src/events/interaction.rs | 7 ++++--- server/src/lib.rs | 1 - voxygen/src/audio/sfx/event_mapper/movement/mod.rs | 1 - voxygen/src/hud/hotbar.rs | 1 - voxygen/src/render/mod.rs | 1 - voxygen/src/render/pipelines/fluid.rs | 3 +-- voxygen/src/ui/ice/renderer/mod.rs | 4 +--- world/examples/water.rs | 5 +++-- world/src/column/mod.rs | 5 ++--- world/src/sim/erosion.rs | 1 - world/src/sim/mod.rs | 3 --- world/src/site/castle/mod.rs | 1 - world/src/site2/plot/dungeon.rs | 1 - 17 files changed, 15 insertions(+), 33 deletions(-) diff --git a/common/src/terrain/map.rs b/common/src/terrain/map.rs index 4b6b39110f..497d7740db 100644 --- a/common/src/terrain/map.rs +++ b/common/src/terrain/map.rs @@ -442,7 +442,6 @@ impl<'a> MapConfig<'a> { /// sample_wpos is a simple function that, given a *column* position, /// returns the approximate altitude at that column. When in doubt, try /// using `MapConfig::sample_wpos` for this. - #[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587 #[allow(clippy::many_single_char_names)] pub fn generate( &self, diff --git a/common/src/terrain/mod.rs b/common/src/terrain/mod.rs index f31e906ba7..aabb5d56a4 100644 --- a/common/src/terrain/mod.rs +++ b/common/src/terrain/mod.rs @@ -286,7 +286,6 @@ pub fn river_spline_coeffs( /// curve"... hopefully this works out okay and gives us what we want (a /// river that extends outwards tangent to a quadratic curve, with width /// configured by distance along the line). -#[allow(clippy::let_and_return)] // TODO: Pending review in #587 #[allow(clippy::many_single_char_names)] pub fn quadratic_nearest_point( spline: &Vec3>, diff --git a/common/src/volumes/chunk.rs b/common/src/volumes/chunk.rs index 34883e77b2..699a5d1f25 100644 --- a/common/src/volumes/chunk.rs +++ b/common/src/volumes/chunk.rs @@ -311,7 +311,6 @@ impl ReadVol for Chunk { impl WriteVol for Chunk { #[inline(always)] - #[allow(clippy::unit_arg)] // TODO: Pending review in #587 fn set(&mut self, pos: Vec3, vox: Self::Vox) -> Result { if !pos .map2(S::SIZE, |e, s| 0 <= e && e < s as i32) diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index 89f675b7d9..c619c145f8 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -272,7 +272,6 @@ impl<'a> PhysicsData<'a> { spatial_grid } - #[allow(clippy::nonminimal_bool)] fn apply_pushback(&mut self, job: &mut Job, spatial_grid: &SpatialGrid) { span!(_guard, "Apply pushback"); job.cpu_stats.measure(ParMode::Rayon); @@ -439,14 +438,12 @@ impl<'a> PhysicsData<'a> { // // Don't apply force when entity is a sticky which is on the // ground (or on the wall) - if !forced_movement && - !(is_sticky && !is_mid_air) + if !forced_movement + && !is_sticky + || is_mid_air && diff.magnitude_squared() > 0.0 && !is_projectile - && !matches!( - collider_other, - Some(Collider::Voxel { .. }) - ) + && !matches!(collider_other,Some(Collider::Voxel { .. })) && !matches!(collider, Some(Collider::Voxel { .. })) { let force = 400.0 diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index a0663ff4d6..88c6dae69b 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -148,7 +148,6 @@ pub fn handle_unmount(server: &mut Server, mounter: EcsEntity) { state.delete_component::(mounter); } -#[allow(clippy::nonminimal_bool)] // TODO: Pending review in #587 /// FIXME: This code is dangerous and needs to be refactored. We can't just /// comment it out, but it needs to be fixed for a variety of reasons. Get rid /// of this ASAP! @@ -159,8 +158,10 @@ pub fn handle_possess(server: &mut Server, possessor_uid: Uid, possesse_uid: Uid ecs.entity_from_uid(possesse_uid.into()), ) { // Check that entities still exist - if !(possessor.gen().is_alive() && ecs.is_alive(possessor)) - || !(possesse.gen().is_alive() && ecs.is_alive(possesse)) + if !possessor.gen().is_alive() + || !ecs.is_alive(possessor) + || !possesse.gen().is_alive() + || !ecs.is_alive(possesse) { error!( "Error possessing! either the possessor entity or possesse entity no longer exists" diff --git a/server/src/lib.rs b/server/src/lib.rs index 66184909fa..2a24620d04 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -163,7 +163,6 @@ pub struct Server { impl Server { /// Create a new `Server` - #[allow(clippy::expect_fun_call)] // TODO: Pending review in #587 #[allow(clippy::needless_update)] // TODO: Pending review in #587 pub fn new( settings: Settings, diff --git a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs index 670c86308b..8a55d371fe 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/mod.rs @@ -184,7 +184,6 @@ impl MovementEventMapper { /// as opening or closing the glider. These methods translate those /// entity states with some additional data into more specific /// `SfxEvent`'s which we attach sounds to - #[allow(clippy::nonminimal_bool)] // TODO: Pending review in #587 fn map_movement_event( character_state: &CharacterState, physics_state: &PhysicsState, diff --git a/voxygen/src/hud/hotbar.rs b/voxygen/src/hud/hotbar.rs index 7bfe10b8d4..e6dd84112d 100644 --- a/voxygen/src/hud/hotbar.rs +++ b/voxygen/src/hud/hotbar.rs @@ -71,7 +71,6 @@ impl State { // TODO: remove // Adds ability3 slot if it is missing and should be present // Removes if it is there and shouldn't be present - #[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587 pub fn maintain_ability3(&mut self, client: &client::Client) { use specs::WorldExt; let inventories = client.state().ecs().read_storage::(); diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index c4af1c02ad..d7598d5508 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -1,6 +1,5 @@ pub mod bound; mod buffer; -#[allow(clippy::single_component_path_imports)] // TODO: Pending review in #587 pub mod consts; mod error; pub mod instances; diff --git a/voxygen/src/render/pipelines/fluid.rs b/voxygen/src/render/pipelines/fluid.rs index 3d49fb95c3..72d5923db5 100644 --- a/voxygen/src/render/pipelines/fluid.rs +++ b/voxygen/src/render/pipelines/fluid.rs @@ -11,11 +11,10 @@ pub struct Vertex { impl Vertex { #[allow(clippy::identity_op)] // TODO: Pending review in #587 - #[allow(clippy::into_iter_on_ref)] // TODO: Pending review in #587 pub fn new(pos: Vec3, norm: Vec3) -> Self { let (norm_axis, norm_dir) = norm .as_slice() - .into_iter() + .iter() .enumerate() .find(|(_i, e)| **e != 0.0) .unwrap_or((0, &1.0)); diff --git a/voxygen/src/ui/ice/renderer/mod.rs b/voxygen/src/ui/ice/renderer/mod.rs index ae83454051..51f4fbf494 100644 --- a/voxygen/src/ui/ice/renderer/mod.rs +++ b/voxygen/src/ui/ice/renderer/mod.rs @@ -827,18 +827,16 @@ impl iced::Renderer for IcedRenderer { // TODO: use graph of primitives to enable diffing??? type Output = (Primitive, iced::mouse::Interaction); - #[allow(clippy::let_and_return)] fn layout<'a, M>( &mut self, element: &iced::Element<'a, M, Self>, limits: &iced::layout::Limits, ) -> iced::layout::Node { span!(_guard, "layout", "IcedRenderer::layout"); - let node = element.layout(self, limits); // Trim text measurements cache? - node + element.layout(self, limits) } fn overlay( diff --git a/world/examples/water.rs b/world/examples/water.rs index 0c3da7012b..df5da313ba 100644 --- a/world/examples/water.rs +++ b/world/examples/water.rs @@ -24,7 +24,6 @@ const W: usize = 1024; const H: usize = 1024; #[allow(clippy::needless_update)] // TODO: Pending review in #587 -#[allow(clippy::unused_io_amount)] // TODO: Pending review in #587 fn main() { FmtSubscriber::builder() .with_max_level(Level::ERROR) @@ -234,7 +233,9 @@ fn main() { |pos, (r, g, b, a)| { let i = pos.x; let j = pos.y; - (&mut buf[(j * x + i) * 4..]).write(&[r, g, b, a]).unwrap(); + (&mut buf[(j * x + i) * 4..]) + .write_all(&[r, g, b, a]) + .unwrap(); }, ); // TODO: Justify fits in u32. diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 1231469174..d57e5892d2 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -15,7 +15,7 @@ use noise::NoiseFn; use serde::Deserialize; use std::{ cmp::Reverse, - f32, f64, + f32, ops::{Add, Div, Mul, Sub}, }; use tracing::error; @@ -60,7 +60,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { type Sample = Option>; #[allow(clippy::float_cmp)] // TODO: Pending review in #587 - #[allow(clippy::nonminimal_bool)] // TODO: Pending review in #587 #[allow(clippy::single_match)] // TODO: Pending review in #587 fn get(&self, (wpos, index): Self::Index) -> Option> { let wposf = wpos.map(|e| e as f64); @@ -321,7 +320,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { neighbor_river_data.for_each(|(river_chunk_idx, river_chunk, river, dist)| { match river.river_kind { Some(kind) => { - if kind.is_river() && !dist.is_some() { + if kind.is_river() && dist.is_none() { // Ostensibly near a river segment, but not "usefully" so (there is no // closest point between t = 0.0 and t = 1.0). return; diff --git a/world/src/sim/erosion.rs b/world/src/sim/erosion.rs index 7e4366a15c..90be18e068 100644 --- a/world/src/sim/erosion.rs +++ b/world/src/sim/erosion.rs @@ -549,7 +549,6 @@ pub fn get_rivers, G: Float + Into>( /// Precompute the maximum slope at all points. /// /// TODO: See if allocating in advance is worthwhile. -#[allow(clippy::let_and_return)] // TODO: Pending review in #587 fn get_max_slope( map_size_lg: MapSizeLg, h: &[Alt], diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 56cbc5c8eb..dfe38d63b8 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -370,8 +370,6 @@ pub struct WorldSim { } impl WorldSim { - #[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587 - pub fn generate(seed: u32, opts: WorldOpts, threadpool: &rayon::ThreadPool) -> Self { // Parse out the contents of various map formats into the values we need. let parsed_world_file = (|| { @@ -2149,7 +2147,6 @@ pub struct RegionInfo { } impl SimChunk { - #[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587 fn generate(map_size_lg: MapSizeLg, posi: usize, gen_ctx: &GenCtx, gen_cdf: &GenCdf) -> Self { let pos = uniform_idx_as_vec2(map_size_lg, posi); let wposf = (pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32)).map(|e| e as f64); diff --git a/world/src/site/castle/mod.rs b/world/src/site/castle/mod.rs index 655138e884..8f90faeadf 100644 --- a/world/src/site/castle/mod.rs +++ b/world/src/site/castle/mod.rs @@ -57,7 +57,6 @@ pub struct GenCtx<'a, R: Rng> { pub struct Colors; impl Castle { - #[allow(clippy::let_and_return)] // TODO: Pending review in #587 pub fn generate(wpos: Vec2, sim: Option<&mut WorldSim>, rng: &mut impl Rng) -> Self { let ctx = GenCtx { sim, rng }; diff --git a/world/src/site2/plot/dungeon.rs b/world/src/site2/plot/dungeon.rs index c8a96a1935..3b0bbae244 100644 --- a/world/src/site2/plot/dungeon.rs +++ b/world/src/site2/plot/dungeon.rs @@ -545,7 +545,6 @@ impl Floor { } } - #[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587 fn create_route(&mut self, _ctx: &mut GenCtx, a: Vec2, b: Vec2) { let heuristic = move |l: &Vec2| (l - b).map(|e| e.abs()).reduce_max() as f32; let neighbors = |l: &Vec2| {