diff --git a/Cargo.lock b/Cargo.lock index 667075b0f2..f575b06355 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5640,8 +5640,7 @@ dependencies = [ [[package]] name = "shaderc" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e6fe602a861622769530a23bc40bfba31adbf186d0c8412e83f5519c5d6bee" +source = "git+https://github.com/pythonesque/shaderc-rs?rev=f2605a02062834019bedff911aee2fd2998c49f9#f2605a02062834019bedff911aee2fd2998c49f9" dependencies = [ "libc", "shaderc-sys", @@ -5650,8 +5649,7 @@ dependencies = [ [[package]] name = "shaderc-sys" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3794498651f8173d0afbc0bb8aca45ced111098227e755dde4c0ef2888c8d0bf" +source = "git+https://github.com/pythonesque/shaderc-rs?rev=f2605a02062834019bedff911aee2fd2998c49f9#f2605a02062834019bedff911aee2fd2998c49f9" dependencies = [ "cmake", "libc", @@ -7806,7 +7804,7 @@ dependencies = [ [[package]] name = "wgpu" version = "0.8.0" -source = "git+https://github.com/gfx-rs/wgpu.git?rev=a92b8549a8e2cb9dac781bafc5ed32828f3caf46#a92b8549a8e2cb9dac781bafc5ed32828f3caf46" +source = "git+https://github.com/pythonesque/wgpu.git?rev=179ea209374a92837cde252f1d9ee01f628cae08#179ea209374a92837cde252f1d9ee01f628cae08" dependencies = [ "arrayvec 0.5.2", "js-sys", @@ -7826,7 +7824,7 @@ dependencies = [ [[package]] name = "wgpu-core" version = "0.8.0" -source = "git+https://github.com/gfx-rs/wgpu.git?rev=a92b8549a8e2cb9dac781bafc5ed32828f3caf46#a92b8549a8e2cb9dac781bafc5ed32828f3caf46" +source = "git+https://github.com/pythonesque/wgpu.git?rev=179ea209374a92837cde252f1d9ee01f628cae08#179ea209374a92837cde252f1d9ee01f628cae08" dependencies = [ "arrayvec 0.5.2", "bitflags", @@ -7866,7 +7864,7 @@ dependencies = [ [[package]] name = "wgpu-types" version = "0.8.0" -source = "git+https://github.com/gfx-rs/wgpu.git?rev=a92b8549a8e2cb9dac781bafc5ed32828f3caf46#a92b8549a8e2cb9dac781bafc5ed32828f3caf46" +source = "git+https://github.com/pythonesque/wgpu.git?rev=179ea209374a92837cde252f1d9ee01f628cae08#179ea209374a92837cde252f1d9ee01f628cae08" dependencies = [ "bitflags", "serde", diff --git a/Cargo.toml b/Cargo.toml index fec9ce5a35..b0c127a1db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,7 +122,8 @@ nativeBuildInputs = ["pkg-config"] [patch.crates-io] vek = { git = "https://github.com/yoanlcq/vek.git", rev = "84d5cb65841d46599a986c5477341bea4456be26" } # patch wgpu so we can use wgpu-profiler crate -wgpu = { git = "https://github.com/gfx-rs/wgpu.git", rev = "a92b8549a8e2cb9dac781bafc5ed32828f3caf46" } +# wgpu = { git = "https://github.com/gfx-rs/wgpu.git", rev = "a92b8549a8e2cb9dac781bafc5ed32828f3caf46" } +wgpu = { git = "https://github.com/pythonesque/wgpu.git", rev = "179ea209374a92837cde252f1d9ee01f628cae08" } # # use the latest fixes in naga (remove when updates trickle down to wgpu-rs) # naga = { git = "https://github.com/gfx-rs/naga.git", rev = "3a0f0144112ff621dd7f731bf455adf6cab19164" } diff --git a/client/src/lib.rs b/client/src/lib.rs index d07bd78f85..aea6a66eeb 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,6 +1,6 @@ #![deny(unsafe_code)] #![deny(clippy::clone_on_ref_ptr)] -#![feature(label_break_value, option_zip)] +#![feature(option_zip)] pub mod addr; pub mod error; @@ -318,7 +318,7 @@ impl Client { server_info.git_hash, server_info.git_date, common::util::GIT_HASH.to_string(), - common::util::GIT_DATE.to_string(), + *common::util::GIT_DATE, ); } // Pass the server info back to the caller to ensure they can access it even @@ -2568,7 +2568,7 @@ impl Client { pub fn players(&self) -> impl Iterator { self.player_list() .values() - .filter_map(|player_info| player_info.is_online.then(|| &*player_info.player_alias)) + .filter_map(|player_info| player_info.is_online.then_some(&*player_info.player_alias)) } /// Return true if this client is a moderator on the server diff --git a/common/build.rs b/common/build.rs index 4f560e1dd3..71e4750974 100644 --- a/common/build.rs +++ b/common/build.rs @@ -17,7 +17,7 @@ fn main() { // Note: It will compare commits. As long as the commits do not diverge from the // server no version change will be detected. match Command::new("git") - .args(&[ + .args([ "log", "-n", "1", @@ -40,7 +40,7 @@ fn main() { // Note: It will compare commits. As long as the commits do not diverge from the // server no version change will be detected. match Command::new("git") - .args(&["describe", "--exact-match", "--tags", "HEAD"]) + .args(["describe", "--exact-match", "--tags", "HEAD"]) .output() { Ok(output) => match String::from_utf8(output.stdout) { diff --git a/common/ecs/src/system.rs b/common/ecs/src/system.rs index 3ab41663cf..015bec55fe 100644 --- a/common/ecs/src/system.rs +++ b/common/ecs/src/system.rs @@ -5,7 +5,7 @@ use std::{collections::HashMap, time::Instant}; /// measuring the level of threads a unit of code ran on. Use Rayon when it ran /// on their threadpool. Use Exact when you know on how many threads your code /// ran on exactly. -#[derive(Clone, Copy, PartialEq, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum ParMode { None, /* Job is not running at all */ Single, @@ -14,7 +14,7 @@ pub enum ParMode { } //TODO: make use of the phase of a system for advanced scheduling and logging -#[derive(Clone, Copy, PartialEq, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Phase { Create, Review, @@ -22,7 +22,7 @@ pub enum Phase { } //TODO: make use of the origin of the system for better logging -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub enum Origin { Common, Client, diff --git a/common/net/src/msg/client.rs b/common/net/src/msg/client.rs index 18ad9e52d5..998d7873d7 100644 --- a/common/net/src/msg/client.rs +++ b/common/net/src/msg/client.rs @@ -28,7 +28,7 @@ pub enum ClientMsg { 2nd Level Enums */ -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum ClientType { /// Regular Client like Voxygen who plays the game Game, @@ -39,7 +39,7 @@ pub enum ClientType { Bot { privileged: bool }, } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct ClientRegister { pub token_or_username: String, } diff --git a/common/net/src/msg/compression.rs b/common/net/src/msg/compression.rs index 37760baaa0..433d572eff 100644 --- a/common/net/src/msg/compression.rs +++ b/common/net/src/msg/compression.rs @@ -36,7 +36,7 @@ impl CompressedData { let buf = Vec::with_capacity(uncompressed.len() / 10); let mut encoder = DeflateEncoder::new(buf, Compression::new(level)); - encoder.write_all(&*uncompressed).expect(EXPECT_MSG); + encoder.write_all(&uncompressed).expect(EXPECT_MSG); let compressed = encoder.finish().expect(EXPECT_MSG); CompressedData { data: compressed, @@ -60,9 +60,9 @@ impl Deserialize<'a>> CompressedData { flate2::read::DeflateDecoder::new(&*self.data) .read_to_end(&mut uncompressed) .ok()?; - bincode::deserialize(&*uncompressed).ok() + bincode::deserialize(&uncompressed).ok() } else { - bincode::deserialize(&*self.data).ok() + bincode::deserialize(&self.data).ok() } } } @@ -237,7 +237,7 @@ impl VoxelImageEncoding for QuadPngEncoding { CompressionType::Rle, FilterType::Up, ); - png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8) + png.write_image(x.as_raw(), x.width(), x.height(), image::ColorType::L8) .ok()?; indices[i] = buf.len(); Some(()) @@ -253,7 +253,7 @@ impl VoxelImageEncoding for QuadPngEncoding { FilterType::Sub, ); png.write_image( - &*ws.3.as_raw(), + ws.3.as_raw(), ws.3.width(), ws.3.height(), image::ColorType::Rgb8, @@ -513,7 +513,7 @@ impl VoxelImageEncoding for TriPngEncoding bool { matches!(self, Self::Character(_) | Self::Possessor) } } -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum PingMsg { Ping, Pong, diff --git a/common/net/src/msg/server.rs b/common/net/src/msg/server.rs index 4280416174..80d1872d30 100644 --- a/common/net/src/msg/server.rs +++ b/common/net/src/msg/server.rs @@ -267,7 +267,7 @@ pub enum DisconnectReason { Kicked(String), } -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum RegisterError { AuthError(String), Banned(String), diff --git a/common/src/calendar.rs b/common/src/calendar.rs index f9934d252a..830207809c 100644 --- a/common/src/calendar.rs +++ b/common/src/calendar.rs @@ -8,7 +8,7 @@ pub enum CalendarEvent { Christmas = 0, } -#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct Calendar { events: Vec, } diff --git a/common/src/character.rs b/common/src/character.rs index c065941d21..92401c3fe1 100644 --- a/common/src/character.rs +++ b/common/src/character.rs @@ -10,7 +10,7 @@ pub type CharacterId = i64; pub const MAX_NAME_LENGTH: usize = 20; /// The minimum character data we need to create a new character on the server. -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Character { pub id: Option, pub alias: String, diff --git a/common/src/cmd.rs b/common/src/cmd.rs index c0a4e330e8..bd9e772a84 100644 --- a/common/src/cmd.rs +++ b/common/src/cmd.rs @@ -39,7 +39,7 @@ impl ChatCommandData { } } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub enum KitSpec { Item(String), ModularWeapon { @@ -47,7 +47,7 @@ pub enum KitSpec { material: comp::item::Material, }, } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct KitManifest(pub HashMap>); impl assets::Asset for KitManifest { type Loader = assets::RonLoader; @@ -55,7 +55,7 @@ impl assets::Asset for KitManifest { const EXTENSION: &'static str = "ron"; } -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct SkillPresetManifest(pub HashMap>); impl assets::Asset for SkillPresetManifest { type Loader = assets::RonLoader; @@ -875,7 +875,7 @@ impl FromStr for ServerChatCommand { .filter_map(|c| c.short_keyword().map(|s| (s, c))) .chain(Self::iter().map(|c| (c.keyword(), c))) // Find command with matching string as keyword - .find_map(|(kwd, command)| (kwd == keyword).then(|| command)) + .find_map(|(kwd, command)| (kwd == keyword).then_some(command)) // Return error if not found .ok_or(()) } diff --git a/common/src/combat.rs b/common/src/combat.rs index 675f2e99ca..a25cf9856c 100644 --- a/common/src/combat.rs +++ b/common/src/combat.rs @@ -901,7 +901,7 @@ pub struct Knockback { } #[cfg(not(target_arch = "wasm32"))] -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum KnockbackDir { Away, Towards, diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 652c273a6a..3b88cf1882 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -326,7 +326,7 @@ impl From for Ability { } } -#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)] +#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)] pub enum AuxiliaryAbility { MainWeapon(usize), OffWeapon(usize), diff --git a/common/src/comp/agent.rs b/common/src/comp/agent.rs index 8e0c63f8ae..7e47b8d997 100644 --- a/common/src/comp/agent.rs +++ b/common/src/comp/agent.rs @@ -21,7 +21,7 @@ pub const TRADE_INTERACTION_TIME: f32 = 300.0; const AWARENESS_DECREMENT_CONSTANT: f32 = 2.1; const SECONDS_BEFORE_FORGET_SOUNDS: f64 = 180.0; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Alignment { /// Wild animals and gentle giants Wild, @@ -37,7 +37,7 @@ pub enum Alignment { Passive, } -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Mark { Merchant, Guard, diff --git a/common/src/comp/anchor.rs b/common/src/comp/anchor.rs index f82b9b1881..28f198e05d 100644 --- a/common/src/comp/anchor.rs +++ b/common/src/comp/anchor.rs @@ -4,7 +4,7 @@ use vek::Vec2; /// This component exists in order to fix a bug that caused entities /// such as campfires to duplicate because the chunk was double-loaded. /// See https://gitlab.com/veloren/veloren/-/merge_requests/1543 -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Anchor { /// An entity with an Entity Anchor will be destroyed when its anchor Entity /// no longer exists diff --git a/common/src/comp/aura.rs b/common/src/comp/aura.rs index a66f719b59..5f873c60f4 100644 --- a/common/src/comp/aura.rs +++ b/common/src/comp/aura.rs @@ -70,7 +70,7 @@ pub enum AuraTarget { All, } -#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum Specifier { WardingAura, HealingAura, diff --git a/common/src/comp/beam.rs b/common/src/comp/beam.rs index 95e501938b..3a073e8774 100644 --- a/common/src/comp/beam.rs +++ b/common/src/comp/beam.rs @@ -34,7 +34,7 @@ impl std::ops::Deref for BeamSegment { fn deref(&self) -> &Properties { &self.properties } } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Beam { pub hit_entities: Vec, pub tick_dur: Duration, @@ -45,7 +45,7 @@ impl Component for Beam { type Storage = specs::DenseVecStorage; } -#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum FrontendSpecifier { Flamethrower, LifestealBeam, diff --git a/common/src/comp/body/arthropod.rs b/common/src/comp/body/arthropod.rs index 021a80b288..4f38fa059b 100644 --- a/common/src/comp/body/arthropod.rs +++ b/common/src/comp/body/arthropod.rs @@ -10,13 +10,13 @@ pub struct Body { impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/biped_large.rs b/common/src/comp/body/biped_large.rs index 44285fa21e..82dea641b7 100644 --- a/common/src/comp/body/biped_large.rs +++ b/common/src/comp/body/biped_large.rs @@ -14,13 +14,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/biped_small.rs b/common/src/comp/body/biped_small.rs index 945586f393..7bfa285af9 100644 --- a/common/src/comp/body/biped_small.rs +++ b/common/src/comp/body/biped_small.rs @@ -14,13 +14,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/bird_large.rs b/common/src/comp/body/bird_large.rs index 8560aad74a..b393aa0cd0 100644 --- a/common/src/comp/body/bird_large.rs +++ b/common/src/comp/body/bird_large.rs @@ -14,13 +14,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/bird_medium.rs b/common/src/comp/body/bird_medium.rs index 6b279cf536..a5da2ece66 100644 --- a/common/src/comp/body/bird_medium.rs +++ b/common/src/comp/body/bird_medium.rs @@ -15,13 +15,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/dragon.rs b/common/src/comp/body/dragon.rs index 07c3991a44..353713abf8 100644 --- a/common/src/comp/body/dragon.rs +++ b/common/src/comp/body/dragon.rs @@ -14,13 +14,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/fish_medium.rs b/common/src/comp/body/fish_medium.rs index 924bf09f36..a98788b788 100644 --- a/common/src/comp/body/fish_medium.rs +++ b/common/src/comp/body/fish_medium.rs @@ -14,13 +14,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/fish_small.rs b/common/src/comp/body/fish_small.rs index 952a3f5412..172db783e1 100644 --- a/common/src/comp/body/fish_small.rs +++ b/common/src/comp/body/fish_small.rs @@ -14,13 +14,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/golem.rs b/common/src/comp/body/golem.rs index 1591a7f41f..706c181872 100644 --- a/common/src/comp/body/golem.rs +++ b/common/src/comp/body/golem.rs @@ -14,13 +14,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index a2f5ea2e17..412499ccb7 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -29,13 +29,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type, diff --git a/common/src/comp/body/object.rs b/common/src/comp/body/object.rs index 3865b4fbd4..bb274d1248 100644 --- a/common/src/comp/body/object.rs +++ b/common/src/comp/body/object.rs @@ -106,7 +106,7 @@ make_case_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - *(&ALL_OBJECTS).choose(&mut rng).unwrap() + *ALL_OBJECTS.choose(&mut rng).unwrap() } } diff --git a/common/src/comp/body/quadruped_low.rs b/common/src/comp/body/quadruped_low.rs index 7affcab6bf..eb9665aa4b 100644 --- a/common/src/comp/body/quadruped_low.rs +++ b/common/src/comp/body/quadruped_low.rs @@ -15,13 +15,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/quadruped_medium.rs b/common/src/comp/body/quadruped_medium.rs index 185b611536..5dfaf2ade9 100644 --- a/common/src/comp/body/quadruped_medium.rs +++ b/common/src/comp/body/quadruped_medium.rs @@ -15,13 +15,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/quadruped_small.rs b/common/src/comp/body/quadruped_small.rs index 0a23d4fbb8..3a050dd00f 100644 --- a/common/src/comp/body/quadruped_small.rs +++ b/common/src/comp/body/quadruped_small.rs @@ -15,13 +15,13 @@ make_proj_elim!( impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/body/ship.rs b/common/src/comp/body/ship.rs index 113138df9f..1c722d6b5a 100644 --- a/common/src/comp/body/ship.rs +++ b/common/src/comp/body/ship.rs @@ -42,13 +42,13 @@ impl Body { Self::random_with(&mut rng) } - pub fn random_with(rng: &mut impl rand::Rng) -> Self { *(&ALL_BODIES).choose(rng).unwrap() } + pub fn random_with(rng: &mut impl rand::Rng) -> Self { *ALL_BODIES.choose(rng).unwrap() } pub fn random_airship_with(rng: &mut impl rand::Rng) -> Self { - *(&ALL_AIRSHIPS).choose(rng).unwrap() + *ALL_AIRSHIPS.choose(rng).unwrap() } - pub fn random_ship_with(rng: &mut impl rand::Rng) -> Self { *(&ALL_SHIPS).choose(rng).unwrap() } + pub fn random_ship_with(rng: &mut impl rand::Rng) -> Self { *ALL_SHIPS.choose(rng).unwrap() } /// Return the structure manifest that this ship uses. `None` means that it /// should be derived from the collider. diff --git a/common/src/comp/body/theropod.rs b/common/src/comp/body/theropod.rs index 5ef4df981f..ddca7d7c0e 100644 --- a/common/src/comp/body/theropod.rs +++ b/common/src/comp/body/theropod.rs @@ -10,13 +10,13 @@ pub struct Body { impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - let species = *(&ALL_SPECIES).choose(&mut rng).unwrap(); + let species = *ALL_SPECIES.choose(&mut rng).unwrap(); Self::random_with(&mut rng, &species) } #[inline] pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self { - let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap(); + let body_type = *ALL_BODY_TYPES.choose(rng).unwrap(); Self { species, body_type } } } diff --git a/common/src/comp/buff.rs b/common/src/comp/buff.rs index 572b5e8af3..1b19446da2 100644 --- a/common/src/comp/buff.rs +++ b/common/src/comp/buff.rs @@ -422,7 +422,7 @@ impl PartialEq for Buff { } /// Source of the de/buff -#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)] pub enum BuffSource { /// Applied by a character Character { by: Uid }, @@ -505,7 +505,7 @@ impl Buffs { self.kinds .get(&kind) .map(|ids| ids.iter()) - .unwrap_or_else(|| (&[]).iter()) + .unwrap_or_else(|| [].iter()) .map(move |id| (*id, &self.buffs[id])) } diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 3396f22016..83a219536b 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -17,7 +17,7 @@ use specs::Component; use std::collections::BTreeMap; use vek::*; -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum InventoryEvent { Pickup(Uid), Swap(InvSlotId, InvSlotId), @@ -31,7 +31,7 @@ pub enum InventoryEvent { }, } -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum InventoryAction { Swap(EquipSlot, Slot), Drop(EquipSlot), @@ -40,7 +40,7 @@ pub enum InventoryAction { Collect(Vec3), } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum InventoryManip { Pickup(Uid), Collect(Vec3), @@ -93,7 +93,7 @@ impl From for InventoryManip { } } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum CraftEvent { Simple { recipe: String, @@ -115,7 +115,7 @@ pub enum CraftEvent { }, } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum GroupManip { Leave, Kick(Uid), @@ -136,7 +136,7 @@ pub enum UtteranceKind { * sounds */ } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ControlEvent { //ToggleLantern, EnableLantern, @@ -230,7 +230,7 @@ pub struct InputAttr { pub target_entity: Option, } -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Climb { Up, Down, diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index a98a2ce544..8629fa4bd5 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -66,7 +66,7 @@ impl Energy { // NaN does not need to be handled here as rust will automatically change to 0 when casting to u32 .clamp(0.0, Self::MAX_SCALED_ENERGY as f32) as u32; - (maximum != self.maximum).then(|| maximum) + (maximum != self.maximum).then_some(maximum) } /// Updates the maximum value for energy. diff --git a/common/src/comp/fluid_dynamics.rs b/common/src/comp/fluid_dynamics.rs index 5c5bdc363a..9124ae501a 100644 --- a/common/src/comp/fluid_dynamics.rs +++ b/common/src/comp/fluid_dynamics.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use std::f32::consts::PI; use vek::*; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum LiquidKind { Water, Lava, diff --git a/common/src/comp/group.rs b/common/src/comp/group.rs index d3315b365a..7135eccab4 100644 --- a/common/src/comp/group.rs +++ b/common/src/comp/group.rs @@ -38,7 +38,7 @@ pub struct GroupInfo { pub name: String, } -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum Role { Member, Pet, @@ -504,7 +504,7 @@ impl GroupManager { self.groups[group.0 as usize].leader = new_leader; // Point to new leader - members(group, &*groups, entities, alignments, uids).for_each(|(e, role)| match role { + members(group, groups, entities, alignments, uids).for_each(|(e, role)| match role { Role::Member => notifier(e, ChangeNotification::NewLeader(new_leader)), Role::Pet => {}, }); diff --git a/common/src/comp/health.rs b/common/src/comp/health.rs index c2a27cfc08..2e6c2eaa5a 100644 --- a/common/src/comp/health.rs +++ b/common/src/comp/health.rs @@ -105,7 +105,7 @@ impl Health { // NaN does not need to be handled here as rust will automatically change to 0 when casting to u32 .clamp(0.0, Self::MAX_SCALED_HEALTH as f32) as u32; - (maximum != self.maximum).then(|| maximum) + (maximum != self.maximum).then_some(maximum) } /// Updates the maximum value for health. @@ -172,8 +172,8 @@ impl Health { .damage_contributors .entry(attacker) .or_insert((0, change.time)); - (*entry).0 += u64::try_from(-delta).unwrap_or(0); - (*entry).1 = change.time + entry.0 += u64::try_from(-delta).unwrap_or(0); + entry.1 = change.time } // Prune any damage contributors who haven't contributed damage for over the diff --git a/common/src/comp/inputs.rs b/common/src/comp/inputs.rs index a3f93bb65e..d6159f496f 100644 --- a/common/src/comp/inputs.rs +++ b/common/src/comp/inputs.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use specs::{Component, DenseVecStorage, DerefFlaggedStorage}; use vek::geom::Aabb; -#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct CanBuild { pub enabled: bool, pub build_areas: HashSet>>, diff --git a/common/src/comp/inventory/item/armor.rs b/common/src/comp/inventory/item/armor.rs index 26baf0152e..05983d9378 100644 --- a/common/src/comp/inventory/item/armor.rs +++ b/common/src/comp/inventory/item/armor.rs @@ -35,7 +35,7 @@ impl Armor { } /// longitudinal and lateral friction, only meaningful for footwear -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Friction { Normal, Ski, diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index bff26293c9..15aac14b35 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -210,7 +210,7 @@ impl TagExampleInfo for Material { fn exemplar_identifier(&self) -> Option<&str> { self.asset_identifier() } } -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ItemTag { /// Used to indicate that an item is composed of this material Material(Material), @@ -559,7 +559,7 @@ impl TryFrom<(&Item, &AbilityMap, &MaterialStatManifest)> for ItemConfig { ability_map.get_ability_set(key) }; let abilities = if let Some(set_key) = item.ability_spec() { - if let Some(set) = ability_map.get_ability_set(&*set_key) { + if let Some(set) = ability_map.get_ability_set(&set_key) { set.clone().modified_by_tool(tool) } else { error!( diff --git a/common/src/comp/inventory/item/modular.rs b/common/src/comp/inventory/item/modular.rs index 23acc1305d..9bb079f7b7 100644 --- a/common/src/comp/inventory/item/modular.rs +++ b/common/src/comp/inventory/item/modular.rs @@ -239,7 +239,7 @@ pub enum ModularComponent { }, } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum WeaponName { Universal(String), HandednessDependent { diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index 2e0f1c6cfc..53e175e57a 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -798,7 +798,7 @@ fn default_main_tool(body: &Body) -> Item { #[derive(Clone)] pub struct LoadoutBuilder(Loadout); -#[derive(Copy, Clone, PartialEq, Deserialize, Serialize, Debug, EnumIter)] +#[derive(Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Debug, EnumIter)] pub enum Preset { HuskSummon, } @@ -1083,7 +1083,7 @@ impl LoadoutBuilder { // Panic if item doesn't correspond to slot assert!( item.as_ref() - .map_or(true, |item| equip_slot.can_hold(&*item.kind())) + .map_or(true, |item| equip_slot.can_hold(&item.kind())) ); self.0.swap(equip_slot, item); diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index d08329ca11..89305fa4c3 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -559,7 +559,7 @@ impl Inventory { #[must_use = "Returned items will be lost if not used"] pub fn equip(&mut self, inv_slot: InvSlotId) -> Vec { self.get(inv_slot) - .and_then(|item| self.loadout.get_slot_to_equip_into(&*item.kind())) + .and_then(|item| self.loadout.get_slot_to_equip_into(&item.kind())) .map(|equip_slot| self.swap_inventory_loadout(inv_slot, equip_slot)) .unwrap_or_else(Vec::new) } @@ -570,7 +570,7 @@ impl Inventory { pub fn free_after_equip(&self, inv_slot: InvSlotId) -> i32 { let (inv_slot_for_equipped, slots_from_equipped) = self .get(inv_slot) - .and_then(|item| self.loadout.get_slot_to_equip_into(&*item.kind())) + .and_then(|item| self.loadout.get_slot_to_equip_into(&item.kind())) .and_then(|equip_slot| self.equipped(equip_slot)) .map_or((1, 0), |item| (0, item.slots().len())); diff --git a/common/src/comp/inventory/slot.rs b/common/src/comp/inventory/slot.rs index 5817c80746..4490deb120 100644 --- a/common/src/comp/inventory/slot.rs +++ b/common/src/comp/inventory/slot.rs @@ -6,12 +6,12 @@ use crate::comp::inventory::{ loadout::LoadoutSlotId, }; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum SlotError { InventoryFull, } -#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)] pub enum Slot { Inventory(InvSlotId), Equip(EquipSlot), diff --git a/common/src/comp/inventory/trade_pricing.rs b/common/src/comp/inventory/trade_pricing.rs index 5a07f0858b..44da73fe28 100644 --- a/common/src/comp/inventory/trade_pricing.rs +++ b/common/src/comp/inventory/trade_pricing.rs @@ -459,7 +459,7 @@ impl EqualitySet { let canonical_itemname = self .equivalence_class .get(item_name) - .map_or(item_name, |i| &*i); + .map_or(item_name, |i| i); canonical_itemname } diff --git a/common/src/comp/invite.rs b/common/src/comp/invite.rs index 194ec0974b..d1c1f1e370 100644 --- a/common/src/comp/invite.rs +++ b/common/src/comp/invite.rs @@ -1,13 +1,13 @@ use serde::{Deserialize, Serialize}; use specs::Component; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum InviteKind { Group, Trade, } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum InviteResponse { Accept, Decline, diff --git a/common/src/comp/misc.rs b/common/src/comp/misc.rs index 35d8981afd..968c894ff7 100644 --- a/common/src/comp/misc.rs +++ b/common/src/comp/misc.rs @@ -3,7 +3,7 @@ use crate::uid::Uid; use serde::{Deserialize, Serialize}; use specs::Component; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Object { Bomb { owner: Option, diff --git a/common/src/comp/phys.rs b/common/src/comp/phys.rs index 4df06ea57f..94308227c4 100644 --- a/common/src/comp/phys.rs +++ b/common/src/comp/phys.rs @@ -156,14 +156,14 @@ impl Component for Collider { type Storage = DerefFlaggedStorage>; } -#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Sticky; impl Component for Sticky { type Storage = DerefFlaggedStorage>; } -#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Immovable; impl Component for Immovable { @@ -213,7 +213,7 @@ impl Component for PhysicsState { /// Used to forcefully update the position, velocity, and orientation of the /// client -#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct ForceUpdate { flag: bool, counter: u64, diff --git a/common/src/comp/shockwave.rs b/common/src/comp/shockwave.rs index d04c40c1bd..4795aae2db 100644 --- a/common/src/comp/shockwave.rs +++ b/common/src/comp/shockwave.rs @@ -35,7 +35,7 @@ impl std::ops::Deref for Shockwave { fn deref(&self) -> &Properties { &self.properties } } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ShockwaveHitEntities { pub hit_entities: Vec, } @@ -44,7 +44,7 @@ impl Component for ShockwaveHitEntities { type Storage = specs::DenseVecStorage; } -#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum FrontendSpecifier { Ground, Fire, diff --git a/common/src/comp/skillset/mod.rs b/common/src/comp/skillset/mod.rs index d5f9d65bfa..a5bf7e8967 100644 --- a/common/src/comp/skillset/mod.rs +++ b/common/src/comp/skillset/mod.rs @@ -232,7 +232,7 @@ impl SkillGroup { /// Contains all of a player's skill groups and skills. Provides methods for /// manipulating assigned skills and skill groups including unlocking skills, /// refunding skills etc. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct SkillSet { skill_groups: HashMap, skills: HashMap, @@ -567,7 +567,7 @@ pub enum SpRewardError { Overflow, } -#[derive(Debug, PartialEq, Clone, Copy, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, Deserialize, Serialize)] pub enum SkillsPersistenceError { HashMismatch, DeserializationFailure, diff --git a/common/src/generation.rs b/common/src/generation.rs index 92609bb3f0..cd6b7be045 100644 --- a/common/src/generation.rs +++ b/common/src/generation.rs @@ -12,14 +12,14 @@ use crate::{ use serde::Deserialize; use vek::*; -#[derive(Debug, Deserialize, Clone, PartialEq)] +#[derive(Debug, Deserialize, Clone, PartialEq, Eq)] pub enum NameKind { Name(String), Automatic, Uninit, } -#[derive(Debug, Deserialize, Clone, PartialEq)] +#[derive(Debug, Deserialize, Clone, PartialEq, Eq)] pub enum BodyBuilder { RandomWith(String), Exact(Body), diff --git a/common/src/lib.rs b/common/src/lib.rs index 6cf1b69302..87fbcf8801 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -5,9 +5,7 @@ #![deny(clippy::clone_on_ref_ptr)] #![feature( associated_type_defaults, - bool_to_option, fundamental, - label_break_value, option_zip, trait_alias, type_alias_impl_trait, diff --git a/common/src/lottery.rs b/common/src/lottery.rs index 38ca914e72..d3c627a996 100644 --- a/common/src/lottery.rs +++ b/common/src/lottery.rs @@ -76,7 +76,7 @@ impl Lottery { pub fn total(&self) -> f32 { self.total } } -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub enum LootSpec> { /// Asset specifier Item(T), diff --git a/common/src/npc.rs b/common/src/npc.rs index 1985d7f113..0d40aafa1e 100644 --- a/common/src/npc.rs +++ b/common/src/npc.rs @@ -7,7 +7,7 @@ use rand::seq::SliceRandom; use serde::Deserialize; use std::str::FromStr; -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub enum NpcKind { Humanoid, Wolf, diff --git a/common/src/recipe.rs b/common/src/recipe.rs index 4bc704e895..c5334f5b7e 100644 --- a/common/src/recipe.rs +++ b/common/src/recipe.rs @@ -191,7 +191,7 @@ impl Recipe { for (inv_slot_id, slot) in inv.slots_with_id() { if let Some(item) = slot .as_ref() - .filter(|item| item.matches_recipe_input(&*input, amount)) + .filter(|item| item.matches_recipe_input(input, amount)) { *input_max.entry(inv_slot_id).or_insert(0) += item.amount(); } @@ -241,7 +241,7 @@ fn inventory_contains_ingredients<'a, I: Iterator for (inv_slot_id, slot) in inv.slots_with_id() { if let Some(item) = slot .as_ref() - .filter(|item| item.matches_recipe_input(&*input, amount)) + .filter(|item| item.matches_recipe_input(input, amount)) { let claim = slot_claims.entry(inv_slot_id).or_insert(0); slots.push((i as u32, inv_slot_id)); diff --git a/common/src/skillset_builder.rs b/common/src/skillset_builder.rs index 900b4237c7..fd0c67941a 100644 --- a/common/src/skillset_builder.rs +++ b/common/src/skillset_builder.rs @@ -9,7 +9,7 @@ use tracing::warn; /// `SkillSetBuilder` preset. Consider using loading from assets, when possible. /// When you're adding new enum variant, /// handle it in [`with_preset`](SkillSetBuilder::with_preset) method -#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub enum Preset { Rank1, Rank2, diff --git a/common/src/states/charged_melee.rs b/common/src/states/charged_melee.rs index 13ec4fe91d..56547ab614 100644 --- a/common/src/states/charged_melee.rs +++ b/common/src/states/charged_melee.rs @@ -181,7 +181,7 @@ impl CharacterBehavior for Data { } /// Used to specify a particular effect for frontend purposes -#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum FrontendSpecifier { GroundCleave, } diff --git a/common/src/states/equipping.rs b/common/src/states/equipping.rs index b70cb72ade..9ef1743990 100644 --- a/common/src/states/equipping.rs +++ b/common/src/states/equipping.rs @@ -10,13 +10,13 @@ use serde::{Deserialize, Serialize}; use std::time::Duration; /// Separated out to condense update portions of character state -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct StaticData { /// Time required to draw weapon pub buildup_duration: Duration, } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Data { /// Struct containing data that does not change over the course of the /// character state diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index 4d46446694..ae37b42d2a 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -8,7 +8,7 @@ use crate::{ }; use serde::{Deserialize, Serialize}; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Default)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)] pub struct Data { pub is_sneaking: bool, // None means unknown diff --git a/common/src/states/spin_melee.rs b/common/src/states/spin_melee.rs index a3edd9b480..a7bdf86280 100644 --- a/common/src/states/spin_melee.rs +++ b/common/src/states/spin_melee.rs @@ -175,7 +175,7 @@ impl CharacterBehavior for Data { } } -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum MovementBehavior { Stationary, ForwardGround, @@ -183,7 +183,7 @@ pub enum MovementBehavior { Walking, } -#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub enum FrontendSpecifier { CultistVortex, } diff --git a/common/src/states/sprite_interact.rs b/common/src/states/sprite_interact.rs index 8faa350d18..59fbc8fb90 100644 --- a/common/src/states/sprite_interact.rs +++ b/common/src/states/sprite_interact.rs @@ -14,7 +14,7 @@ use std::time::Duration; use vek::Vec3; /// Separated out to condense update portions of character state -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct StaticData { /// Buildup to sprite interaction pub buildup_duration: Duration, @@ -32,7 +32,7 @@ pub struct StaticData { pub was_sneak: bool, } -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Data { /// Struct containing data that does not change over the course of the /// character state @@ -128,7 +128,7 @@ impl CharacterBehavior for Data { } /// Used to control effects based off of the type of sprite interacted with -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum SpriteInteractKind { Chest, Harvestable, diff --git a/common/src/states/use_item.rs b/common/src/states/use_item.rs index 5d6a2fac9c..d350a5c9ed 100644 --- a/common/src/states/use_item.rs +++ b/common/src/states/use_item.rs @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; use std::time::Duration; /// Separated out to condense update portions of character state -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct StaticData { /// Buildup to item use pub buildup_duration: Duration, @@ -39,7 +39,7 @@ pub struct StaticData { pub was_sneak: bool, } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Data { /// Struct containing data that does not change over the course of the /// character state @@ -163,7 +163,7 @@ impl CharacterBehavior for Data { } /// Used to control effects based off of the type of item used -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum ItemUseKind { Consumable(ConsumableKind), } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 5dfa4a0897..7641f091c3 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -1199,7 +1199,7 @@ pub enum ForcedMovement { }, } -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum MovementDirection { Look, Move, @@ -1253,7 +1253,7 @@ impl AbilityInfo { } } -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum HandInfo { TwoHanded, MainHand, diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index 0cfea7f298..ebe089e58b 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -12,7 +12,7 @@ use crate::{ }; use serde::{Deserialize, Serialize}; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct Data { pub is_sneaking: bool, } diff --git a/common/src/terrain/site.rs b/common/src/terrain/site.rs index b1652df67c..b4de963cba 100644 --- a/common/src/terrain/site.rs +++ b/common/src/terrain/site.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum SiteKindMeta { Dungeon(DungeonKindMeta), Cave, @@ -9,13 +9,13 @@ pub enum SiteKindMeta { Void, } -#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum DungeonKindMeta { Old, Gnarling, } -#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum SettlementKindMeta { Default, Cliff, diff --git a/common/src/terrain/structure.rs b/common/src/terrain/structure.rs index 1465e8cb2d..78eeea91ed 100644 --- a/common/src/terrain/structure.rs +++ b/common/src/terrain/structure.rs @@ -12,7 +12,7 @@ use vek::*; make_case_elim!( structure_block, - #[derive(Copy, Clone, PartialEq, Debug, Deserialize)] + #[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize)] #[repr(u8)] pub enum StructureBlock { None = 0, diff --git a/common/src/trade.rs b/common/src/trade.rs index 6d03dfae73..496c05358e 100644 --- a/common/src/trade.rs +++ b/common/src/trade.rs @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize}; use strum::EnumIter; use tracing::{trace, warn}; -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TradePhase { Mutate, Review, @@ -22,7 +22,7 @@ pub enum TradePhase { /// Clients submit `TradeAction` to the server, which adds the Uid of the /// player out-of-band (i.e. without trusting the client to say who it's /// accepting on behalf of) -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TradeAction { AddItem { item: InvSlotId, @@ -41,7 +41,7 @@ pub enum TradeAction { Decline, } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum TradeResult { Completed, Declined, @@ -73,7 +73,7 @@ pub enum TradeResult { /// trading currently-equipped items (since `EquipSlot`s are disjoint from /// `InvSlotId`s), which avoids the issues associated with trading equipped bags /// that may still have contents. -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct PendingTrade { /// `parties[0]` is the entity that initiated the trade, parties[1] is the /// other entity that's being traded with @@ -239,7 +239,7 @@ impl Trades { None => return, } } - trade.process_trade_action(party, action, &*inventories); + trade.process_trade_action(party, action, &inventories); } else { warn!( "An entity who is not a party to trade {:?} tried to modify it", diff --git a/common/state/src/plugin/errors.rs b/common/state/src/plugin/errors.rs index 1709c60365..b206b47002 100644 --- a/common/state/src/plugin/errors.rs +++ b/common/state/src/plugin/errors.rs @@ -13,7 +13,7 @@ pub enum PluginError { #[derive(Debug)] pub enum PluginModuleError { - InstantiationError(InstantiationError), + InstantiationError(Box), MemoryAllocation(MemoryAllocationError), MemoryUninit(ExportError), FindFunction(ExportError), diff --git a/common/state/src/plugin/mod.rs b/common/state/src/plugin/mod.rs index 8197f4b076..034e7f07ad 100644 --- a/common/state/src/plugin/mod.rs +++ b/common/state/src/plugin/mod.rs @@ -114,7 +114,7 @@ pub struct PluginMgr { impl PluginMgr { pub fn from_assets() -> Result { - let mut assets_path = (&*ASSETS_PATH).clone(); + let mut assets_path = (*ASSETS_PATH).clone(); assets_path.push("plugins"); info!("Searching {:?} for plugins...", assets_path); Self::from_dir(assets_path) diff --git a/common/state/src/plugin/module.rs b/common/state/src/plugin/module.rs index b7cdfec56e..f104f2a1a3 100644 --- a/common/state/src/plugin/module.rs +++ b/common/state/src/plugin/module.rs @@ -37,7 +37,7 @@ impl PluginModule { // We are creating an enironnement let store = Store::new(&engine); // We are compiling the WASM file in the previously generated environement - let module = Module::new(&store, &wasm_data).expect("Can't compile"); + let module = Module::new(&store, wasm_data).expect("Can't compile"); // This is the function imported into the wasm environement fn raw_emit_actions(env: &HostFunctionEnvironement, ptr: i64, len: i64) { @@ -79,7 +79,7 @@ impl PluginModule { // Create an instance (Code execution environement) let instance = Instance::new(&module, &import_object) - .map_err(PluginModuleError::InstantiationError)?; + .map_err(|err| PluginModuleError::InstantiationError(Box::new(err)))?; Ok(Self { memory_manager, ecs, diff --git a/common/systems/src/buff.rs b/common/systems/src/buff.rs index 56d47e933c..fb70b7e122 100644 --- a/common/systems/src/buff.rs +++ b/common/systems/src/buff.rs @@ -212,7 +212,7 @@ impl<'a> System<'a> for Sys { for (kind, ids) in buff_comp_kinds.iter() { if kind.queues() { if let Some((Some(buff), id)) = - ids.get(0).map(|id| (buff_comp_buffs.get_mut(id), id)) + ids.first().map(|id| (buff_comp_buffs.get_mut(id), id)) { tick_buff(*id, buff, dt, |id| expired_buffs.push(id)); } @@ -262,7 +262,7 @@ impl<'a> System<'a> for Sys { buff.kind, buff.time, &read_data, - &mut *stat, + &mut stat, health, energy, entity, diff --git a/common/systems/src/lib.rs b/common/systems/src/lib.rs index a88b20b9b9..05fab14477 100644 --- a/common/systems/src/lib.rs +++ b/common/systems/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(bool_to_option, let_else, btree_drain_filter)] +#![feature(let_else, btree_drain_filter)] #![allow(clippy::option_map_unit_fn)] mod aura; diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index 86fb126403..7c2b98c138 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -540,7 +540,7 @@ impl<'a> PhysicsData<'a> { .join() { let vol = match collider { - Collider::Voxel { id } => voxel_colliders_manifest.colliders.get(&*id), + Collider::Voxel { id } => voxel_colliders_manifest.colliders.get(id), Collider::Volume(vol) => Some(&**vol), _ => None, }; diff --git a/network/examples/chat.rs b/network/examples/chat.rs index d52db59d3a..8e2641ba22 100644 --- a/network/examples/chat.rs +++ b/network/examples/chat.rs @@ -23,7 +23,7 @@ fn main() { .short('m') .long("mode") .takes_value(true) - .possible_values(&["server", "client", "both"]) + .possible_values(["server", "client", "both"]) .default_value("both") .help( "choose whether you want to start the server or client or both needed for \ @@ -50,7 +50,7 @@ fn main() { .long("protocol") .takes_value(true) .default_value("tcp") - .possible_values(&["tcp", "upd", "mpsc"]) + .possible_values(["tcp", "upd", "mpsc"]) .help( "underlying protocol used for this test, mpsc can only combined with mode=both", ), @@ -61,7 +61,7 @@ fn main() { .long("trace") .takes_value(true) .default_value("warn") - .possible_values(&["trace", "debug", "info", "warn", "error"]) + .possible_values(["trace", "debug", "info", "warn", "error"]) .help("set trace level, not this has a performance impact!"), ) .get_matches(); diff --git a/network/examples/fileshare/commands.rs b/network/examples/fileshare/commands.rs index 9f23ddb6aa..f2f5f36b59 100644 --- a/network/examples/fileshare/commands.rs +++ b/network/examples/fileshare/commands.rs @@ -22,7 +22,7 @@ pub enum Command { Get(u32), } -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] pub struct FileInfo { id: u32, pub path: String, diff --git a/network/examples/fileshare/main.rs b/network/examples/fileshare/main.rs index f821a211af..9c82166295 100644 --- a/network/examples/fileshare/main.rs +++ b/network/examples/fileshare/main.rs @@ -34,7 +34,7 @@ fn main() { .long("trace") .takes_value(true) .default_value("warn") - .possible_values(&["trace", "debug", "info", "warn", "error"]) + .possible_values(["trace", "debug", "info", "warn", "error"]) .help("set trace level, not this has a performance impact!"), ) .get_matches(); diff --git a/network/examples/network-speed/main.rs b/network/examples/network-speed/main.rs index 931989c2ac..a35eac0940 100644 --- a/network/examples/network-speed/main.rs +++ b/network/examples/network-speed/main.rs @@ -36,7 +36,7 @@ fn main() { .short('m') .long("mode") .takes_value(true) - .possible_values(&["server", "client", "both"]) + .possible_values(["server", "client", "both"]) .default_value("both") .help( "choose whether you want to start the server or client or both needed for \ @@ -63,7 +63,7 @@ fn main() { .long("protocol") .takes_value(true) .default_value("tcp") - .possible_values(&["tcp", "udp", "mpsc"]) + .possible_values(["tcp", "udp", "mpsc"]) .help( "underlying protocol used for this test, mpsc can only combined with mode=both", ), @@ -74,7 +74,7 @@ fn main() { .long("trace") .takes_value(true) .default_value("warn") - .possible_values(&["trace", "debug", "info", "warn", "error"]) + .possible_values(["trace", "debug", "info", "warn", "error"]) .help("set trace level, not this has a performance impact!"), ) .get_matches(); diff --git a/network/protocol/src/error.rs b/network/protocol/src/error.rs index 3c63a4907d..0601e4e4c7 100644 --- a/network/protocol/src/error.rs +++ b/network/protocol/src/error.rs @@ -1,7 +1,7 @@ /// All possible Errors that can happen during Handshake [`InitProtocol`] /// /// [`InitProtocol`]: crate::InitProtocol -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum InitProtocolError { Custom(E), /// expected Handshake, didn't get handshake @@ -13,7 +13,7 @@ pub enum InitProtocolError { } /// When you return closed you must stay closed! -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum ProtocolError { /// Custom Error on the underlying I/O, /// e.g. the TCP, UDP or MPSC connection is dropped by the OS diff --git a/network/protocol/src/event.rs b/network/protocol/src/event.rs index f0f333ed8a..a57e0a77df 100644 --- a/network/protocol/src/event.rs +++ b/network/protocol/src/event.rs @@ -9,7 +9,7 @@ use bytes::Bytes; /// [`SendProtocol`]: crate::SendProtocol /// [`RecvProtocol`]: crate::RecvProtocol #[derive(Debug, Clone)] -#[cfg_attr(test, derive(PartialEq))] +#[cfg_attr(test, derive(PartialEq, Eq))] pub enum ProtocolEvent { Shutdown, OpenStream { diff --git a/network/protocol/src/frame.rs b/network/protocol/src/frame.rs index bcf548ca7f..fc95aff072 100644 --- a/network/protocol/src/frame.rs +++ b/network/protocol/src/frame.rs @@ -14,7 +14,7 @@ const FRAME_RAW: u8 = 8; //const FRAME_RESERVED_3: u8 = 13; /// Used for Communication between Channel <----(TCP/UDP)----> Channel -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum InitFrame { Handshake { magic_number: [u8; 7], @@ -30,7 +30,7 @@ pub enum InitFrame { } /// Used for OUT TCP Communication between Channel --(TCP)--> Channel -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum OTFrame { Shutdown, /* Shutdown this channel gracefully, if all channels are shutdown (gracefully), * Participant is deleted */ @@ -55,7 +55,7 @@ pub enum OTFrame { } /// Used for IN TCP Communication between Channel <--(TCP)-- Channel -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum ITFrame { Shutdown, /* Shutdown this channel gracefully, if all channels are shutdown (gracefully), * Participant is deleted */ @@ -113,7 +113,7 @@ impl InitFrame { } pub(crate) fn read_frame(bytes: &mut BytesMut) -> Option { - let frame_no = match bytes.get(0) { + let frame_no = match bytes.first() { Some(&f) => f, None => return None, }; @@ -454,7 +454,7 @@ mod tests { magic_number: VELOREN_MAGIC_NUMBER, version: VELOREN_NETWORK_VERSION, }; - let _ = InitFrame::write_bytes(frame1, &mut buffer); + InitFrame::write_bytes(frame1, &mut buffer); buffer.truncate(6); // simulate partial retrieve let frame1d = InitFrame::read_frame(&mut buffer); assert_eq!(frame1d, None); @@ -474,7 +474,7 @@ mod tests { let mut buffer = BytesMut::with_capacity(50); let frame1 = InitFrame::Raw(b"foobar".to_vec()); - let _ = InitFrame::write_bytes(frame1.clone(), &mut buffer); + InitFrame::write_bytes(frame1.clone(), &mut buffer); buffer[1] = 255; let framed = InitFrame::read_frame(&mut buffer); assert_eq!(framed, Some(frame1)); @@ -485,7 +485,7 @@ mod tests { let mut buffer = BytesMut::with_capacity(50); let frame1 = InitFrame::Raw(b"foobar".to_vec()); - let _ = InitFrame::write_bytes(frame1, &mut buffer); + InitFrame::write_bytes(frame1, &mut buffer); buffer[1] = 3; let framed = InitFrame::read_frame(&mut buffer); // we accept a different frame here, as it's RAW and debug only! diff --git a/network/protocol/src/quic.rs b/network/protocol/src/quic.rs index 566364e017..d61d9113b5 100644 --- a/network/protocol/src/quic.rs +++ b/network/protocol/src/quic.rs @@ -18,7 +18,7 @@ use tracing::info; #[cfg(feature = "trace_pedantic")] use tracing::trace; -#[derive(PartialEq)] +#[derive(PartialEq, Eq)] pub enum QuicDataFormatStream { Main, Reliable(Sid), diff --git a/network/src/api.rs b/network/src/api.rs index 9fb3526c3c..096bded719 100644 --- a/network/src/api.rs +++ b/network/src/api.rs @@ -121,7 +121,7 @@ pub enum NetworkConnectError { } /// Error type thrown by [`Participants`](Participant) methods -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum ParticipantError { ///Participant was closed by remote side ParticipantDisconnected, diff --git a/rust-toolchain b/rust-toolchain index f6f9b5b6c6..62193b6c62 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2022-04-25 +nightly-2022-09-08 diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index e88c6d7572..78b8ff89f2 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -1,6 +1,5 @@ #![deny(unsafe_code)] #![deny(clippy::clone_on_ref_ptr)] -#![feature(bool_to_option)] #[cfg(target_os = "windows")] #[global_allocator] diff --git a/server/src/chunk_serialize.rs b/server/src/chunk_serialize.rs index 4986bd0f49..3c11cd8e50 100644 --- a/server/src/chunk_serialize.rs +++ b/server/src/chunk_serialize.rs @@ -13,7 +13,7 @@ use vek::Vec2; /// Deferring allows us to remove code duplication and maybe serialize ONCE, /// send to MULTIPLE clients /// TODO: store a urgent flag and seperate even more, 5 ticks vs 5 seconds -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct ChunkSendEntry { pub(crate) entity: Entity, pub(crate) chunk_key: Vec2, diff --git a/server/src/cmd.rs b/server/src/cmd.rs index d868cfef3c..7f273b87bf 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -517,7 +517,7 @@ fn handle_give_item( ) -> CmdResult<()> { if let (Some(item_name), give_amount_opt) = parse_cmd_args!(args, String, u32) { let give_amount = give_amount_opt.unwrap_or(1); - if let Ok(item) = Item::new_from_asset(&item_name.replace('/', ".").replace('\\', ".")) { + if let Ok(item) = Item::new_from_asset(&item_name.replace(['/', '\\'], ".")) { let mut item: Item = item; let mut res = Ok(()); @@ -1844,7 +1844,7 @@ fn handle_kill_npcs( true }; - should_kill.then(|| entity) + should_kill.then_some(entity) }) .collect::>() }; diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index b4ccbb7d9d..f435bbbdd2 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -278,7 +278,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt let entry = damage_contributors .entry(DamageContrib::Group(*group)) .or_insert((0, 0.0)); - (*entry).0 += damage; + entry.0 += damage; }, } } diff --git a/server/src/lib.rs b/server/src/lib.rs index b8185565da..e76b90c299 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -2,10 +2,8 @@ #![allow(clippy::option_map_unit_fn)] #![deny(clippy::clone_on_ref_ptr)] #![feature( - bool_to_option, box_patterns, drain_filter, - label_break_value, let_chains, let_else, never_type, @@ -490,7 +488,7 @@ impl Server { use std::fs; match || -> Result<_, Box> { - let key = fs::read(&key_file_path)?; + let key = fs::read(key_file_path)?; let key = if key_file_path.extension().map_or(false, |x| x == "der") { rustls::PrivateKey(key) } else { @@ -506,7 +504,7 @@ impl Server { .ok_or("No valid pem key in file")?; rustls::PrivateKey(key) }; - let cert_chain = fs::read(&cert_file_path)?; + let cert_chain = fs::read(cert_file_path)?; let cert_chain = if cert_file_path.extension().map_or(false, |x| x == "der") { vec![rustls::Certificate(cert_chain)] @@ -585,7 +583,7 @@ impl Server { let editable_settings = self.state.ecs().fetch::(); ServerInfo { name: settings.server_name.clone(), - description: (&*editable_settings.server_description).clone(), + description: (*editable_settings.server_description).clone(), git_hash: common::util::GIT_HASH.to_string(), git_date: common::util::GIT_DATE.to_string(), auth_provider: settings.auth_server_address.clone(), diff --git a/server/src/persistence/character_loader.rs b/server/src/persistence/character_loader.rs index 98b630d0c4..1e496255c0 100644 --- a/server/src/persistence/character_loader.rs +++ b/server/src/persistence/character_loader.rs @@ -86,7 +86,7 @@ impl CharacterLoader { // This connection -must- remain read-only to avoid lock contention with the // CharacterUpdater thread. let mut conn = - establish_connection(&*settings.read().unwrap(), ConnectionMode::ReadOnly); + establish_connection(&settings.read().unwrap(), ConnectionMode::ReadOnly); for request in internal_rx { conn.update_log_mode(&settings); diff --git a/server/src/persistence/character_updater.rs b/server/src/persistence/character_updater.rs index 565903f67b..3e1e5787c8 100644 --- a/server/src/persistence/character_updater.rs +++ b/server/src/persistence/character_updater.rs @@ -83,7 +83,7 @@ impl CharacterUpdater { // Unwrap here is safe as there is no code that can panic when the write lock is // taken that could cause the RwLock to become poisoned. let mut conn = - establish_connection(&*settings.read().unwrap(), ConnectionMode::ReadWrite); + establish_connection(&settings.read().unwrap(), ConnectionMode::ReadWrite); while let Ok(updates) = update_rx.recv() { match updates { CharacterUpdaterEvent::BatchUpdate(updates) => { diff --git a/server/src/persistence/mod.rs b/server/src/persistence/mod.rs index c84f5e1675..02d02a9690 100644 --- a/server/src/persistence/mod.rs +++ b/server/src/persistence/mod.rs @@ -63,12 +63,12 @@ impl VelorenConnection { let settings = database_settings .read() .expect("DatabaseSettings RwLock was poisoned"); - if self.sql_log_mode == (*settings).sql_log_mode { + if self.sql_log_mode == settings.sql_log_mode { return; } - set_log_mode(&mut self.connection, (*settings).sql_log_mode); - self.sql_log_mode = (*settings).sql_log_mode; + set_log_mode(&mut self.connection, settings.sql_log_mode); + self.sql_log_mode = settings.sql_log_mode; info!( "SQL log mode for connection changed to {:?}", @@ -106,13 +106,13 @@ pub struct DatabaseSettings { pub sql_log_mode: SqlLogMode, } -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub enum ConnectionMode { ReadOnly, ReadWrite, } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum SqlLogMode { /// Logging is disabled Disabled, @@ -199,10 +199,8 @@ pub(crate) fn establish_connection( settings: &DatabaseSettings, connection_mode: ConnectionMode, ) -> VelorenConnection { - fs::create_dir_all(&settings.db_dir).expect(&*format!( - "Failed to create saves directory: {:?}", - &settings.db_dir - )); + fs::create_dir_all(&settings.db_dir) + .unwrap_or_else(|_| panic!("Failed to create saves directory: {:?}", &settings.db_dir)); let open_flags = OpenFlags::SQLITE_OPEN_PRIVATE_CACHE | OpenFlags::SQLITE_OPEN_NO_MUTEX diff --git a/server/src/rtsim/entity.rs b/server/src/rtsim/entity.rs index 25a25f9785..a26662bd30 100644 --- a/server/src/rtsim/entity.rs +++ b/server/src/rtsim/entity.rs @@ -88,7 +88,7 @@ impl Entity { .into() }, _ => { - let species = *(&comp::humanoid::ALL_SPECIES) + let species = *comp::humanoid::ALL_SPECIES .choose(&mut self.rng(PERM_SPECIES)) .unwrap(); comp::humanoid::Body::random_with(&mut self.rng(PERM_BODY), &species).into() @@ -102,7 +102,7 @@ impl Entity { | RtSimEntityKind::Alchemist | RtSimEntityKind::Blacksmith | RtSimEntityKind::Merchant => { - let species = *(&comp::humanoid::ALL_SPECIES) + let species = *comp::humanoid::ALL_SPECIES .choose(&mut self.rng(PERM_SPECIES)) .unwrap(); comp::humanoid::Body::random_with(&mut self.rng(PERM_BODY), &species).into() diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 5a271b5131..b4d5891139 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -703,8 +703,10 @@ impl StateExt for State { msg: &str, ) -> bool { let mut automod = self.ecs().write_resource::(); - let Some(client) = self.ecs().read_storage::().get(entity) else { return true }; - let Some(player) = self.ecs().read_storage::().get(entity) else { return true }; + let client = self.ecs().read_storage::(); + let player = self.ecs().read_storage::(); + let Some(client) = client.get(entity) else { return true }; + let Some(player) = player.get(entity) else { return true }; match automod.validate_chat_msg( player.uuid(), diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index fecb5948ac..738a6cb1e6 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -557,7 +557,7 @@ impl<'a> AgentData<'a> { tgt_pos: &Pos, ) { if let Some((bearing, speed)) = agent.chaser.chase( - &*terrain, + terrain, self.pos.0, self.vel.0, tgt_pos.0, @@ -666,7 +666,7 @@ impl<'a> AgentData<'a> { } if let Some((bearing, speed)) = agent.chaser.chase( - &*terrain, + terrain, self.pos.0, self.vel.0, // Away from the target (ironically) diff --git a/server/src/sys/entity_sync.rs b/server/src/sys/entity_sync.rs index 8032765efa..7d7bf4ca16 100644 --- a/server/src/sys/entity_sync.rs +++ b/server/src/sys/entity_sync.rs @@ -393,7 +393,7 @@ impl<'a> System<'a> for Sys { let outcomes = outcomes .iter() - .filter(|o| o.get_pos().and_then(&is_near).unwrap_or(true)) + .filter(|o| o.get_pos().and_then(is_near).unwrap_or(true)) .cloned() .collect::>(); diff --git a/server/src/sys/msg/register.rs b/server/src/sys/msg/register.rs index 147d8e117d..940616b9a1 100644 --- a/server/src/sys/msg/register.rs +++ b/server/src/sys/msg/register.rs @@ -136,9 +136,9 @@ impl<'a> System<'a> for Sys { &ecs_world, #[cfg(feature = "plugins")] &read_data._plugin_mgr, - &*read_data.editable_settings.admins, - &*read_data.editable_settings.whitelist, - &*read_data.editable_settings.banlist, + &read_data.editable_settings.admins, + &read_data.editable_settings.whitelist, + &read_data.editable_settings.banlist, player_count >= max_players, ) { None => return Ok(()), @@ -232,11 +232,11 @@ impl<'a> System<'a> for Sys { time_of_day: *read_data.time_of_day, max_group_size: read_data.settings.max_player_group_size, client_timeout: read_data.settings.client_timeout, - world_map: (&*read_data.map).clone(), + world_map: (*read_data.map).clone(), recipe_book: default_recipe_book().cloned(), component_recipe_book: default_component_recipe_book().cloned(), - material_stats: (&*read_data.material_stats).clone(), - ability_map: (&*read_data.ability_map).clone(), + material_stats: (*read_data.material_stats).clone(), + ability_map: (*read_data.ability_map).clone(), })?; debug!("Done initial sync with client."); diff --git a/server/src/sys/terrain.rs b/server/src/sys/terrain.rs index 369852785b..b2ae5f1ed6 100644 --- a/server/src/sys/terrain.rs +++ b/server/src/sys/terrain.rs @@ -436,7 +436,7 @@ impl NpcData { comp::Agent::from_body(&body) .with_behavior( Behavior::default() - .maybe_with_capabilities(can_speak.then(|| BehaviorCapability::SPEAK)) + .maybe_with_capabilities(can_speak.then_some(BehaviorCapability::SPEAK)) .with_trade_site(trade_for_site), ) .with_patrol_origin(pos) diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 180eab04e1..aa3c87fff8 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -59,7 +59,9 @@ winit = {version = "0.25.0", features = ["serde"]} wgpu = { version = "=0.8.0", features = ["trace", "cross"] } wgpu-profiler = { git = "https://github.com/Imberflur/wgpu-profiler", tag = "wgpu-0.8" } bytemuck = { version="1.4", features=["derive"] } -shaderc = "0.8.0" +# shaderc = "0.8.0" +# Working around a current bug in shaderc that causes it to use the system installation even if we specify compile from source +shaderc = { git = "https://github.com/pythonesque/shaderc-rs", rev = "f2605a02062834019bedff911aee2fd2998c49f9" } # cmake crate used by shaderc, newer version 0.1.46 uses a new cmake command that is not available in our CI cmake version # see https://github.com/alexcrichton/cmake-rs/issues/131 cmake = "=0.1.45" diff --git a/voxygen/anim/src/arthropod/mod.rs b/voxygen/anim/src/arthropod/mod.rs index 4311c138d0..c9aee5f244 100644 --- a/voxygen/anim/src/arthropod/mod.rs +++ b/voxygen/anim/src/arthropod/mod.rs @@ -286,17 +286,17 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Sandcrawler, _) => (2.5, 7.0, -5.5), }, scaler: match (body.species, body.body_type) { - (Tarantula, _) => (1.0), - (Blackwidow, _) => (1.0), - (Antlion, _) => (1.0), - (Hornbeetle, _) => (0.8), - (Leafbeetle, _) => (0.8), - (Stagbeetle, _) => (0.8), - (Weevil, _) => (0.8), - (Cavespider, _) => (1.0), - (Moltencrawler, _) => (0.8), - (Mosscrawler, _) => (0.8), - (Sandcrawler, _) => (0.8), + (Tarantula, _) => 1.0, + (Blackwidow, _) => 1.0, + (Antlion, _) => 1.0, + (Hornbeetle, _) => 0.8, + (Leafbeetle, _) => 0.8, + (Stagbeetle, _) => 0.8, + (Weevil, _) => 0.8, + (Cavespider, _) => 1.0, + (Moltencrawler, _) => 0.8, + (Mosscrawler, _) => 0.8, + (Sandcrawler, _) => 0.8, }, // Z ori (front, front center, back center, center) leg_ori: match (body.species, body.body_type) { diff --git a/voxygen/anim/src/bird_large/mod.rs b/voxygen/anim/src/bird_large/mod.rs index c7232e012b..9b978e610d 100644 --- a/voxygen/anim/src/bird_large/mod.rs +++ b/voxygen/anim/src/bird_large/mod.rs @@ -276,24 +276,24 @@ impl<'a> From<&'a Body> for SkeletonAttr { (WealdWyvern, _) => (0.5, 0.0, -3.5), }, scaler: match (body.species, body.body_type) { - (Phoenix, _) => (1.0), - (Cockatrice, _) => (1.0), - (Roc, _) => (1.0), + (Phoenix, _) => 1.0, + (Cockatrice, _) => 1.0, + (Roc, _) => 1.0, (FlameWyvern, _) | (CloudWyvern, _) | (FrostWyvern, _) | (SeaWyvern, _) - | (WealdWyvern, _) => (1.0), + | (WealdWyvern, _) => 1.0, }, feed: match (body.species, body.body_type) { - (Phoenix, _) => (-0.65), - (Cockatrice, _) => (-0.5), - (Roc, _) => (-0.4), + (Phoenix, _) => -0.65, + (Cockatrice, _) => -0.5, + (Roc, _) => -0.4, (FlameWyvern, _) | (CloudWyvern, _) | (FrostWyvern, _) | (SeaWyvern, _) - | (WealdWyvern, _) => (-0.65), + | (WealdWyvern, _) => -0.65, }, wyvern: matches!( (body.species, body.body_type), diff --git a/voxygen/anim/src/dragon/mod.rs b/voxygen/anim/src/dragon/mod.rs index 48c91e673b..62315faf77 100644 --- a/voxygen/anim/src/dragon/mod.rs +++ b/voxygen/anim/src/dragon/mod.rs @@ -167,7 +167,7 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Reddragon, _) => (6.0, -2.0, -10.5), }, height: match (body.species, body.body_type) { - (Reddragon, _) => (1.0), + (Reddragon, _) => 1.0, }, } } diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index e3aa8d44f9..9a3457c825 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(generic_associated_types, bool_to_option)] +#![feature(generic_associated_types)] #![allow(incomplete_features)] #![allow(clippy::single_match)] #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] diff --git a/voxygen/anim/src/quadruped_low/mod.rs b/voxygen/anim/src/quadruped_low/mod.rs index e21d486d3e..2e97b5061c 100644 --- a/voxygen/anim/src/quadruped_low/mod.rs +++ b/voxygen/anim/src/quadruped_low/mod.rs @@ -331,42 +331,42 @@ impl<'a> From<&'a Body> for SkeletonAttr { _ => (0.0, 1.0), }, scaler: match (body.species, body.body_type) { - (Crocodile, _) => (1.05), - (SeaCrocodile, _) => (1.05), - (Alligator, _) => (1.12), - (Salamander, _) => (1.12), - (Monitor, _) => (0.9), - (Asp, _) => (1.12), - (Rocksnapper, _) => (1.12), - (Rootsnapper, _) => (1.12), - (Reefsnapper, _) => (1.12), - (Hakulaq, _) => (1.05), - (Dagon, _) => (1.05), - (Pangolin, _) => (1.05), - (Maneater, _) => (1.12), - (Lavadrake, _) => (1.12), - (Icedrake, _) => (1.12), - (Basilisk, _) => (1.3), - _ => (0.9), + (Crocodile, _) => 1.05, + (SeaCrocodile, _) => 1.05, + (Alligator, _) => 1.12, + (Salamander, _) => 1.12, + (Monitor, _) => 0.9, + (Asp, _) => 1.12, + (Rocksnapper, _) => 1.12, + (Rootsnapper, _) => 1.12, + (Reefsnapper, _) => 1.12, + (Hakulaq, _) => 1.05, + (Dagon, _) => 1.05, + (Pangolin, _) => 1.05, + (Maneater, _) => 1.12, + (Lavadrake, _) => 1.12, + (Icedrake, _) => 1.12, + (Basilisk, _) => 1.3, + _ => 0.9, }, tempo: match (body.species, body.body_type) { - (Crocodile, _) => (0.7), - (SeaCrocodile, _) => (0.7), - (Alligator, _) => (0.7), - (Salamander, _) => (0.85), - (Monitor, _) => (1.4), - (Tortoise, _) => (0.7), - (Rocksnapper, _) => (0.7), - (Rootsnapper, _) => (0.7), - (Reefsnapper, _) => (0.7), - (Hakulaq, _) => (1.2), - (Dagon, _) => (1.2), - (Pangolin, _) => (1.15), - (Maneater, _) => (0.9), - (Lavadrake, _) => (1.1), - (Icedrake, _) => (1.1), - (Basilisk, _) => (0.8), - _ => (1.0), + (Crocodile, _) => 0.7, + (SeaCrocodile, _) => 0.7, + (Alligator, _) => 0.7, + (Salamander, _) => 0.85, + (Monitor, _) => 1.4, + (Tortoise, _) => 0.7, + (Rocksnapper, _) => 0.7, + (Rootsnapper, _) => 0.7, + (Reefsnapper, _) => 0.7, + (Hakulaq, _) => 1.2, + (Dagon, _) => 1.2, + (Pangolin, _) => 1.15, + (Maneater, _) => 0.9, + (Lavadrake, _) => 1.1, + (Icedrake, _) => 1.1, + (Basilisk, _) => 0.8, + _ => 1.0, }, } } diff --git a/voxygen/anim/src/quadruped_medium/mod.rs b/voxygen/anim/src/quadruped_medium/mod.rs index c76c5bd6a8..fa5792b09b 100644 --- a/voxygen/anim/src/quadruped_medium/mod.rs +++ b/voxygen/anim/src/quadruped_medium/mod.rs @@ -606,96 +606,96 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Akhlut, _) => (1.5, -1.0, -4.5), }, scaler: match (body.species, body.body_type) { - (Grolgar, _) => (1.05), - (Saber, _) => (0.9), - (Tuskram, _) => (0.95), - (Lion, Male) => (1.05), - (Lion, Female) => (1.05), - (Tarasque, _) => (1.05), - (Tiger, _) => (0.95), - (Catoblepas, _) => (1.05), - (Roshwalr, _) => (1.05), - (Barghest, _) => (1.2), - (Antelope, _) => (0.95), - (Kelpie, _) => (1.1), - (Donkey, _) => (0.95), - (Horse, _) => (1.2), - (Zebra, _) => (1.05), - (Cattle, _) => (1.25), - (Highland, _) => (1.32), - (Bear, _) => (1.4), - (Yak, _) => (1.4), - (Camel, _) => (1.15), - (Dreadhorn, _) => (1.6), - (Moose, _) => (0.95), - (Snowleopard, _) => (0.95), - (Mammoth, _) => (3.0), - (Ngoubou, _) => (1.0), - (Akhlut, _) => (1.4), - _ => (0.9), + (Grolgar, _) => 1.05, + (Saber, _) => 0.9, + (Tuskram, _) => 0.95, + (Lion, Male) => 1.05, + (Lion, Female) => 1.05, + (Tarasque, _) => 1.05, + (Tiger, _) => 0.95, + (Catoblepas, _) => 1.05, + (Roshwalr, _) => 1.05, + (Barghest, _) => 1.2, + (Antelope, _) => 0.95, + (Kelpie, _) => 1.1, + (Donkey, _) => 0.95, + (Horse, _) => 1.2, + (Zebra, _) => 1.05, + (Cattle, _) => 1.25, + (Highland, _) => 1.32, + (Bear, _) => 1.4, + (Yak, _) => 1.4, + (Camel, _) => 1.15, + (Dreadhorn, _) => 1.6, + (Moose, _) => 0.95, + (Snowleopard, _) => 0.95, + (Mammoth, _) => 3.0, + (Ngoubou, _) => 1.0, + (Akhlut, _) => 1.4, + _ => 0.9, }, startangle: match (body.species, body.body_type) { //changes the default angle of front feet - (Grolgar, _) => (-0.3), - (Saber, _) => (-0.2), - (Tuskram, _) => (0.3), - (Lion, Male) => (-0.1), - (Lion, Female) => (-0.1), - (Tarasque, _) => (-0.5), - (Catoblepas, _) => (-0.5), - (Bonerattler, _) => (-0.7), - (Roshwalr, _) => (-0.3), - (Barghest, _) => (-0.5), - _ => (0.0), + (Grolgar, _) => -0.3, + (Saber, _) => -0.2, + (Tuskram, _) => 0.3, + (Lion, Male) => -0.1, + (Lion, Female) => -0.1, + (Tarasque, _) => -0.5, + (Catoblepas, _) => -0.5, + (Bonerattler, _) => -0.7, + (Roshwalr, _) => -0.3, + (Barghest, _) => -0.5, + _ => 0.0, }, tempo: match (body.species, body.body_type) { - (Grolgar, _) => (0.85), - (Saber, _) => (1.1), - (Tuskram, _) => (0.9), - (Lion, Male) => (0.95), - (Lion, Female) => (0.95), - (Tarasque, _) => (0.95), - (Wolf, _) => (1.1), - (Mouflon, _) => (0.85), - (Catoblepas, _) => (1.1), - (Deer, _) => (0.85), - (Hirdrasil, _) => (0.85), - (Roshwalr, _) => (0.75), - (Donkey, _) => (0.85), - (Zebra, _) => (0.85), - (Kelpie, _) => (0.85), - (Horse, _) => (0.85), - (Barghest, _) => (0.95), - (Darkhound, _) => (1.1), - (Cattle, _) => (0.8), - (Highland, _) => (0.8), - (Bear, _) => (0.8), - (Yak, _) => (0.8), - (Camel, _) => (1.8), - (Akhlut, _) => (0.95), - _ => (1.0), + (Grolgar, _) => 0.85, + (Saber, _) => 1.1, + (Tuskram, _) => 0.9, + (Lion, Male) => 0.95, + (Lion, Female) => 0.95, + (Tarasque, _) => 0.95, + (Wolf, _) => 1.1, + (Mouflon, _) => 0.85, + (Catoblepas, _) => 1.1, + (Deer, _) => 0.85, + (Hirdrasil, _) => 0.85, + (Roshwalr, _) => 0.75, + (Donkey, _) => 0.85, + (Zebra, _) => 0.85, + (Kelpie, _) => 0.85, + (Horse, _) => 0.85, + (Barghest, _) => 0.95, + (Darkhound, _) => 1.1, + (Cattle, _) => 0.8, + (Highland, _) => 0.8, + (Bear, _) => 0.8, + (Yak, _) => 0.8, + (Camel, _) => 1.8, + (Akhlut, _) => 0.95, + _ => 1.0, }, spring: match (body.species, body.body_type) { - (Grolgar, _) => (0.9), - (Saber, _) => (0.9), - (Tuskram, _) => (0.9), - (Wolf, _) => (1.2), - (Mouflon, _) => (0.9), - (Catoblepas, _) => (0.55), - (Bonerattler, _) => (1.1), - (Deer, _) => (0.9), - (Hirdrasil, _) => (1.1), - (Donkey, _) => (0.85), - (Camel, _) => (0.85), - (Zebra, _) => (0.85), - (Antelope, _) => (1.2), - (Kelpie, _) => (0.95), - (Horse, _) => (0.85), - (Darkhound, _) => (1.2), - (Dreadhorn, _) => (0.85), - (Moose, _) => (0.9), - (Snowleopard, _) => (1.1), - _ => (1.0), + (Grolgar, _) => 0.9, + (Saber, _) => 0.9, + (Tuskram, _) => 0.9, + (Wolf, _) => 1.2, + (Mouflon, _) => 0.9, + (Catoblepas, _) => 0.55, + (Bonerattler, _) => 1.1, + (Deer, _) => 0.9, + (Hirdrasil, _) => 1.1, + (Donkey, _) => 0.85, + (Camel, _) => 0.85, + (Zebra, _) => 0.85, + (Antelope, _) => 1.2, + (Kelpie, _) => 0.95, + (Horse, _) => 0.85, + (Darkhound, _) => 1.2, + (Dreadhorn, _) => 0.85, + (Moose, _) => 0.9, + (Snowleopard, _) => 1.1, + _ => 1.0, }, feed: match (body.species, body.body_type) { // TODO: Rework some species to allow for feed anim diff --git a/voxygen/anim/src/quadruped_small/mod.rs b/voxygen/anim/src/quadruped_small/mod.rs index ded341a054..2303e88169 100644 --- a/voxygen/anim/src/quadruped_small/mod.rs +++ b/voxygen/anim/src/quadruped_small/mod.rs @@ -270,122 +270,122 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Goat, _) => (-7.0, 0.0), }, scaler: match (body.species, body.body_type) { - (Pig, _) => (0.72), - (Fox, _) => (0.72), - (Boar, _) => (0.95), - (Jackalope, _) => (0.67), - (Skunk, _) => (0.72), - (Cat, _) => (0.67), - (Batfox, _) => (0.9), - (Holladon, _) => (1.12), - (Rabbit, _) => (0.56), - (Frog, _) => (0.56), - (Rat, _) => (0.5), - (Axolotl, _) => (0.5), - (Gecko, _) => (0.56), - (Turtle, _) => (0.67), - (Squirrel, _) => (0.4), - (Fungome, _) => (0.72), - (Porcupine, _) => (0.65), - (Hare, _) => (0.65), - _ => (0.8), + (Pig, _) => 0.72, + (Fox, _) => 0.72, + (Boar, _) => 0.95, + (Jackalope, _) => 0.67, + (Skunk, _) => 0.72, + (Cat, _) => 0.67, + (Batfox, _) => 0.9, + (Holladon, _) => 1.12, + (Rabbit, _) => 0.56, + (Frog, _) => 0.56, + (Rat, _) => 0.5, + (Axolotl, _) => 0.5, + (Gecko, _) => 0.56, + (Turtle, _) => 0.67, + (Squirrel, _) => 0.4, + (Fungome, _) => 0.72, + (Porcupine, _) => 0.65, + (Hare, _) => 0.65, + _ => 0.8, }, tempo: match (body.species, body.body_type) { - (Boar, _) => (1.1), - (Cat, _) => (1.1), - (Quokka, _) => (1.2), - (Hyena, _) => (1.1), - (Rabbit, _) => (1.15), - (Frog, _) => (1.15), - (Rat, _) => (1.0), - (Axolotl, _) => (1.2), - (Gecko, _) => (1.1), - (Turtle, _) => (3.0), - (Squirrel, _) => (1.15), - (Porcupine, _) => (1.2), - (Beaver, _) => (1.2), - (Hare, _) => (1.15), - _ => (1.0), + (Boar, _) => 1.1, + (Cat, _) => 1.1, + (Quokka, _) => 1.2, + (Hyena, _) => 1.1, + (Rabbit, _) => 1.15, + (Frog, _) => 1.15, + (Rat, _) => 1.0, + (Axolotl, _) => 1.2, + (Gecko, _) => 1.1, + (Turtle, _) => 3.0, + (Squirrel, _) => 1.15, + (Porcupine, _) => 1.2, + (Beaver, _) => 1.2, + (Hare, _) => 1.15, + _ => 1.0, }, maximize: match (body.species, body.body_type) { - (Fox, _) => (1.3), - (Sheep, _) => (1.1), - (Boar, _) => (1.4), - (Jackalope, _) => (1.2), - (Hyena, _) => (1.4), - (Rabbit, _) => (1.3), - (Frog, _) => (1.3), - (Axolotl, _) => (0.9), - (Turtle, _) => (0.8), - (Fungome, _) => (0.7), - (Hare, _) => (1.3), - _ => (1.0), + (Fox, _) => 1.3, + (Sheep, _) => 1.1, + (Boar, _) => 1.4, + (Jackalope, _) => 1.2, + (Hyena, _) => 1.4, + (Rabbit, _) => 1.3, + (Frog, _) => 1.3, + (Axolotl, _) => 0.9, + (Turtle, _) => 0.8, + (Fungome, _) => 0.7, + (Hare, _) => 1.3, + _ => 1.0, }, minimize: match (body.species, body.body_type) { - (Pig, _) => (0.6), - (Fox, _) => (1.3), - (Sheep, _) => (0.8), - (Jackalope, _) => (0.8), - (Skunk, _) => (0.9), - (Cat, _) => (0.8), - (Quokka, _) => (0.9), - (Holladon, _) => (0.7), - (Hyena, _) => (1.4), - (Rabbit, _) => (0.8), - (Frog, _) => (0.8), - (Turtle, _) => (0.8), - (Fungome, _) => (0.4), - (Porcupine, _) => (0.9), - (Beaver, _) => (0.9), - (Hare, _) => (0.8), - (Goat, _) => (0.8), - _ => (1.0), + (Pig, _) => 0.6, + (Fox, _) => 1.3, + (Sheep, _) => 0.8, + (Jackalope, _) => 0.8, + (Skunk, _) => 0.9, + (Cat, _) => 0.8, + (Quokka, _) => 0.9, + (Holladon, _) => 0.7, + (Hyena, _) => 1.4, + (Rabbit, _) => 0.8, + (Frog, _) => 0.8, + (Turtle, _) => 0.8, + (Fungome, _) => 0.4, + (Porcupine, _) => 0.9, + (Beaver, _) => 0.9, + (Hare, _) => 0.8, + (Goat, _) => 0.8, + _ => 1.0, }, spring: match (body.species, body.body_type) { - (Sheep, _) => (1.2), - (Boar, _) => (0.8), - (Jackalope, _) => (2.2), - (Cat, _) => (1.4), - (Batfox, _) => (1.1), - (Raccoon, _) => (1.1), - (Quokka, _) => (1.3), - (Holladon, _) => (0.7), - (Hyena, _) => (1.4), - (Rabbit, _) => (2.5), - (Truffler, _) => (0.8), - (Frog, _) => (2.5), - (Axolotl, _) => (0.8), - (Gecko, _) => (0.6), - (Turtle, _) => (0.7), - (Fungome, _) => (0.8), - (Porcupine, _) => (1.3), - (Beaver, _) => (1.3), - (Hare, Male) => (2.2), - (Hare, Female) => (2.5), - (Goat, _) => (1.2), - _ => (1.0), + (Sheep, _) => 1.2, + (Boar, _) => 0.8, + (Jackalope, _) => 2.2, + (Cat, _) => 1.4, + (Batfox, _) => 1.1, + (Raccoon, _) => 1.1, + (Quokka, _) => 1.3, + (Holladon, _) => 0.7, + (Hyena, _) => 1.4, + (Rabbit, _) => 2.5, + (Truffler, _) => 0.8, + (Frog, _) => 2.5, + (Axolotl, _) => 0.8, + (Gecko, _) => 0.6, + (Turtle, _) => 0.7, + (Fungome, _) => 0.8, + (Porcupine, _) => 1.3, + (Beaver, _) => 1.3, + (Hare, Male) => 2.2, + (Hare, Female) => 2.5, + (Goat, _) => 1.2, + _ => 1.0, }, feed: match (body.species, body.body_type) { - (Boar, _) => (0.6), - (Skunk, _) => (0.8), - (Batfox, _) => (0.7), - (Raccoon, _) => (0.8), - (Rabbit, _) => (1.2), - (Truffler, _) => (0.6), - (Frog, _) => (0.7), - (Axolotl, _) => (0.8), - (Gecko, _) => (0.8), - (Turtle, _) => (0.5), - (Fungome, _) => (0.7), - (Hare, _) => (1.2), - _ => (1.0), + (Boar, _) => 0.6, + (Skunk, _) => 0.8, + (Batfox, _) => 0.7, + (Raccoon, _) => 0.8, + (Rabbit, _) => 1.2, + (Truffler, _) => 0.6, + (Frog, _) => 0.7, + (Axolotl, _) => 0.8, + (Gecko, _) => 0.8, + (Turtle, _) => 0.5, + (Fungome, _) => 0.7, + (Hare, _) => 1.2, + _ => 1.0, }, lateral: match (body.species, body.body_type) { - (Axolotl, _) => (1.0), - (Gecko, _) => (1.0), - (Turtle, _) => (1.0), - (Fungome, _) => (1.0), - _ => (0.0), + (Axolotl, _) => 1.0, + (Gecko, _) => 1.0, + (Turtle, _) => 1.0, + (Fungome, _) => 1.0, + _ => 0.0, }, } } diff --git a/voxygen/anim/src/theropod/mod.rs b/voxygen/anim/src/theropod/mod.rs index 22397bfd80..60df30770f 100644 --- a/voxygen/anim/src/theropod/mod.rs +++ b/voxygen/anim/src/theropod/mod.rs @@ -248,15 +248,15 @@ impl<'a> From<&'a Body> for SkeletonAttr { (Ntouka, _) => (1.5, -1.0, -2.5), }, scaler: match (body.species, body.body_type) { - (Archaeos, _) => (2.93), - (Odonto, _) => (2.93), - (Sandraptor, _) => (1.1), - (Snowraptor, _) => (1.1), - (Woodraptor, _) => (1.1), - (Sunlizard, _) => (1.1), - (Yale, _) => (1.26), - (Dodarock, _) => (1.1), - (Ntouka, _) => (2.93), + (Archaeos, _) => 2.93, + (Odonto, _) => 2.93, + (Sandraptor, _) => 1.1, + (Snowraptor, _) => 1.1, + (Woodraptor, _) => 1.1, + (Sunlizard, _) => 1.1, + (Yale, _) => 1.26, + (Dodarock, _) => 1.1, + (Ntouka, _) => 2.93, }, } } diff --git a/voxygen/i18n/src/lib.rs b/voxygen/i18n/src/lib.rs index 435bb71884..be1bc8890b 100644 --- a/voxygen/i18n/src/lib.rs +++ b/voxygen/i18n/src/lib.rs @@ -165,7 +165,7 @@ impl assets::Compound for Language { for id in cache.load_dir::(path, true)?.ids() { match cache.load(id) { Ok(handle) => { - let source: &raw::Resource = &*handle.read(); + let source: &raw::Resource = &handle.read(); let src = source.src.clone(); // NOTE: diff --git a/voxygen/src/audio/channel.rs b/voxygen/src/audio/channel.rs index 8e82f45e9d..be082395cf 100644 --- a/voxygen/src/audio/channel.rs +++ b/voxygen/src/audio/channel.rs @@ -159,7 +159,7 @@ impl MusicChannel { /// AmbientChannelTags are used for non-positional sfx. Currently the only use /// is for wind. -#[derive(Debug, PartialEq, Clone, Copy, Deserialize, EnumIter)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, Deserialize, EnumIter)] pub enum AmbientChannelTag { Wind, Rain, diff --git a/voxygen/src/audio/fader.rs b/voxygen/src/audio/fader.rs index 7c624e981c..8a91b901ac 100644 --- a/voxygen/src/audio/fader.rs +++ b/voxygen/src/audio/fader.rs @@ -14,7 +14,7 @@ pub struct Fader { } /// Enables quick lookup of whether a fader is increasing or decreasing the /// channel volume -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum FadeDirection { In, Out, diff --git a/voxygen/src/cmd.rs b/voxygen/src/cmd.rs index 3cd0200ffd..46d90ceb50 100644 --- a/voxygen/src/cmd.rs +++ b/voxygen/src/cmd.rs @@ -85,7 +85,7 @@ impl FromStr for ClientChatCommand { fn from_str(keyword: &str) -> Result { Self::iter() .map(|c| (c.keyword(), c)) - .find_map(|(kwd, command)| (kwd == keyword).then(|| command)) + .find_map(|(kwd, command)| (kwd == keyword).then_some(command)) .ok_or(()) } } diff --git a/voxygen/src/hud/crafting.rs b/voxygen/src/hud/crafting.rs index 384099398e..07fcd3d0df 100644 --- a/voxygen/src/hud/crafting.rs +++ b/voxygen/src/hud/crafting.rs @@ -195,7 +195,7 @@ impl<'a> Crafting<'a> { } } -#[derive(Copy, Clone, Debug, EnumIter, PartialEq)] +#[derive(Copy, Clone, Debug, EnumIter, PartialEq, Eq)] pub enum CraftingTab { All, Tool, @@ -1343,22 +1343,30 @@ impl<'a> Widget for Crafting<'a> { // Craft button if Button::image(self.imgs.button) .w_h(105.0, 25.0) - .hover_image( - can_perform - .then_some(self.imgs.button_hover) - .unwrap_or(self.imgs.button), - ) - .press_image( - can_perform - .then_some(self.imgs.button_press) - .unwrap_or(self.imgs.button), - ) + .hover_image(if can_perform { + self.imgs.button_hover + } else { + self.imgs.button + }) + .press_image(if can_perform { + self.imgs.button_press + } else { + self.imgs.button + }) .label(&self.localized_strings.get_msg("hud-crafting-craft")) .label_y(conrod_core::position::Relative::Scalar(1.0)) - .label_color(can_perform.then_some(TEXT_COLOR).unwrap_or(TEXT_GRAY_COLOR)) + .label_color(if can_perform { + TEXT_COLOR + } else { + TEXT_GRAY_COLOR + }) .label_font_size(self.fonts.cyri.scale(12)) .label_font_id(self.fonts.cyri.conrod_id) - .image_color(can_perform.then_some(TEXT_COLOR).unwrap_or(TEXT_GRAY_COLOR)) + .image_color(if can_perform { + TEXT_COLOR + } else { + TEXT_GRAY_COLOR + }) .bottom_left_with_margins_on(state.ids.align_ing, -31.0, 15.0) .parent(state.ids.window_frame) .set(state.ids.btn_craft, ui) @@ -1396,30 +1404,30 @@ impl<'a> Widget for Crafting<'a> { let can_perform_all = can_perform && matches!(recipe_kind, RecipeKind::Simple); if Button::image(self.imgs.button) .w_h(105.0, 25.0) - .hover_image( - can_perform - .then_some(self.imgs.button_hover) - .unwrap_or(self.imgs.button), - ) - .press_image( - can_perform - .then_some(self.imgs.button_press) - .unwrap_or(self.imgs.button), - ) + .hover_image(if can_perform { + self.imgs.button_hover + } else { + self.imgs.button + }) + .press_image(if can_perform { + self.imgs.button_press + } else { + self.imgs.button + }) .label(&self.localized_strings.get_msg("hud-crafting-craft_all")) .label_y(conrod_core::position::Relative::Scalar(1.0)) - .label_color( - can_perform_all - .then_some(TEXT_COLOR) - .unwrap_or(TEXT_GRAY_COLOR), - ) + .label_color(if can_perform_all { + TEXT_COLOR + } else { + TEXT_GRAY_COLOR + }) .label_font_size(self.fonts.cyri.scale(12)) .label_font_id(self.fonts.cyri.conrod_id) - .image_color( - can_perform_all - .then_some(TEXT_COLOR) - .unwrap_or(TEXT_GRAY_COLOR), - ) + .image_color(if can_perform_all { + TEXT_COLOR + } else { + TEXT_GRAY_COLOR + }) .bottom_right_with_margins_on(state.ids.align_ing, -31.0, 15.0) .parent(state.ids.window_frame) .set(state.ids.btn_craft_all, ui) @@ -1670,7 +1678,7 @@ impl<'a> Widget for Crafting<'a> { // Grey color for images and text if their amount is too low to craft the // item - let item_count_in_inventory = self.inventory.item_count(&*item_def); + let item_count_in_inventory = self.inventory.item_count(&item_def); let col = if item_count_in_inventory >= u64::from(amount.max(1)) { TEXT_COLOR } else { diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index e8f9ef044e..91ac79187c 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -352,7 +352,7 @@ pub enum Event { ChangeSection(DiarySection), } -#[derive(PartialEq)] +#[derive(PartialEq, Eq)] pub enum DiarySection { SkillTrees, AbilitySelection, diff --git a/voxygen/src/hud/hotbar.rs b/voxygen/src/hud/hotbar.rs index c59e0c8f5c..f3fc7bab26 100644 --- a/voxygen/src/hud/hotbar.rs +++ b/voxygen/src/hud/hotbar.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use super::HudInfo; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Slot { One = 0, Two = 1, @@ -20,7 +20,7 @@ pub enum Slot { Ten = 9, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] pub enum SlotContents { Inventory(u64, ItemKey), Ability(usize), diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs index 09ef6478d7..ef0e05f5f8 100644 --- a/voxygen/src/hud/item_imgs.rs +++ b/voxygen/src/hud/item_imgs.rs @@ -170,7 +170,7 @@ fn graceful_load_segment_no_skin(specifier: &str) -> Arc { .map(|mat_cell| match mat_cell { MatCell::None => None, MatCell::Mat(_) => Some(MatCell::None), - MatCell::Normal(data) => data.is_hollow().then(|| MatCell::None), + MatCell::Normal(data) => data.is_hollow().then_some(MatCell::None), }) .to_segment(|_| Default::default()); Arc::new(seg) diff --git a/voxygen/src/hud/loot_scroller.rs b/voxygen/src/hud/loot_scroller.rs index 87143869ca..57567652ba 100644 --- a/voxygen/src/hud/loot_scroller.rs +++ b/voxygen/src/hud/loot_scroller.rs @@ -312,7 +312,7 @@ impl<'a> Widget for LootScroller<'a> { Quality::Artifact => self.imgs.inv_slot_orange, _ => self.imgs.inv_slot_red, }; - let quality_col = get_quality_col(&*item); + let quality_col = get_quality_col(item); Image::new(self.imgs.pixel) .color(Some(shade_color(quality_col.alpha(0.7)))) @@ -327,7 +327,7 @@ impl<'a> Widget for LootScroller<'a> { .set(state.ids.message_icon_frames[i], ui); Image::new(animate_by_pulse( - &self.item_imgs.img_ids_or_not_found_img((&*item).into()), + &self.item_imgs.img_ids_or_not_found_img(item.into()), self.pulse, )) .color(Some(shade_color(color::hsla(0.0, 0.0, 1.0, 1.0)))) @@ -335,7 +335,7 @@ impl<'a> Widget for LootScroller<'a> { .middle_of(state.ids.message_icon_bgs[i]) .with_item_tooltip( self.item_tooltip_manager, - core::iter::once(&*item as &dyn ItemDesc), + core::iter::once(item as &dyn ItemDesc), &None, &item_tooltip, ) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 76e0d70064..a6e96c96cd 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -577,7 +577,7 @@ pub enum Event { // TODO: Maybe replace this with bitflags. // `map` is not here because it currently is displayed over the top of other // open windows. -#[derive(PartialEq)] +#[derive(PartialEq, Eq)] pub enum Windows { Settings, // Display settings window. None, @@ -630,7 +630,7 @@ pub enum PressBehavior { #[serde(other)] Toggle = 0, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct ChatTab { pub label: String, pub filter: ChatFilter, @@ -1798,9 +1798,9 @@ impl Hud { }; self.failed_block_pickups - .retain(|_, t| pulse - (*t).pulse < overitem::PICKUP_FAILED_FADE_OUT_TIME); + .retain(|_, t| pulse - t.pulse < overitem::PICKUP_FAILED_FADE_OUT_TIME); self.failed_entity_pickups - .retain(|_, t| pulse - (*t).pulse < overitem::PICKUP_FAILED_FADE_OUT_TIME); + .retain(|_, t| pulse - t.pulse < overitem::PICKUP_FAILED_FADE_OUT_TIME); // Render overitem: name, etc. for (entity, pos, item, distance) in (&entities, &pos, &items) @@ -2061,7 +2061,7 @@ impl Hud { } else { None }; - (info.is_some() || bubble.is_some()).then(|| { + (info.is_some() || bubble.is_some()).then_some({ ( entity, pos, info, bubble, stats, skill_set, health, buffs, scale, body, hpfl, in_group, dist_sqr, alignment, is_mount, @@ -2897,7 +2897,7 @@ impl Hud { &info, &self.imgs, &self.fonts, - &*i18n, + i18n, self.pulse, &self.rot_imgs, item_tooltip_manager, @@ -3038,7 +3038,7 @@ impl Hud { &self.item_imgs, &self.rot_imgs, &self.fonts, - &*i18n, + i18n, &msm, item_tooltip_manager, self.pulse, diff --git a/voxygen/src/hud/settings_window/mod.rs b/voxygen/src/hud/settings_window/mod.rs index 6e55347e52..f7705c2337 100644 --- a/voxygen/src/hud/settings_window/mod.rs +++ b/voxygen/src/hud/settings_window/mod.rs @@ -47,7 +47,7 @@ widget_ids! { const RESET_BUTTONS_HEIGHT: f64 = 34.0; const RESET_BUTTONS_WIDTH: f64 = 155.0; -#[derive(Debug, EnumIter, PartialEq)] +#[derive(Debug, EnumIter, PartialEq, Eq)] pub enum SettingsTab { Interface, Chat, diff --git a/voxygen/src/hud/slots.rs b/voxygen/src/hud/slots.rs index 0b95ff6275..4de681b1e4 100644 --- a/voxygen/src/hud/slots.rs +++ b/voxygen/src/hud/slots.rs @@ -33,7 +33,7 @@ pub enum SlotKind { pub type SlotManager = slot::SlotManager; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct InventorySlot { pub slot: InvSlotId, pub entity: EcsEntity, @@ -74,7 +74,7 @@ impl SlotKey for EquipSlot { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct TradeSlot { pub index: usize, pub quantity: u32, @@ -115,7 +115,7 @@ impl SlotKey for TradeSlot { } } -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Eq)] pub enum HotbarImage { Item(ItemKey), Ability(String), @@ -203,7 +203,7 @@ impl<'a> SlotKey, HotbarImageSource<'a>> for HotbarSlot { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum AbilitySlot { Slot(usize), Ability(AuxiliaryAbility), diff --git a/voxygen/src/hud/trade.rs b/voxygen/src/hud/trade.rs index 16b3553082..05f1946f42 100644 --- a/voxygen/src/hud/trade.rs +++ b/voxygen/src/hud/trade.rs @@ -228,13 +228,9 @@ impl<'a> Trade<'a> { .unwrap_or_else(|| format!("Player {}", who)); let offer_header = if ours { - self.localized_strings - .get_msg("hud-trade-your_offer") - .to_owned() + self.localized_strings.get_msg("hud-trade-your_offer") } else { - self.localized_strings - .get_msg("hud-trade-their_offer") - .to_owned() + self.localized_strings.get_msg("hud-trade-their_offer") }; Text::new(&offer_header) diff --git a/voxygen/src/lib.rs b/voxygen/src/lib.rs index 644dccf3eb..5a3f6bf684 100644 --- a/voxygen/src/lib.rs +++ b/voxygen/src/lib.rs @@ -5,7 +5,6 @@ #![feature( array_methods, array_zip, - bool_to_option, drain_filter, once_cell, trait_alias, diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index 8bde511768..7d5eff9b10 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -1,5 +1,4 @@ #![deny(unsafe_code)] -#![feature(bool_to_option)] #![recursion_limit = "2048"] mod cli; diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index a345ad17f0..4100df4a1d 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -28,9 +28,9 @@ impl CharSelectionState { let scene = Scene::new( global_state.window.renderer_mut(), Some("fixture.selection_bg"), - &*client.borrow(), + &client.borrow(), ); - let char_selection_ui = CharSelectionUi::new(global_state, &*client.borrow()); + let char_selection_ui = CharSelectionUi::new(global_state, &client.borrow()); Self { char_selection_ui, diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index c0b7e4f2b1..fd118aaa36 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -68,7 +68,7 @@ pub trait Vertex: Clone + bytemuck::Pod { use serde::{Deserialize, Serialize}; /// Anti-aliasing modes -#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum AaMode { /// Fast approximate antialiasing. /// @@ -102,7 +102,7 @@ impl Default for AaMode { } /// Cloud modes -#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum CloudMode { /// No clouds. As cheap as it gets. None, @@ -132,7 +132,7 @@ impl Default for CloudMode { } /// Fluid modes -#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum FluidMode { /// "Cheap" water. This water implements no waves, no reflections, no /// diffraction, and no light attenuation through water. As a result, @@ -163,7 +163,7 @@ impl Default for FluidMode { } /// Lighting modes -#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum LightingMode { /// Ashikhmin-Shirley BRDF lighting model. Attempts to generate a /// physically plausible (to some extent) lighting distribution. @@ -251,7 +251,7 @@ impl Default for UpscaleMode { /// Present modes /// See https://docs.rs/wgpu/0.7.0/wgpu/enum.PresentMode.html -#[derive(Default, PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Default, PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] pub enum PresentMode { Mailbox, Immediate, diff --git a/voxygen/src/render/pipelines/bloom.rs b/voxygen/src/render/pipelines/bloom.rs index 80be67b0f8..6bb494059c 100644 --- a/voxygen/src/render/pipelines/bloom.rs +++ b/voxygen/src/render/pipelines/bloom.rs @@ -208,7 +208,7 @@ impl BloomPipelines { let upsample_pipeline = create_pipeline( "Bloom upsample pipeline", upsample_fs_module, - (!bloom_config.uniform_blur).then(|| wgpu::BlendState { + (!bloom_config.uniform_blur).then_some(wgpu::BlendState { color: wgpu::BlendComponent { src_factor: wgpu::BlendFactor::One, dst_factor: wgpu::BlendFactor::One, diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index 804b8aacb9..66e358e8cf 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -254,7 +254,7 @@ impl Renderer { let full_name = format!("#{} {} {:?}", i, info.name, info.device_type,); - full_name.contains(&filter).then(|| adapter) + full_name.contains(&filter).then_some(adapter) }), Some(_) | None => { runtime.block_on(instance.request_adapter(&wgpu::RequestAdapterOptionsBase { @@ -504,7 +504,7 @@ impl Renderer { #[cfg(feature = "egui-ui")] let egui_renderpass = - egui_wgpu_backend::RenderPass::new(&*device, TextureFormat::Bgra8UnormSrgb, 1); + egui_wgpu_backend::RenderPass::new(&device, TextureFormat::Bgra8UnormSrgb, 1); Ok(Self { device, diff --git a/voxygen/src/render/renderer/drawer.rs b/voxygen/src/render/renderer/drawer.rs index 2029b163ae..599461ab4b 100644 --- a/voxygen/src/render/renderer/drawer.rs +++ b/voxygen/src/render/renderer/drawer.rs @@ -1133,7 +1133,7 @@ impl<'pass_ref, 'pass: 'pass_ref> UiDrawer<'pass_ref, 'pass> { // Note: not actually prepared yet // we do this to avoid having to write extra code for the set functions let mut prepared = PreparedUiDrawer { - render_pass: &mut *self.render_pass, + render_pass: &mut self.render_pass, }; // Prepare prepared.set_locals(locals); diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 5d91d24281..602a4d701d 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -4896,7 +4896,7 @@ impl ItemDropCentralSpec { .map(|mat_cell| match mat_cell { MatCell::None => None, MatCell::Mat(_) => Some(MatCell::None), - MatCell::Normal(data) => data.is_hollow().then(|| MatCell::None), + MatCell::Normal(data) => data.is_hollow().then_some(MatCell::None), }) .to_segment(|_| Default::default()) }, diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 58ee56d2ed..634068f090 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -926,7 +926,7 @@ impl FigureMgr { let body = *body; // Only use trail manager when trails are enabled - let trail_mgr = scene_data.weapon_trails_enabled.then(|| &mut *trail_mgr); + let trail_mgr = scene_data.weapon_trails_enabled.then_some(&mut *trail_mgr); let common_params = FigureUpdateCommonParameters { entity: Some(entity), @@ -5859,11 +5859,11 @@ impl FigureMgr { arthropod_states, }, } = self; - let col_lights = &*col_lights_; + let col_lights = col_lights_; if let Some((bound, model_entry)) = match body { Body::Humanoid(body) => character_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -5880,7 +5880,7 @@ impl FigureMgr { }), Body::QuadrupedSmall(body) => quadruped_small_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -5897,7 +5897,7 @@ impl FigureMgr { }), Body::QuadrupedMedium(body) => quadruped_medium_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -5914,7 +5914,7 @@ impl FigureMgr { }), Body::QuadrupedLow(body) => quadruped_low_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -5931,7 +5931,7 @@ impl FigureMgr { }), Body::BirdMedium(body) => bird_medium_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -5948,7 +5948,7 @@ impl FigureMgr { }), Body::FishMedium(body) => fish_medium_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -5965,7 +5965,7 @@ impl FigureMgr { }), Body::Theropod(body) => theropod_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -5982,7 +5982,7 @@ impl FigureMgr { }), Body::Dragon(body) => dragon_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -5999,7 +5999,7 @@ impl FigureMgr { }), Body::BirdLarge(body) => bird_large_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6016,7 +6016,7 @@ impl FigureMgr { }), Body::FishSmall(body) => fish_small_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6033,7 +6033,7 @@ impl FigureMgr { }), Body::BipedLarge(body) => biped_large_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6050,7 +6050,7 @@ impl FigureMgr { }), Body::BipedSmall(body) => biped_small_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6067,7 +6067,7 @@ impl FigureMgr { }), Body::Golem(body) => golem_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6084,7 +6084,7 @@ impl FigureMgr { }), Body::Arthropod(body) => arthropod_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6101,7 +6101,7 @@ impl FigureMgr { }), Body::Object(body) => object_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6118,7 +6118,7 @@ impl FigureMgr { }), Body::ItemDrop(body) => item_drop_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6137,7 +6137,7 @@ impl FigureMgr { if body.manifest_entry().is_some() { ship_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), @@ -6155,7 +6155,7 @@ impl FigureMgr { } else { volume_states .get(&entity) - .filter(|state| filter_state(*state)) + .filter(|state| filter_state(state)) .map(move |state| { ( state.bound(), diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 47a50d8e40..8e625611a9 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -604,7 +604,7 @@ impl Scene { }; // Compute camera matrices. - self.camera.compute_dependents(&*scene_data.state.terrain()); + self.camera.compute_dependents(&scene_data.state.terrain()); let camera::Dependents { view_mat, view_mat_inv, diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index c6074c9f89..d7efa6827b 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -554,7 +554,7 @@ impl SpriteRenderContext { } }); - let init = core::lazy::OnceCell::new(); + let init = core::cell::OnceCell::new(); let mut join_handle = Some(join_handle); let mut closure = move |renderer: &mut Renderer| { // The second unwrap can only fail if the sprite meshing thread panics, which diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index 237c89da82..e1f4e2898b 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -103,7 +103,7 @@ impl SessionState { let mut scene = Scene::new( global_state.window.renderer_mut(), &mut global_state.lazy_init, - &*client.borrow(), + &client.borrow(), &global_state.settings, ); scene @@ -186,7 +186,7 @@ impl SessionState { // All this camera code is just to determine if it's underwater for the sfx // filter let camera = self.scene.camera_mut(); - camera.compute_dependents(&*client.state().terrain()); + camera.compute_dependents(&client.state().terrain()); let camera::Dependents { cam_pos, .. } = self.scene.camera().dependents(); let focus_pos = self.scene.camera().get_focus_pos(); let focus_off = focus_pos.map(|e| e.trunc()); @@ -474,7 +474,7 @@ impl PlayState for SessionState { } // Compute camera data - camera.compute_dependents(&*client.state().terrain()); + camera.compute_dependents(&client.state().terrain()); let camera::Dependents { cam_pos, cam_dir, .. } = self.scene.camera().dependents(); @@ -1195,7 +1195,7 @@ impl PlayState for SessionState { // Recompute dependents just in case some input modified the camera self.scene .camera_mut() - .compute_dependents(&*self.client.borrow().state().terrain()); + .compute_dependents(&self.client.borrow().state().terrain()); // Generate debug info, if needed // (it iterates through enough data that we might diff --git a/voxygen/src/session/settings_change.rs b/voxygen/src/session/settings_change.rs index 4c82431be8..79680466b2 100644 --- a/voxygen/src/session/settings_change.rs +++ b/voxygen/src/session/settings_change.rs @@ -395,7 +395,7 @@ impl SettingsChange { session_state .scene .camera_mut() - .compute_dependents(&*session_state.client.borrow().state().terrain()); + .compute_dependents(&session_state.client.borrow().state().terrain()); }, Graphics::ChangeGamma(new_gamma) => { settings.graphics.gamma = new_gamma; @@ -411,7 +411,7 @@ impl SettingsChange { global_state .window .renderer_mut() - .set_render_mode((&*new_render_mode).clone()) + .set_render_mode((*new_render_mode).clone()) .unwrap(); settings.graphics.render_mode = *new_render_mode; }, @@ -441,7 +441,7 @@ impl SettingsChange { session_state .scene .camera_mut() - .compute_dependents(&*session_state.client.borrow().state().terrain()); + .compute_dependents(&session_state.client.borrow().state().terrain()); // LoD session_state.scene.lod.set_detail(graphics.lod_detail); // Render mode diff --git a/voxygen/src/settings/chat.rs b/voxygen/src/settings/chat.rs index 6bca1a55c5..4b0b29ceac 100644 --- a/voxygen/src/settings/chat.rs +++ b/voxygen/src/settings/chat.rs @@ -8,7 +8,7 @@ use std::collections::HashSet; pub const MAX_CHAT_TABS: usize = 5; -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct ChatFilter { //messages pub message_all: bool, diff --git a/voxygen/src/settings/graphics.rs b/voxygen/src/settings/graphics.rs index 303bf77f49..c8919a5a76 100644 --- a/voxygen/src/settings/graphics.rs +++ b/voxygen/src/settings/graphics.rs @@ -2,7 +2,7 @@ use crate::{render::RenderMode, window::FullScreenSettings}; use serde::{Deserialize, Serialize}; use std::fmt; -#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)] +#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)] pub enum Fps { Max(u32), Unlimited, diff --git a/voxygen/src/ui/graphic/renderer.rs b/voxygen/src/ui/graphic/renderer.rs index bfb0fd12d4..05e4275bce 100644 --- a/voxygen/src/ui/graphic/renderer.rs +++ b/voxygen/src/ui/graphic/renderer.rs @@ -78,7 +78,7 @@ impl euc::Interpolate for VsOut { } } -impl<'a> Pipeline for Voxel { +impl Pipeline for Voxel { type Pixel = [u8; 4]; type Vertex = Vert; type VsOut = VsOut; diff --git a/voxygen/src/ui/ice/widget/tooltip.rs b/voxygen/src/ui/ice/widget/tooltip.rs index 0b8ac0860a..192e817314 100644 --- a/voxygen/src/ui/ice/widget/tooltip.rs +++ b/voxygen/src/ui/ice/widget/tooltip.rs @@ -124,7 +124,7 @@ impl TooltipManager { fn showing(&self, aabr: Aabr) -> Option<(Point, f32)> { match self.state { State::Idle | State::Start(_) => None, - State::Showing(show) => (show.aabr == aabr).then(|| { + State::Showing(show) => (show.aabr == aabr).then_some({ ( Point { x: show.hover_pos.x as f32, diff --git a/voxygen/src/ui/widgets/item_tooltip.rs b/voxygen/src/ui/widgets/item_tooltip.rs index e8d06bf9a4..d7c7c5d8c5 100644 --- a/voxygen/src/ui/widgets/item_tooltip.rs +++ b/voxygen/src/ui/widgets/item_tooltip.rs @@ -700,7 +700,7 @@ impl<'a> Widget for ItemTooltip<'a> { ); let mut diff_text = |text: String, color, id_index| { - widget::Text::new(&*text) + widget::Text::new(&text) .align_middle_y_of(state.ids.stats[id_index]) .right_from(state.ids.stats[id_index], H_PAD) .graphics_for(id) @@ -905,7 +905,7 @@ impl<'a> Widget for ItemTooltip<'a> { util::option_comparison(&armor_stats.stealth, &equipped_stats.stealth); let mut diff_text = |text: String, color, id_index| { - widget::Text::new(&*text) + widget::Text::new(&text) .align_middle_y_of(state.ids.stats[id_index]) .right_from(state.ids.stats[id_index], H_PAD) .graphics_for(id) diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index 575a9f6dbd..cfd4675c4f 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -1370,7 +1370,7 @@ pub enum FullscreenMode { impl Default for FullscreenMode { fn default() -> Self { FullscreenMode::Borderless } } -#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)] #[serde(default)] pub struct FullScreenSettings { pub enabled: bool, diff --git a/world/Cargo.toml b/world/Cargo.toml index a1f5428df4..7868245d9d 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -31,7 +31,7 @@ tracing = { version = "0.1", default-features = false } rand = "0.8" rand_chacha = "0.3" arr_macro = "0.1.2" -packed_simd = { package = "packed_simd_2", version = "0.3.5", optional = true } +packed_simd = { package = "packed_simd_2", version = "0.3.8", optional = true } rayon = "1.5" serde = { version = "1.0.110", features = ["derive"] } ron = { version = "0.8", default-features = false } diff --git a/world/examples/pricing_csv.rs b/world/examples/pricing_csv.rs index 517d62cd1b..d302edcc3a 100644 --- a/world/examples/pricing_csv.rs +++ b/world/examples/pricing_csv.rs @@ -15,7 +15,7 @@ use veloren_world::{ fn good_pricing_csv(world: &World, index: &Index) -> Result<(), Box> { let mut csv = csv::Writer::from_path("good_pricing.csv")?; - csv.write_record(&[ + csv.write_record([ "Site", "XCoord", "YCoord", @@ -39,7 +39,7 @@ fn good_pricing_csv(world: &World, index: &Index) -> Result<(), Box> if site.do_economic_simulation() { let prices = site.economy.get_site_prices(); //println!("{:?}: {:?} {:?}", site.name(), civsite.center, prices); - csv.write_record(&[ + csv.write_record([ site.name(), &format!("{}", civsite.center.x), &format!("{}", civsite.center.y), diff --git a/world/src/canvas.rs b/world/src/canvas.rs index ab6acbda3a..c1d8506894 100644 --- a/world/src/canvas.rs +++ b/world/src/canvas.rs @@ -218,7 +218,7 @@ impl<'a> Canvas<'a> { for z in (structure.get_bounds().min.z..structure.get_bounds().max.z).rev() { if let Ok(sblock) = structure.get(rpos2d.with_z(z)) { let mut add_snow = false; - let _ = canvas.map(wpos2d.with_z(origin.z + z), |block| { + canvas.map(wpos2d.with_z(origin.z + z), |block| { if let Some(new_block) = block_from_structure( info.index, *sblock, @@ -242,7 +242,7 @@ impl<'a> Canvas<'a> { }); if add_snow { - let _ = canvas.set( + canvas.set( wpos2d.with_z(origin.z + z + 1), Block::new(BlockKind::Snow, Rgb::new(210, 210, 255)), ); diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 07a6fbcef6..16b4ad5d43 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -1233,7 +1233,7 @@ impl fmt::Display for Site { } } -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum SiteKind { Settlement, Dungeon, @@ -1449,14 +1449,14 @@ impl Site { pub fn is_castle(&self) -> bool { matches!(self.kind, SiteKind::Castle) } } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub struct PointOfInterest { pub name: String, pub kind: PoiKind, pub loc: Vec2, } -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] pub enum PoiKind { /// Peak stores the altitude Peak(u32), diff --git a/world/src/layer/mod.rs b/world/src/layer/mod.rs index eb2b8a9dbc..81ea876f06 100644 --- a/world/src/layer/mod.rs +++ b/world/src/layer/mod.rs @@ -96,7 +96,7 @@ pub fn apply_paths_to(canvas: &mut Canvas) { let surface_z = (riverless_alt + bridge_offset).floor() as i32; for z in inset - depth..inset { - let _ = canvas.set( + canvas.set( Vec3::new(wpos2d.x, wpos2d.y, surface_z + z), if bridge_offset >= 2.0 && path_dist >= 3.0 || z < inset - 1 { Block::new( @@ -114,7 +114,7 @@ pub fn apply_paths_to(canvas: &mut Canvas) { for z in inset..inset + head_space { let pos = Vec3::new(wpos2d.x, wpos2d.y, surface_z + z); if canvas.get(pos).kind() != BlockKind::Water { - let _ = canvas.set(pos, EMPTY_AIR); + canvas.set(pos, EMPTY_AIR); } } } @@ -653,7 +653,7 @@ pub fn apply_coral_to(canvas: &mut Canvas) { }); if is_coral { - let _ = canvas.set(wpos, Block::new(BlockKind::Rock, Rgb::new(170, 220, 210))); + canvas.set(wpos, Block::new(BlockKind::Rock, Rgb::new(170, 220, 210))); } } }); @@ -1042,7 +1042,7 @@ pub fn apply_caverns_to(canvas: &mut Canvas, dynamic_rng: &mut R) { block }; - let _ = canvas.set(wpos, block); + canvas.set(wpos, block); } }); } diff --git a/world/src/layer/wildlife.rs b/world/src/layer/wildlife.rs index 83fcd5352f..4694cc9299 100644 --- a/world/src/layer/wildlife.rs +++ b/world/src/layer/wildlife.rs @@ -392,7 +392,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>( .and_then(|pack| { (dynamic_rng.gen::() < density * col_sample.spawn_rate && col_sample.gradient < Some(1.3)) - .then(|| pack) + .then_some(pack) }) }) .flatten() diff --git a/world/src/lib.rs b/world/src/lib.rs index e77c4837e4..65650b38d9 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -7,13 +7,7 @@ )] #![allow(clippy::branches_sharing_code)] // TODO: evaluate #![deny(clippy::clone_on_ref_ptr)] -#![feature( - bool_to_option, - label_break_value, - option_zip, - arbitrary_enum_discriminant, - let_else -)] +#![feature(option_zip, arbitrary_enum_discriminant, let_else)] mod all; mod block; diff --git a/world/src/sim/erosion.rs b/world/src/sim/erosion.rs index 3cb0cf4e7f..63dd236bfa 100644 --- a/world/src/sim/erosion.rs +++ b/world/src/sim/erosion.rs @@ -838,7 +838,7 @@ fn erode( // TODO: Figure out how to switch between single-receiver and multi-receiver // drainage, as the former is much less computationally costly. // let area = get_drainage(map_size_lg, &newh, &dh, boundary_len); - let area = get_multi_drainage(map_size_lg, &mstack, &mrec, &*mwrec, boundary_len); + let area = get_multi_drainage(map_size_lg, &mstack, &mrec, &mwrec, boundary_len); debug!("Got flux..."); (dh, newh, maxh, mrec, mstack, mwrec, area) }, @@ -1864,7 +1864,7 @@ pub fn get_lakes( let mut indirection_ = vec![0u32; indirection.len()]; // First, find all the lakes. let mut lake_roots = Vec::with_capacity(downhill.len()); // Test - (&*downhill) + (*downhill) .iter() .enumerate() .filter(|(_, &dh_idx)| dh_idx < 0) @@ -2160,7 +2160,7 @@ pub fn get_lakes( let mut filling_queue = Vec::with_capacity(downhill.len()); let mut newh = Vec::with_capacity(downhill.len()); - (&*boundary) + (*boundary) .iter() .chain(pass_flows_sorted.iter()) .for_each(|&chunk_idx| { diff --git a/world/src/sim/map.rs b/world/src/sim/map.rs index 97568339d0..3054fc4a3f 100644 --- a/world/src/sim/map.rs +++ b/world/src/sim/map.rs @@ -202,7 +202,7 @@ pub fn sample_pos( let downhill_pos = downhill_wpos.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as i32); NEIGHBOR_DELTA .iter() - .zip((&mut connections).iter_mut()) + .zip(connections.iter_mut()) .filter(|&(&offset, _)| downhill_pos - pos == Vec2::from(offset)) .for_each(|(_, connection)| { has_connections = true; diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 90e148cad1..f9e8344edf 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -1362,7 +1362,7 @@ impl WorldSim { threadpool, ) }; - let flux_old = get_multi_drainage(map_size_lg, &mstack, &mrec, &*mwrec, boundary_len); + let flux_old = get_multi_drainage(map_size_lg, &mstack, &mrec, &mwrec, boundary_len); // let flux_rivers = get_drainage(map_size_lg, &water_alt_pos, &dh, // boundary_len); TODO: Make rivers work with multi-direction flux as // well. diff --git a/world/src/site/economy/map_types.rs b/world/src/site/economy/map_types.rs index 1364570cb4..7e0502514b 100644 --- a/world/src/site/economy/map_types.rs +++ b/world/src/site/economy/map_types.rs @@ -109,14 +109,14 @@ impl IndexMut for GoodMap { impl GoodMap { pub fn iter(&self) -> impl Iterator + '_ { - (&self.data) + self.data .iter() .enumerate() .map(|(idx, v)| (GoodIndex { idx }, v)) } pub fn iter_mut(&mut self) -> impl Iterator + '_ { - (&mut self.data) + self.data .iter_mut() .enumerate() .map(|(idx, v)| (GoodIndex { idx }, v)) @@ -206,7 +206,7 @@ impl fmt::Debug for LaborMap { .entries( self.iter() .filter(|i| *i.1 != V::default()) - .map(|i| (i.0, &*i.1)), + .map(|i| (i.0, i.1)), ) .finish() } @@ -226,14 +226,14 @@ impl IndexMut for LaborMap { impl LaborMap { pub fn iter(&self) -> impl Iterator + '_ { - (&self.data) + self.data .iter() .enumerate() .map(|(idx, v)| (LaborIndex::from_usize(idx), v)) } pub fn iter_mut(&mut self) -> impl Iterator + '_ { - (&mut self.data) + self.data .iter_mut() .enumerate() .map(|(idx, v)| (LaborIndex::from_usize(idx), v)) diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index 6590010185..a0e1044035 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -1110,7 +1110,7 @@ fn transfer(wares: &mut Vec, bag: &mut Item) { } } -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Eq)] pub enum Crop { Corn, Wheat, @@ -1126,7 +1126,7 @@ pub enum Crop { // NOTE: No support for struct variants in make_case_elim yet, unfortunately, so // we can't use it. -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Eq)] pub enum Plot { Hazard, Dirt, @@ -1149,7 +1149,7 @@ const CARDINALS: [Vec2; 4] = [ Vec2::new(-1, 0), ]; -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Eq)] pub enum WayKind { Path, #[allow(dead_code)] @@ -1165,7 +1165,7 @@ impl WayKind { } } -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Eq)] pub enum Tower { #[allow(dead_code)] Wall, diff --git a/world/src/site2/mod.rs b/world/src/site2/mod.rs index 527e6077ad..3910e61750 100644 --- a/world/src/site2/mod.rs +++ b/world/src/site2/mod.rs @@ -154,7 +154,7 @@ impl Site { } max_cost }; - let path = Astar::new(MAX_ITERS, a, &heuristic, DefaultHashBuilder::default()) + let path = Astar::new(MAX_ITERS, a, heuristic, DefaultHashBuilder::default()) .poll( MAX_ITERS, &heuristic, diff --git a/world/src/site2/tile.rs b/world/src/site2/tile.rs index e058642191..0ffff309f8 100644 --- a/world/src/site2/tile.rs +++ b/world/src/site2/tile.rs @@ -239,14 +239,14 @@ pub enum HazardKind { Hill { gradient: f32 }, } -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Eq)] pub enum KeepKind { Middle, Corner, Wall(Dir), } -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Eq)] pub enum RoofKind { Parapet, Pyramid, diff --git a/world/src/site2/util/mod.rs b/world/src/site2/util/mod.rs index 99eb36abef..7a15e5f356 100644 --- a/world/src/site2/util/mod.rs +++ b/world/src/site2/util/mod.rs @@ -4,7 +4,7 @@ use rand::Rng; use vek::*; /// A 2d direction. -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Dir { X, Y, diff --git a/world/src/util/map_array.rs b/world/src/util/map_array.rs index 84f6fde108..7171b7db23 100644 --- a/world/src/util/map_array.rs +++ b/world/src/util/map_array.rs @@ -87,7 +87,7 @@ mod tests { impl MyMap { pub fn iter(&self) -> impl Iterator + '_ { - (&self.0).iter().enumerate().map(|(i, v)| (MyIndex(i), v)) + self.0.iter().enumerate().map(|(i, v)| (MyIndex(i), v)) } }