Skip to content

Commit fae7d89

Browse files
authored
Merge pull request #688 from ozkriff/i687_fix_clippy_2023
Fx clippy warnings
2 parents 455c8c8 + bf52cf5 commit fae7d89

File tree

5 files changed

+31
-40
lines changed

5 files changed

+31
-40
lines changed

src/assets.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
//! This module groups all the async loading stuff.
22
3-
// TODO: https://github.com/rust-lang/rust-clippy/issues/4637
4-
#![allow(clippy::eval_order_dependence)]
5-
63
use std::{collections::HashMap, hash::Hash};
74

85
use mq::{

src/core/battle.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,14 @@ pub struct Id(i32);
8484
#[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)]
8585
pub struct Strength(pub i32);
8686

87-
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, PartialOrd)]
87+
#[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)]
8888
pub enum Weight {
89+
#[default]
8990
Normal = 0,
91+
9092
Heavy = 1,
91-
Immovable = 2,
92-
}
9393

94-
impl Default for Weight {
95-
fn default() -> Self {
96-
Weight::Normal
97-
}
94+
Immovable = 2,
9895
}
9996

10097
impl fmt::Display for Weight {
@@ -132,14 +129,10 @@ pub struct Accuracy(pub i32);
132129
#[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, PartialOrd)]
133130
pub struct Dodge(pub i32);
134131

135-
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Eq)]
132+
#[derive(Serialize, Deserialize, Default, Debug, Clone, Copy, PartialEq, Eq)]
136133
pub enum TileType {
134+
#[default]
137135
Plain,
138-
Rocks,
139-
}
140136

141-
impl Default for TileType {
142-
fn default() -> Self {
143-
TileType::Plain
144-
}
137+
Rocks,
145138
}

src/error.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@ use std::{error, fmt, io, path::PathBuf};
22

33
#[derive(Debug, derive_more::From)]
44
pub enum ZError {
5-
UiError(ui::Error),
6-
SceneError(zscene::Error),
7-
RonDeserializeError {
5+
Ui(ui::Error),
6+
Scene(zscene::Error),
7+
RonDeserialize {
88
error: ron::de::Error,
99
path: PathBuf,
1010
},
11-
IOError(io::Error),
12-
MqFileError(mq::file::FileError),
13-
MqFontError(mq::text::FontError),
11+
IO(io::Error),
12+
MqFile(mq::file::FileError),
13+
MqFont(mq::text::FontError),
1414
}
1515

1616
impl ZError {
1717
pub fn from_ron_de_error(error: ron::de::Error, path: PathBuf) -> Self {
18-
ZError::RonDeserializeError { error, path }
18+
ZError::RonDeserialize { error, path }
1919
}
2020
}
2121

2222
impl fmt::Display for ZError {
2323
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2424
match self {
25-
ZError::UiError(ref e) => write!(f, "ZGUI Error: {}", e),
26-
ZError::SceneError(ref e) => write!(f, "ZScene Error: {}", e),
27-
ZError::RonDeserializeError { error, path } => {
25+
ZError::Ui(ref e) => write!(f, "ZGUI Error: {}", e),
26+
ZError::Scene(ref e) => write!(f, "ZScene Error: {}", e),
27+
ZError::RonDeserialize { error, path } => {
2828
let s = path.to_str().unwrap_or("<no path>");
2929
write!(f, "Can't deserialize '{}': {}", s, error)
3030
}
31-
ZError::IOError(ref e) => write!(f, "IO Error: {}", e),
32-
ZError::MqFileError(ref e) => write!(f, "Macroquad File error: {}", e),
33-
ZError::MqFontError(ref e) => write!(f, "Macroquad Font error: {}", e),
31+
ZError::IO(ref e) => write!(f, "IO Error: {}", e),
32+
ZError::MqFile(ref e) => write!(f, "Macroquad File error: {}", e),
33+
ZError::MqFont(ref e) => write!(f, "Macroquad Font error: {}", e),
3434
}
3535
}
3636
}
3737

3838
impl error::Error for ZError {
3939
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
4040
match self {
41-
ZError::UiError(ref e) => Some(e),
42-
ZError::SceneError(ref e) => Some(e),
43-
ZError::RonDeserializeError { error, .. } => Some(error),
44-
ZError::IOError(ref e) => Some(e),
45-
ZError::MqFileError(ref e) => Some(e),
46-
ZError::MqFontError(ref e) => Some(e),
41+
ZError::Ui(ref e) => Some(e),
42+
ZError::Scene(ref e) => Some(e),
43+
ZError::RonDeserialize { error, .. } => Some(error),
44+
ZError::IO(ref e) => Some(e),
45+
ZError::MqFile(ref e) => Some(e),
46+
ZError::MqFont(ref e) => Some(e),
4747
}
4848
}
4949
}

src/screen/main_menu.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55

66
use log::trace;
77
use mq::math::Vec2;
8-
use ui::{self, Gui, Widget};
8+
use ui::{self, Widget};
99

1010
use crate::{
1111
assets,
@@ -16,8 +16,11 @@ use crate::{
1616

1717
#[derive(Copy, Clone, Debug)]
1818
enum Message {
19+
#[cfg_attr(target_arch = "wasm32", allow(unused))] // can't quit WASM so it's not used there
1920
Exit,
21+
2022
StartInstant,
23+
2124
StartCampaign,
2225
}
2326

@@ -49,7 +52,7 @@ fn make_gui() -> ZResult<ui::Gui<Message>> {
4952

5053
#[derive(Debug)]
5154
pub struct MainMenu {
52-
gui: Gui<Message>,
55+
gui: ui::Gui<Message>,
5356
receiver_battle_result: Option<Receiver<Option<state::BattleResult>>>,
5457
}
5558

zgui/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ impl Drawable {
116116
struct Sprite {
117117
drawable: Drawable,
118118
dimensions: Rect,
119-
basic_scale: f32,
120119
pos: Vec2,
121120
scale: Vec2,
122121
color: Color,
@@ -129,7 +128,6 @@ impl Sprite {
129128
Self {
130129
drawable,
131130
dimensions,
132-
basic_scale,
133131
pos: Vec2::new(0.0, 0.0),
134132
scale: Vec2::new(basic_scale, basic_scale),
135133
color: SPRITE_COLOR,

0 commit comments

Comments
 (0)