diff --git a/common/net/src/lib.rs b/common/net/src/lib.rs index 17db09349d..faacbb015e 100644 --- a/common/net/src/lib.rs +++ b/common/net/src/lib.rs @@ -1,7 +1,4 @@ #![allow(incomplete_features)] -#![feature( - generic_const_exprs, - const_fn_floating_point_arithmetic, -)] +#![feature(generic_const_exprs, const_fn_floating_point_arithmetic)] pub mod msg; pub mod sync; diff --git a/common/src/comp/inventory/item/tool.rs b/common/src/comp/inventory/item/tool.rs index 62b9d48509..8c53d71020 100644 --- a/common/src/comp/inventory/item/tool.rs +++ b/common/src/comp/inventory/item/tool.rs @@ -375,6 +375,7 @@ impl AbilitySet { } } +#[allow(clippy::derivable_impls)] impl Default for AbilitySet { fn default() -> Self { AbilitySet { diff --git a/common/src/resources.rs b/common/src/resources.rs index fee169e388..4a55d3b5c3 100644 --- a/common/src/resources.rs +++ b/common/src/resources.rs @@ -41,7 +41,7 @@ pub enum GameMode { #[derive(Copy, Clone, Default, Debug)] pub struct PlayerEntity(pub Option); -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Default)] pub struct PlayerPhysicsSetting { /// true if the client wants server-authoratative physics (e.g. to use /// airships properly) @@ -51,15 +51,6 @@ pub struct PlayerPhysicsSetting { pub server_force: bool, } -impl Default for PlayerPhysicsSetting { - fn default() -> PlayerPhysicsSetting { - PlayerPhysicsSetting { - client_optin: false, - server_force: false, - } - } -} - impl PlayerPhysicsSetting { pub fn server_authoritative(&self) -> bool { self.client_optin || self.server_force } diff --git a/common/src/skillset_builder.rs b/common/src/skillset_builder.rs index d0e7b2ecc0..90282d912e 100644 --- a/common/src/skillset_builder.rs +++ b/common/src/skillset_builder.rs @@ -54,12 +54,9 @@ fn skills_from_nodes(nodes: &[SkillNode]) -> Vec<(Skill, Option)> { skills } +#[derive(Default)] pub struct SkillSetBuilder(SkillSet); -impl Default for SkillSetBuilder { - fn default() -> Self { Self(SkillSet::default()) } -} - impl SkillSetBuilder { /// Creates `SkillSetBuilder` from `asset_specifier` #[must_use] diff --git a/common/src/states/basic_beam.rs b/common/src/states/basic_beam.rs index a9da6c3f24..6e863a6e8b 100644 --- a/common/src/states/basic_beam.rs +++ b/common/src/states/basic_beam.rs @@ -151,7 +151,7 @@ impl CharacterBehavior for Data { // and applying `pitch` to get needed orientation. let look_dir = data.inputs.look_dir; let xy_dir = Dir::from_unnormalized(Vec3::new(look_dir.x, look_dir.y, 0.0)) - .unwrap_or_else(Dir::default); + .unwrap_or_default(); let pitch = xy_dir.rotation_between(look_dir); Ori::from(Vec3::new( diff --git a/server/src/input.rs b/server/src/input.rs index c542fe83f2..7a5c751246 100644 --- a/server/src/input.rs +++ b/server/src/input.rs @@ -1,7 +1,4 @@ +#[derive(Default)] pub struct Input { // TODO: Use this type to manage server input. } - -impl Default for Input { - fn default() -> Self { Input {} } -} diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index c8112b25ca..2b712dc2af 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -1662,9 +1662,9 @@ impl<'a> AgentData<'a> { Some((entity, *e_pos)) } else if let Some(villain_info) = guard_duty(e_health, e_alignment) { Some(villain_info) - } else if rtsim_remember(e_stats, agent, event_emitter) { - Some((entity, *e_pos)) - } else if npc_sees_cultist(e_stats, e_inventory, agent, event_emitter) { + } else if rtsim_remember(e_stats, agent, event_emitter) + || npc_sees_cultist(e_stats, e_inventory, agent, event_emitter) + { Some((entity, *e_pos)) } else { None diff --git a/voxygen/anim/src/biped_large/spin.rs b/voxygen/anim/src/biped_large/spin.rs index 213d8b943d..5debd2f82a 100644 --- a/voxygen/anim/src/biped_large/spin.rs +++ b/voxygen/anim/src/biped_large/spin.rs @@ -87,7 +87,7 @@ impl Animation for SpinAnimation { next.head.orientation = Quaternion::rotation_y(movement1 * 0.1 - movement2 * -0.1) * Quaternion::rotation_z(1.07 + movement1 * 0.4 + movement2 * -1.5); - next.torso.orientation = Quaternion::rotation_z(movement2 * 6.28); + next.torso.orientation = Quaternion::rotation_z(movement2 * std::f32::consts::TAU); } if let Some(ToolKind::Axe | ToolKind::Hammer | ToolKind::Dagger) = active_tool_kind { diff --git a/voxygen/src/hud/hotbar.rs b/voxygen/src/hud/hotbar.rs index e6dd84112d..8bbcd07a15 100644 --- a/voxygen/src/hud/hotbar.rs +++ b/voxygen/src/hud/hotbar.rs @@ -27,21 +27,12 @@ pub enum SlotContents { Ability4, } -#[derive(Clone, Debug)] +#[derive(Clone, Copy, Default)] pub struct State { pub slots: [Option; 10], inputs: [bool; 10], } -impl Default for State { - fn default() -> Self { - Self { - slots: [None; 10], - inputs: [false; 10], - } - } -} - impl State { pub fn new(slots: [Option; 10]) -> Self { Self { diff --git a/voxygen/src/menu/char_selection/ui/mod.rs b/voxygen/src/menu/char_selection/ui/mod.rs index 2561f3bb90..9ffb4a5ef5 100644 --- a/voxygen/src/menu/char_selection/ui/mod.rs +++ b/voxygen/src/menu/char_selection/ui/mod.rs @@ -378,6 +378,7 @@ impl Controls { .position(|i| i.character.id == Some(id)) }); + #[allow(clippy::if_same_then_else)] if let Some(error) = error { // TODO: use more user friendly errors with suggestions on potential solutions // instead of directly showing error message here diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index 594a114384..b98fc788c8 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -209,6 +209,7 @@ pub enum ShadowMode { Cheap, } +#[allow(clippy::derivable_impls)] impl Default for ShadowMode { fn default() -> Self { ShadowMode::Map(Default::default()) } } diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index 1e13017d6d..1c5f22bd57 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -310,7 +310,7 @@ impl Renderer { | (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES), limits, }, - trace_path.as_deref(), + trace_path, ))?; // Set error handler for wgpu errors diff --git a/voxygen/src/settings/gamepad.rs b/voxygen/src/settings/gamepad.rs index 53313cc047..0aa405e173 100644 --- a/voxygen/src/settings/gamepad.rs +++ b/voxygen/src/settings/gamepad.rs @@ -136,11 +136,11 @@ pub mod con_settings { pub scroll_y: Axis, } - #[derive(Clone, Debug, Serialize, Deserialize)] + #[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(default)] pub struct GameAnalogButton {} - #[derive(Clone, Debug, Serialize, Deserialize)] + #[derive(Clone, Debug, Default, Serialize, Deserialize)] #[serde(default)] pub struct MenuAnalogButton {} @@ -246,12 +246,4 @@ pub mod con_settings { } } } - - impl Default for GameAnalogButton { - fn default() -> Self { Self {} } - } - - impl Default for MenuAnalogButton { - fn default() -> Self { Self {} } - } } diff --git a/voxygen/src/ui/ice/renderer/style/checkbox.rs b/voxygen/src/ui/ice/renderer/style/checkbox.rs index a113c0911b..bf0f63864d 100644 --- a/voxygen/src/ui/ice/renderer/style/checkbox.rs +++ b/voxygen/src/ui/ice/renderer/style/checkbox.rs @@ -19,7 +19,7 @@ impl Background { } } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Default)] pub struct Style { background: Option, check: Option, @@ -82,12 +82,3 @@ impl Style { self.background.as_ref().map(|b| b.default) } } - -impl Default for Style { - fn default() -> Self { - Self { - background: None, - check: None, - } - } -} diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index 65b57fb139..0cbee75004 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -875,12 +875,7 @@ impl Ui { switch_to_plain_state!(); // Mesh should already be cached. - mesh.push_mesh( - text_cache - .get(&widget_id) - .as_deref() - .unwrap_or(&Mesh::new()), - ); + mesh.push_mesh(text_cache.get(&widget_id).unwrap_or(&Mesh::new())); }, PrimitiveKind::Rectangle { color } => { let color = srgba_to_linear(color.to_fsa().into()); diff --git a/world/src/lib.rs b/world/src/lib.rs index 3fde821cf4..2ebd01a561 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -7,11 +7,7 @@ )] #![allow(clippy::branches_sharing_code)] // TODO: evaluate #![deny(clippy::clone_on_ref_ptr)] -#![feature( - bool_to_option, - const_panic, - label_break_value -)] +#![feature(bool_to_option, const_panic, label_break_value)] mod all; mod block; diff --git a/world/src/site/economy.rs b/world/src/site/economy.rs index 20dd4ef789..11afd2ff4b 100644 --- a/world/src/site/economy.rs +++ b/world/src/site/economy.rs @@ -274,24 +274,14 @@ impl LaborMap { } } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct AreaResources { pub resource_sum: GoodMap, pub resource_chunks: GoodMap, pub chunks: u32, } -impl Default for AreaResources { - fn default() -> Self { - Self { - resource_sum: GoodMap::default(), - resource_chunks: GoodMap::default(), - chunks: 0, - } - } -} - -#[derive(Debug)] +#[derive(Debug, Default)] pub struct NaturalResources { // resources per distance, we should increase labor cost for far resources pub per_area: Vec, @@ -301,16 +291,6 @@ pub struct NaturalResources { pub average_yield_per_chunk: GoodMap, } -impl Default for NaturalResources { - fn default() -> Self { - Self { - per_area: Vec::new(), - chunks_per_resource: GoodMap::default(), - average_yield_per_chunk: GoodMap::default(), - } - } -} - #[derive(Debug, Deserialize)] pub struct RawProfessions(Vec); @@ -383,21 +363,12 @@ pub struct TradeDelivery { pub supply: GoodMap, // maximum amount available, at the time of interaction } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct TradeInformation { pub orders: DHashMap, Vec>, // per provider pub deliveries: DHashMap, Vec>, // per receiver } -impl Default for TradeInformation { - fn default() -> Self { - Self { - orders: Default::default(), - deliveries: Default::default(), - } - } -} - #[derive(Debug)] pub struct NeighborInformation { pub id: Id,