From 5db993343cdd14c6425382a987d0ecaecf9e8de3 Mon Sep 17 00:00:00 2001 From: Andrey Lesnikov Date: Fri, 9 Jun 2023 15:25:05 +0400 Subject: [PATCH 1/6] zgui: Fix unused basic_scale warn --- zgui/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/zgui/src/lib.rs b/zgui/src/lib.rs index 0f2647b..f2b1923 100644 --- a/zgui/src/lib.rs +++ b/zgui/src/lib.rs @@ -116,7 +116,6 @@ impl Drawable { struct Sprite { drawable: Drawable, dimensions: Rect, - basic_scale: f32, pos: Vec2, scale: Vec2, color: Color, @@ -129,7 +128,6 @@ impl Sprite { Self { drawable, dimensions, - basic_scale, pos: Vec2::new(0.0, 0.0), scale: Vec2::new(basic_scale, basic_scale), color: SPRITE_COLOR, From d58e0a1b079562bcc9018f9eb7ceae18966178d0 Mon Sep 17 00:00:00 2001 From: Andrey Lesnikov Date: Fri, 9 Jun 2023 15:26:25 +0400 Subject: [PATCH 2/6] Remove #![allow(clippy::eval_order_dependence)] Seems like it was fixed and explicit allow isn't needed anymore --- src/assets.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/assets.rs b/src/assets.rs index 352b9a1..d5e3b93 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -1,8 +1,5 @@ //! This module groups all the async loading stuff. -// TODO: https://github.com/rust-lang/rust-clippy/issues/4637 -#![allow(clippy::eval_order_dependence)] - use std::{collections::HashMap, hash::Hash}; use mq::{ From 5cb1e7cfa67378cbe18e55982690b111a33f5069 Mon Sep 17 00:00:00 2001 From: Andrey Lesnikov Date: Fri, 9 Jun 2023 15:28:24 +0400 Subject: [PATCH 3/6] Fix clippy::derivable_impls --- src/core/battle.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/core/battle.rs b/src/core/battle.rs index 568a476..dc3de3a 100644 --- a/src/core/battle.rs +++ b/src/core/battle.rs @@ -84,17 +84,14 @@ pub struct Id(i32); #[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)] pub struct Strength(pub i32); -#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, PartialOrd)] +#[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)] pub enum Weight { + #[default] Normal = 0, + Heavy = 1, - Immovable = 2, -} -impl Default for Weight { - fn default() -> Self { - Weight::Normal - } + Immovable = 2, } impl fmt::Display for Weight { @@ -132,14 +129,10 @@ pub struct Accuracy(pub i32); #[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)] pub struct Dodge(pub i32); -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Eq)] +#[derive(Serialize, Deserialize, Default, Debug, Clone, Copy, PartialEq, Eq)] pub enum TileType { + #[default] Plain, - Rocks, -} -impl Default for TileType { - fn default() -> Self { - TileType::Plain - } + Rocks, } From c3c4eb981a314eae2b42cb74e1201ac0326eb2a7 Mon Sep 17 00:00:00 2001 From: Andrey Lesnikov Date: Fri, 9 Jun 2023 15:38:39 +0400 Subject: [PATCH 4/6] main_menu.rs: Allow unused Message::Exit on WASM --- src/screen/main_menu.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/screen/main_menu.rs b/src/screen/main_menu.rs index 7def0b9..0420a2d 100644 --- a/src/screen/main_menu.rs +++ b/src/screen/main_menu.rs @@ -16,8 +16,11 @@ use crate::{ #[derive(Copy, Clone, Debug)] enum Message { + #[cfg_attr(target_arch = "wasm32", allow(unused))] // can't quit WASM so it's not used there Exit, + StartInstant, + StartCampaign, } From ffd651f650f742cf1df8424afdd4db57a2211008 Mon Sep 17 00:00:00 2001 From: Andrey Lesnikov Date: Fri, 9 Jun 2023 15:40:54 +0400 Subject: [PATCH 5/6] main_menu.rs: Unify ui::Gui path --- src/screen/main_menu.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screen/main_menu.rs b/src/screen/main_menu.rs index 0420a2d..1b005cd 100644 --- a/src/screen/main_menu.rs +++ b/src/screen/main_menu.rs @@ -5,7 +5,7 @@ use std::{ use log::trace; use mq::math::Vec2; -use ui::{self, Gui, Widget}; +use ui::{self, Widget}; use crate::{ assets, @@ -52,7 +52,7 @@ fn make_gui() -> ZResult> { #[derive(Debug)] pub struct MainMenu { - gui: Gui, + gui: ui::Gui, receiver_battle_result: Option>>, } From bf52cf52b9044c4b7d25a855c1c5c70af30db101 Mon Sep 17 00:00:00 2001 From: Andrey Lesnikov Date: Fri, 9 Jun 2023 15:43:21 +0400 Subject: [PATCH 6/6] error.rs: Fix clippy::enum_variant_names --- src/error.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/error.rs b/src/error.rs index 3cb57bf..c5596ae 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,35 +2,35 @@ use std::{error, fmt, io, path::PathBuf}; #[derive(Debug, derive_more::From)] pub enum ZError { - UiError(ui::Error), - SceneError(zscene::Error), - RonDeserializeError { + Ui(ui::Error), + Scene(zscene::Error), + RonDeserialize { error: ron::de::Error, path: PathBuf, }, - IOError(io::Error), - MqFileError(mq::file::FileError), - MqFontError(mq::text::FontError), + IO(io::Error), + MqFile(mq::file::FileError), + MqFont(mq::text::FontError), } impl ZError { pub fn from_ron_de_error(error: ron::de::Error, path: PathBuf) -> Self { - ZError::RonDeserializeError { error, path } + ZError::RonDeserialize { error, path } } } impl fmt::Display for ZError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - ZError::UiError(ref e) => write!(f, "ZGUI Error: {}", e), - ZError::SceneError(ref e) => write!(f, "ZScene Error: {}", e), - ZError::RonDeserializeError { error, path } => { + ZError::Ui(ref e) => write!(f, "ZGUI Error: {}", e), + ZError::Scene(ref e) => write!(f, "ZScene Error: {}", e), + ZError::RonDeserialize { error, path } => { let s = path.to_str().unwrap_or(""); write!(f, "Can't deserialize '{}': {}", s, error) } - ZError::IOError(ref e) => write!(f, "IO Error: {}", e), - ZError::MqFileError(ref e) => write!(f, "Macroquad File error: {}", e), - ZError::MqFontError(ref e) => write!(f, "Macroquad Font error: {}", e), + ZError::IO(ref e) => write!(f, "IO Error: {}", e), + ZError::MqFile(ref e) => write!(f, "Macroquad File error: {}", e), + ZError::MqFont(ref e) => write!(f, "Macroquad Font error: {}", e), } } } @@ -38,12 +38,12 @@ impl fmt::Display for ZError { impl error::Error for ZError { fn source(&self) -> Option<&(dyn error::Error + 'static)> { match self { - ZError::UiError(ref e) => Some(e), - ZError::SceneError(ref e) => Some(e), - ZError::RonDeserializeError { error, .. } => Some(error), - ZError::IOError(ref e) => Some(e), - ZError::MqFileError(ref e) => Some(e), - ZError::MqFontError(ref e) => Some(e), + ZError::Ui(ref e) => Some(e), + ZError::Scene(ref e) => Some(e), + ZError::RonDeserialize { error, .. } => Some(error), + ZError::IO(ref e) => Some(e), + ZError::MqFile(ref e) => Some(e), + ZError::MqFont(ref e) => Some(e), } } }