diff --git a/Cargo.toml b/Cargo.toml index 819cb22999..4f67d34265 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,16 @@ rust.tail_expr_drop_order = { level = "allow", priority = 1 } rust.edition_2024_expr_fragment_specifier = { level = "allow", priority = 1 } rust.keyword_idents_2024 = { level = "allow", priority = 1 } +[workspace.lints.clippy] +# This lint is widely considered an annoyance by Veloren developers and doesn't pay its way. +unnecessary_map_or = "allow" +# This suggests turning if statements into if guards in the match. This is +# often not ideal because this can make the match arms inconsistent and make +# them reliant on being followed by a no-op wildcard arm. +collapsible_match = "allow" +# bug in current version (fixed in latest nightly) +manual_option_zip = "allow" + ### PROFILES ### # default profile for devs, fast to compile, okay enough to run, no debug information @@ -240,6 +250,3 @@ specs = { git = "https://github.com/amethyst/specs.git", rev = "4e2da1df29ee840b # naga = { path = "../wgpu/naga" } -[workspace.lints.clippy] -# This lint is widely considered an annoyance by Veloren developers and doesn't pay its way. -unnecessary_map_or = "allow" diff --git a/common/query_server/src/server.rs b/common/query_server/src/server.rs index d836b94519..fbbafa7503 100644 --- a/common/query_server/src/server.rs +++ b/common/query_server/src/server.rs @@ -32,6 +32,7 @@ pub struct QueryServer { #[derive(Default, Clone, Copy, Debug)] pub struct Metrics { pub received_packets: u32, + /// Note, these are not counted in `received_packets`. pub dropped_packets: u32, pub invalid_packets: u32, pub proccessing_errors: u32, diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index d80eb64d77..c09a8555b5 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -1115,16 +1115,17 @@ impl Inventory { ); } }, - EquipSlot::InactiveMainhand + EquipSlot::InactiveMainhand => { if self.loadout.equipped(EquipSlot::InactiveMainhand).is_none() - && self.loadout.equipped(EquipSlot::InactiveOffhand).is_some() => - { - let offhand = self.loadout.swap(EquipSlot::InactiveOffhand, None, time); - assert!( - self.loadout - .swap(EquipSlot::InactiveMainhand, offhand, time) - .is_none() - ); + && self.loadout.equipped(EquipSlot::InactiveOffhand).is_some() + { + let offhand = self.loadout.swap(EquipSlot::InactiveOffhand, None, time); + assert!( + self.loadout + .swap(EquipSlot::InactiveMainhand, offhand, time) + .is_none() + ); + } }, _ => {}, } diff --git a/common/src/states/leap_ranged.rs b/common/src/states/leap_ranged.rs index 2e6f50ca81..a05a3db505 100644 --- a/common/src/states/leap_ranged.rs +++ b/common/src/states/leap_ranged.rs @@ -166,8 +166,10 @@ impl CharacterBehavior for Data { c.timer = tick_attack_or_default(data, self.timer, None); } }, - StageSection::Recover if self.timer < self.static_data.recover_duration => { - if let CharacterState::LeapRanged(c) = &mut update.character { + StageSection::Recover => { + if self.timer < self.static_data.recover_duration + && let CharacterState::LeapRanged(c) = &mut update.character + { c.timer = tick_attack_or_default(data, self.timer, None); } }, diff --git a/common/systems/src/beam.rs b/common/systems/src/beam.rs index b22a4a6677..8e2c413d35 100644 --- a/common/systems/src/beam.rs +++ b/common/systems/src/beam.rs @@ -167,9 +167,9 @@ impl<'a> System<'a> for Sys { read_data .positions .get(target) - .zip(read_data.healths.get(target)) - .zip(read_data.uids.get(target)) - .zip(read_data.bodies.get(target)) + .and_then(|l| read_data.healths.get(target).map(|r| (l, r))) + .and_then(|l| read_data.uids.get(target).map(|r| (l, r))) + .and_then(|l| read_data.bodies.get(target).map(|r| (l, r))) .map(|(((pos_b, health_b), uid_b), body_b)| { (target, uid_b, pos_b, health_b, body_b) }) diff --git a/network/protocol/src/quic.rs b/network/protocol/src/quic.rs index 47e6d8854e..e95296a4a5 100644 --- a/network/protocol/src/quic.rs +++ b/network/protocol/src/quic.rs @@ -199,10 +199,12 @@ where self.reliable_buffers.insert(sid, BytesMut::new()); } }, - ProtocolEvent::CloseStream { sid } if !self.store.try_close_stream(sid) => { - #[cfg(feature = "trace_pedantic")] - trace!(?sid, "hold back notify close stream"); - self.notify_closing_streams.push(sid); + ProtocolEvent::CloseStream { sid } => { + if !self.store.try_close_stream(sid) { + #[cfg(feature = "trace_pedantic")] + trace!(?sid, "hold back notify close stream"); + self.notify_closing_streams.push(sid); + } }, _ => {}, } diff --git a/network/protocol/src/tcp.rs b/network/protocol/src/tcp.rs index 7b5159f840..521432946b 100644 --- a/network/protocol/src/tcp.rs +++ b/network/protocol/src/tcp.rs @@ -113,10 +113,12 @@ where self.store .open_stream(sid, prio, promises, guaranteed_bandwidth); }, - ProtocolEvent::CloseStream { sid } if !self.store.try_close_stream(sid) => { - #[cfg(feature = "trace_pedantic")] - trace!(?sid, "hold back notify close stream"); - self.notify_closing_streams.push(sid); + ProtocolEvent::CloseStream { sid } => { + if !self.store.try_close_stream(sid) { + #[cfg(feature = "trace_pedantic")] + trace!(?sid, "hold back notify close stream"); + self.notify_closing_streams.push(sid); + } }, _ => {}, } diff --git a/server/agent/src/attack.rs b/server/agent/src/attack.rs index 2fd968bc90..0f398bc6c4 100644 --- a/server/agent/src/attack.rs +++ b/server/agent/src/attack.rs @@ -8204,15 +8204,18 @@ impl AgentData<'_> { false } }, - Some(input @ InputKind::Ability(1)) + Some(input @ InputKind::Ability(1)) => { if self .char_state .timer() .is_some_and(|t| t.as_secs_f32() < 3.0) - && could_use_input(input) => - { - controller.push_basic_input(input); - true + && could_use_input(input) + { + controller.push_basic_input(input); + true + } else { + false + } }, _ => false, }; @@ -8301,22 +8304,25 @@ impl AgentData<'_> { controller.push_basic_input(input); } }, - CharacterState::ChargedRanged(c) - if c.charge_frac() < 1.0 && could_use_input(input) => - { - controller.push_basic_input(input); + CharacterState::ChargedRanged(c) => { + if c.charge_frac() < 1.0 && could_use_input(input) { + controller.push_basic_input(input); + } }, _ => {}, } } let continued_attack = match self.char_state.ability_info().map(|ai| ai.input) { - Some(input @ InputKind::Primary) + Some(input @ InputKind::Primary) => { if !matches!(self.char_state.stage_section(), Some(StageSection::Recover)) - && could_use_input(input) => - { - controller.push_basic_input(input); - true + && could_use_input(input) + { + controller.push_basic_input(input); + true + } else { + false + } }, _ => false, }; @@ -8452,10 +8458,10 @@ impl AgentData<'_> { controller.push_basic_input(input); } }, - CharacterState::ChargedRanged(c) - if c.charge_frac() < 1.0 && could_use_input(input) => - { - controller.push_basic_input(input); + CharacterState::ChargedRanged(c) => { + if c.charge_frac() < 1.0 && could_use_input(input) { + controller.push_basic_input(input); + } }, _ => {}, } diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index 98bcd6a8bc..389dc9df3f 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -211,9 +211,13 @@ pub fn handle_create_npc(server: &mut Server, ev: CreateNpcEvent) -> EcsEntity { &state.ecs().read_storage(), &uids, &mut |entity, group_change| { - group_change - .try_map_ref(|e| uids.get(*e).copied()) - .zip(clients.get(entity)) + clients + .get(entity) + .and_then(|c| { + group_change + .try_map_ref(|e| uids.get(*e).copied()) + .map(|g| (g, c)) + }) .map(|(g, c)| { // Might be unnecessary, but maybe pets can somehow have map // markers in the future diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 1792155b77..1f15a120e9 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -1672,7 +1672,9 @@ impl ServerEvent for ExplosionEvent { .filter_map(|entity| { data.auras .get(entity) - .zip(data.positions.get(entity)) + .and_then(|entity_auras| { + data.positions.get(entity).map(|pos| (entity_auras, pos)) + }) .and_then(|(entity_auras, pos)| { entity_auras .auras @@ -1807,7 +1809,9 @@ impl ServerEvent for ExplosionEvent { .filter_map(|entity| { data.auras .get(entity) - .zip(data.positions.get(entity)) + .and_then(|entity_auras| { + data.positions.get(entity).map(|pos| (entity_auras, pos)) + }) .and_then(|(entity_auras, pos)| { entity_auras .auras diff --git a/server/src/events/group_manip.rs b/server/src/events/group_manip.rs index a802f61cb5..010ef9cc2e 100644 --- a/server/src/events/group_manip.rs +++ b/server/src/events/group_manip.rs @@ -141,9 +141,13 @@ impl ServerEvent for GroupManipEvent { &uids, &entities, &mut |entity, group_change| { - group_change - .try_map_ref(|e| uids.get(*e).copied()) - .zip(clients.get(entity)) + clients + .get(entity) + .and_then(|c| { + group_change + .try_map_ref(|e| uids.get(*e).copied()) + .map(|g| (g, c)) + }) .map(|(g, c)| { update_map_markers(&map_markers, &uids, c, &group_change); c.send_fallible(ServerGeneral::GroupUpdate(g)); @@ -204,9 +208,13 @@ impl ServerEvent for GroupManipEvent { &uids, &entities, &mut |entity, group_change| { - group_change - .try_map_ref(|e| uids.get(*e).copied()) - .zip(clients.get(entity)) + clients + .get(entity) + .and_then(|c| { + group_change + .try_map_ref(|e| uids.get(*e).copied()) + .map(|g| (g, c)) + }) .map(|(g, c)| { update_map_markers( &map_markers, @@ -291,9 +299,13 @@ impl ServerEvent for GroupManipEvent { &alignments, &uids, |entity, group_change| { - group_change - .try_map_ref(|e| uids.get(*e).copied()) - .zip(clients.get(entity)) + clients + .get(entity) + .and_then(|c| { + group_change + .try_map_ref(|e| uids.get(*e).copied()) + .map(|g| (g, c)) + }) .map(|(g, c)| { update_map_markers( &map_markers, diff --git a/server/src/events/invite.rs b/server/src/events/invite.rs index f9cc8a5191..5f7a6beacc 100644 --- a/server/src/events/invite.rs +++ b/server/src/events/invite.rs @@ -272,9 +272,13 @@ pub fn handle_invite_accept(data: &mut InviteResponseData, entity: Entity) { &data.alignments, &data.uids, |entity, group_change| { - group_change - .try_map_ref(|e| data.uids.get(*e).copied()) - .zip(data.clients.get(entity)) + data.clients + .get(entity) + .and_then(|c| { + group_change + .try_map_ref(|e| data.uids.get(*e).copied()) + .map(|g| (g, c)) + }) .map(|(g, c)| { update_map_markers(&data.map_markers, &data.uids, c, &group_change); c.send_fallible(ServerGeneral::GroupUpdate(g)); diff --git a/server/src/pet.rs b/server/src/pet.rs index 9d92178c5c..367e1e78fe 100644 --- a/server/src/pet.rs +++ b/server/src/pet.rs @@ -100,9 +100,13 @@ fn tame_pet_internal(ecs: &specs::World, pet_entity: Entity, owner: Entity, pet: &ecs.read_storage(), &uids, &mut |entity, group_change| { - group_change - .try_map_ref(|e| uids.get(*e).copied()) - .zip(clients.get(entity)) + clients + .get(entity) + .and_then(|c| { + group_change + .try_map_ref(|e| uids.get(*e).copied()) + .map(|g| (g, c)) + }) .map(|(g, c)| { // Might be unneccessary, but maybe pets can somehow have map // markers in the future diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index f04023eeb0..1baa5f9c64 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -1238,9 +1238,13 @@ impl StateExt for State { &uids, &self.ecs().entities(), &mut |entity, group_change| { - group_change - .try_map_ref(|e| uids.get(*e).copied()) - .zip(clients.get(entity)) + clients + .get(entity) + .and_then(|c| { + group_change + .try_map_ref(|e| uids.get(*e).copied()) + .map(|g| (g, c)) + }) .map(|(g, c)| { update_map_markers(&map_markers, &uids, c, &group_change); c.send_fallible(ServerGeneral::GroupUpdate(g)); diff --git a/voxygen/src/hud/tutorial.rs b/voxygen/src/hud/tutorial.rs index 43c8c89f6d..d2a4d80fd1 100644 --- a/voxygen/src/hud/tutorial.rs +++ b/voxygen/src/hud/tutorial.rs @@ -449,8 +449,10 @@ impl TutorialState { Interactable::Entity { interaction: EntityInteraction::CampfireSit, .. - } if self.earn_achievement(Achievement::FindCampfire) => { - self.show_hint(Hint::Campfire, Duration::from_secs(1)); + } => { + if self.earn_achievement(Achievement::FindCampfire) { + self.show_hint(Hint::Campfire, Duration::from_secs(1)); + } }, _ => {}, }