fix clippy issues, WITHOUT clippy::needless_pass_by_ref_mut as we are still unsure how to proceed with it. we want to keep the &mut ref where we are actually writing. maybe we need another method support

This commit is contained in:
Marcel Märtens 2023-10-05 20:03:24 +02:00
parent 882a8d104c
commit 631f3ab8ee
27 changed files with 73 additions and 62 deletions

View File

@ -16,7 +16,7 @@ impl<T> Id<T> {
impl<T> Copy for Id<T> {} impl<T> Copy for Id<T> {}
impl<T> Clone for Id<T> { impl<T> Clone for Id<T> {
fn clone(&self) -> Self { Self(self.0, PhantomData) } fn clone(&self) -> Self { *self }
} }
impl<T> Eq for Id<T> {} impl<T> Eq for Id<T> {}
impl<T> PartialEq for Id<T> { impl<T> PartialEq for Id<T> {

View File

@ -1,3 +1,7 @@
#![allow(
clippy::needless_pass_by_ref_mut //until we find a better way for specs
)]
use clap::Parser; use clap::Parser;
use common::comp; use common::comp;
use server::persistence::SqlLogMode; use server::persistence::SqlLogMode;

View File

@ -2924,11 +2924,7 @@ impl<'a> AgentData<'a> {
{ {
agent.action_state.counters[FCounters::SummonThreshold as usize] -= agent.action_state.counters[FCounters::SummonThreshold as usize] -=
SUMMON_THRESHOLD; SUMMON_THRESHOLD;
if !agent.action_state.conditions[Conditions::AttackToggle as usize] { agent.action_state.conditions[Conditions::AttackToggle as usize] = !agent.action_state.conditions[Conditions::AttackToggle as usize];
agent.action_state.conditions[Conditions::AttackToggle as usize] = true;
} else {
agent.action_state.conditions[Conditions::AttackToggle as usize] = false;
}
} }
} else { } else {
// If target is in melee range use flamecrush // If target is in melee range use flamecrush

View File

@ -1,4 +1,7 @@
#![feature(exclusive_range_pattern, let_chains)] #![feature(exclusive_range_pattern, let_chains)]
#![allow(
clippy::needless_pass_by_ref_mut //until we find a better way for specs
)]
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once"); compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");

View File

@ -1,5 +1,8 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![allow(clippy::option_map_unit_fn)] #![allow(
clippy::option_map_unit_fn,
clippy::needless_pass_by_ref_mut //until we find a better way for specs
)]
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#![feature( #![feature(
box_patterns, box_patterns,

View File

@ -1062,7 +1062,7 @@ pub fn update(
// The `defer_foreign_keys` pragma treats the foreign key // The `defer_foreign_keys` pragma treats the foreign key
// constraints as deferred for the next transaction (it turns itself // constraints as deferred for the next transaction (it turns itself
// off at the commit boundary). https://sqlite.org/foreignkeys.html#fk_deferred // off at the commit boundary). https://sqlite.org/foreignkeys.html#fk_deferred
transaction.pragma_update(None, "defer_foreign_keys", &"ON".to_string())?; transaction.pragma_update(None, "defer_foreign_keys", "ON")?;
let mut stmt = transaction.prepare_cached( let mut stmt = transaction.prepare_cached(
" "

View File

@ -1,4 +1,7 @@
#![feature(stmt_expr_attributes)] #![feature(stmt_expr_attributes)]
#![allow(
clippy::needless_pass_by_ref_mut //until we find a better way for specs
)]
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once"); compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");

View File

@ -407,7 +407,7 @@ impl TabComplete for ArgumentSpec {
.filter(|string| string.starts_with(part)) .filter(|string| string.starts_with(part))
.map(|c| c.to_string()) .map(|c| c.to_string())
.collect(), .collect(),
ArgumentSpec::Boolean(_, part, _) => vec!["true", "false"] ArgumentSpec::Boolean(_, part, _) => ["true", "false"]
.iter() .iter()
.filter(|string| string.starts_with(part)) .filter(|string| string.starts_with(part))
.map(|c| c.to_string()) .map(|c| c.to_string())

View File

@ -196,7 +196,7 @@ impl<'a> InventoryScroller<'a> {
.set(self.bg_ids.bg_frame, ui); .set(self.bg_ids.bg_frame, ui);
} }
fn title(&mut self, state: &mut ConrodState<'_, InventoryScrollerState>, ui: &mut UiCell<'_>) { fn title(&mut self, state: &ConrodState<'_, InventoryScrollerState>, ui: &mut UiCell<'_>) {
Text::new( Text::new(
&self &self
.localized_strings .localized_strings
@ -371,7 +371,7 @@ impl<'a> InventoryScroller<'a> {
}); });
} }
for (pos, item) in items.into_iter() { for (pos, item) in items.into_iter() {
if self.details_mode && !self.is_us && matches!(item, None) { if self.details_mode && !self.is_us && item.is_none() {
continue; continue;
} }
let (x, y) = if self.details_mode { let (x, y) = if self.details_mode {
@ -488,7 +488,7 @@ impl<'a> InventoryScroller<'a> {
fn footer_metrics( fn footer_metrics(
&mut self, &mut self,
state: &mut ConrodState<'_, InventoryScrollerState>, state: &ConrodState<'_, InventoryScrollerState>,
ui: &mut UiCell<'_>, ui: &mut UiCell<'_>,
) { ) {
let space_used = self.inventory.populated_slots(); let space_used = self.inventory.populated_slots();

View File

@ -1479,7 +1479,7 @@ impl<'a> Widget for Crafting<'a> {
}); });
self.inventory self.inventory
.slots_with_id() .slots_with_id()
.filter(|(_, item)| item.as_ref().map_or(false, |i| can_repair(i))) .filter(|(_, item)| item.as_ref().map_or(false, can_repair))
.for_each(|(slot, _)| { .for_each(|(slot, _)| {
events.push(Event::RepairItem { events.push(Event::RepairItem {
slot: Slot::Inventory(slot), slot: Slot::Inventory(slot),
@ -1489,7 +1489,7 @@ impl<'a> Widget for Crafting<'a> {
let can_perform = repair_slot let can_perform = repair_slot
.item(self.inventory) .item(self.inventory)
.map_or(false, |item| can_repair(item)); .map_or(false, can_repair);
(repair_slot.slot, None, can_perform) (repair_slot.slot, None, can_perform)
}, },

View File

@ -516,30 +516,28 @@ impl BuffIconKind {
impl PartialOrd for BuffIconKind { impl PartialOrd for BuffIconKind {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for BuffIconKind {
fn cmp(&self, other: &Self) -> Ordering {
match (self, other) { match (self, other) {
( (
BuffIconKind::Buff { kind, .. }, BuffIconKind::Buff { kind, .. },
BuffIconKind::Buff { BuffIconKind::Buff {
kind: other_kind, .. kind: other_kind, ..
}, },
) => Some(kind.cmp(other_kind)), ) => kind.cmp(other_kind),
(BuffIconKind::Buff { .. }, BuffIconKind::Stance(_)) => Some(Ordering::Greater), (BuffIconKind::Buff { .. }, BuffIconKind::Stance(_)) => Ordering::Greater,
(BuffIconKind::Stance(_), BuffIconKind::Buff { .. }) => Some(Ordering::Less), (BuffIconKind::Stance(_), BuffIconKind::Buff { .. }) => Ordering::Less,
(BuffIconKind::Stance(stance), BuffIconKind::Stance(stance_other)) => { (BuffIconKind::Stance(stance), BuffIconKind::Stance(stance_other)) => {
Some(stance.cmp(stance_other)) stance.cmp(stance_other)
}, },
} }
} }
} }
impl Ord for BuffIconKind {
fn cmp(&self, other: &Self) -> Ordering {
// We know this is safe since we can look at the partialord implementation and
// see that every variant is wrapped in Some
self.partial_cmp(other).unwrap()
}
}
impl PartialEq for BuffIconKind { impl PartialEq for BuffIconKind {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
match (self, other) { match (self, other) {
@ -586,7 +584,7 @@ impl BuffIcon {
buffs buffs
.iter_active() .iter_active()
.filter_map(BuffIcon::from_buffs) .filter_map(BuffIcon::from_buffs)
.chain(stance.and_then(BuffIcon::from_stance).into_iter()) .chain(stance.and_then(BuffIcon::from_stance))
.collect::<Vec<_>>() .collect::<Vec<_>>()
} }

View File

@ -223,7 +223,7 @@ impl<'a> Widget for Quest<'a> {
// [amount, item_desc] // [amount, item_desc]
//("common.items.weapons.sword.caladbolg"); //("common.items.weapons.sword.caladbolg");
let rewards = vec![ let rewards = [
(1, "common.items.weapons.dagger.starter_dagger", "Dagger"), (1, "common.items.weapons.dagger.starter_dagger", "Dagger"),
(4, "common.items.crafting_ing.seashells", "Seashell"), (4, "common.items.crafting_ing.seashells", "Seashell"),
( (

View File

@ -1,6 +1,10 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
#![allow(clippy::identity_op, clippy::option_map_unit_fn)] #![allow(
clippy::identity_op,
clippy::option_map_unit_fn,
clippy::needless_pass_by_ref_mut //until we find a better way for specs
)]
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#![feature( #![feature(
array_methods, array_methods,

View File

@ -529,8 +529,8 @@ pub fn generate_mesh<'a>(
( (
opaque_deep opaque_deep
.into_iter() .into_iter()
.chain(opaque_shallow.into_iter()) .chain(opaque_shallow)
.chain(opaque_surface.into_iter()) .chain(opaque_surface)
.collect(), .collect(),
fluid_mesh, fluid_mesh,
Mesh::new(), Mesh::new(),

View File

@ -1069,7 +1069,7 @@ fn mesh_hold() -> BoneMeshes {
) )
} }
///////// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct QuadrupedSmallCentralSpec(HashMap<(QSSpecies, QSBodyType), SidedQSCentralVoxSpec>); struct QuadrupedSmallCentralSpec(HashMap<(QSSpecies, QSBodyType), SidedQSCentralVoxSpec>);
@ -1660,7 +1660,7 @@ impl QuadrupedMediumLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct BirdMediumCentralSpec(HashMap<(BMSpecies, BMBodyType), SidedBMCentralVoxSpec>); struct BirdMediumCentralSpec(HashMap<(BMSpecies, BMBodyType), SidedBMCentralVoxSpec>);
@ -1914,7 +1914,7 @@ impl BirdMediumLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct TheropodCentralSpec(HashMap<(TSpecies, TBodyType), SidedTCentralVoxSpec>); struct TheropodCentralSpec(HashMap<(TSpecies, TBodyType), SidedTCentralVoxSpec>);
@ -2244,7 +2244,7 @@ impl TheropodLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct ArthropodCentralSpec(HashMap<(ASpecies, ABodyType), SidedACentralVoxSpec>); struct ArthropodCentralSpec(HashMap<(ASpecies, ABodyType), SidedACentralVoxSpec>);
@ -2644,7 +2644,7 @@ impl ArthropodLateralSpec {
(lateral, Vec3::from(spec.leg_br.offset)) (lateral, Vec3::from(spec.leg_br.offset))
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct FishMediumCentralSpec(HashMap<(FMSpecies, FMBodyType), SidedFMCentralVoxSpec>); struct FishMediumCentralSpec(HashMap<(FMSpecies, FMBodyType), SidedFMCentralVoxSpec>);
@ -2850,7 +2850,7 @@ impl FishMediumLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct FishSmallCentralSpec(HashMap<(FSSpecies, FSBodyType), SidedFSCentralVoxSpec>); struct FishSmallCentralSpec(HashMap<(FSSpecies, FSBodyType), SidedFSCentralVoxSpec>);
@ -2994,7 +2994,7 @@ impl FishSmallLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct BipedSmallWeaponSpec(HashMap<ToolKey, ArmorVoxSpec>); struct BipedSmallWeaponSpec(HashMap<ToolKey, ArmorVoxSpec>);
@ -3269,8 +3269,8 @@ impl BipedSmallWeaponSpec {
(tool_kind_segment, offset) (tool_kind_segment, offset)
} }
} }
////
//////
#[derive(Deserialize)] #[derive(Deserialize)]
struct DragonCentralSpec(HashMap<(DSpecies, DBodyType), SidedDCentralVoxSpec>); struct DragonCentralSpec(HashMap<(DSpecies, DBodyType), SidedDCentralVoxSpec>);
@ -3641,7 +3641,7 @@ impl DragonLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct BirdLargeCentralSpec(HashMap<(BLASpecies, BLABodyType), SidedBLACentralVoxSpec>); struct BirdLargeCentralSpec(HashMap<(BLASpecies, BLABodyType), SidedBLACentralVoxSpec>);
@ -4044,7 +4044,7 @@ impl BirdLargeLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct BipedLargeCentralSpec(HashMap<(BLSpecies, BLBodyType), SidedBLCentralVoxSpec>); struct BipedLargeCentralSpec(HashMap<(BLSpecies, BLBodyType), SidedBLCentralVoxSpec>);
@ -4462,7 +4462,8 @@ impl BipedLargeSecondSpec {
(tool_kind_segment, offset) (tool_kind_segment, offset)
} }
} }
////
//////
#[derive(Deserialize)] #[derive(Deserialize)]
struct GolemCentralSpec(HashMap<(GSpecies, GBodyType), SidedGCentralVoxSpec>); struct GolemCentralSpec(HashMap<(GSpecies, GBodyType), SidedGCentralVoxSpec>);
@ -4772,8 +4773,7 @@ impl GolemLateralSpec {
} }
} }
///// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct QuadrupedLowCentralSpec(HashMap<(QLSpecies, QLBodyType), SidedQLCentralVoxSpec>); struct QuadrupedLowCentralSpec(HashMap<(QLSpecies, QLBodyType), SidedQLCentralVoxSpec>);
@ -5050,8 +5050,7 @@ impl QuadrupedLowLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct ObjectCentralSpec(HashMap<object::Body, SidedObjectCentralVoxSpec>); struct ObjectCentralSpec(HashMap<object::Body, SidedObjectCentralVoxSpec>);

View File

@ -1101,8 +1101,8 @@ impl FigureMgr {
let holding_lantern = inventory let holding_lantern = inventory
.map_or(false, |i| i.equipped(EquipSlot::Lantern).is_some()) .map_or(false, |i| i.equipped(EquipSlot::Lantern).is_some())
&& light_emitter.is_some() && light_emitter.is_some()
&& !((matches!(second_tool_hand, Some(_)) && !(second_tool_hand.is_some()
|| matches!(active_tool_hand, Some(Hands::Two))) || matches!(active_tool_hand, Some(Hands::Two))
&& character.map_or(false, |c| c.is_wield())) && character.map_or(false, |c| c.is_wield()))
&& !character.map_or(false, |c| c.is_using_hands()) && !character.map_or(false, |c| c.is_using_hands())
&& physics.in_liquid().is_none(); && physics.in_liquid().is_none();

View File

@ -137,7 +137,7 @@ impl Scene {
figure_state: None, figure_state: None,
backdrop: backdrop.map(|specifier| { backdrop: backdrop.map(|specifier| {
let mut state = FigureState::new(renderer, FixtureSkeleton::default(), ()); let mut state = FigureState::new(renderer, FixtureSkeleton, ());
let mut greedy = FigureModel::make_greedy(); let mut greedy = FigureModel::make_greedy();
let mut opaque_mesh = Mesh::new(); let mut opaque_mesh = Mesh::new();
let (segment, offset) = load_mesh(specifier, Vec3::new(-55.0, -49.5, -2.0)); let (segment, offset) = load_mesh(specifier, Vec3::new(-55.0, -49.5, -2.0));

View File

@ -437,8 +437,8 @@ fn mesh_worker(
( (
deep_level deep_level
.into_iter() .into_iter()
.chain(shallow_level.into_iter()) .chain(shallow_level)
.chain(surface_level.into_iter()) .chain(surface_level)
.collect(), .collect(),
alt_indices, alt_indices,
) )

View File

@ -59,7 +59,7 @@ impl Interactable {
volume_pos: VolumePos, volume_pos: VolumePos,
interaction: Interaction, interaction: Interaction,
) -> Option<Self> { ) -> Option<Self> {
let Some(block) = volume_pos.get_block(terrain, id_maps, colliders) else { return None }; let block= volume_pos.get_block(terrain, id_maps, colliders)?;
let block_interaction = match interaction { let block_interaction = match interaction {
Interaction::Collect => { Interaction::Collect => {
// Check if this is an unlockable sprite // Check if this is an unlockable sprite

View File

@ -5,7 +5,7 @@ mod widget;
pub use defaults::Defaults; pub use defaults::Defaults;
pub(self) use primitive::Primitive; use primitive::Primitive;
use super::{ use super::{
super::graphic::{self, Graphic, TexId}, super::graphic::{self, Graphic, TexId},

View File

@ -675,6 +675,7 @@ impl Window {
.game_analog_button_map .game_analog_button_map
.get(&AnalogButton::from((button, code))) .get(&AnalogButton::from((button, code)))
{ {
#[allow(clippy::never_loop)]
for action in actions { for action in actions {
match *action {} match *action {}
} }
@ -684,6 +685,7 @@ impl Window {
.menu_analog_button_map .menu_analog_button_map
.get(&AnalogButton::from((button, code))) .get(&AnalogButton::from((button, code)))
{ {
#[allow(clippy::never_loop)]
for action in actions { for action in actions {
match *action {} match *action {}
} }

View File

@ -1036,7 +1036,6 @@ pub fn apply_caverns_to<R: Rng>(canvas: &mut Canvas, dynamic_rng: &mut R) {
} }
}; };
let cavern_top = cavern_top;
let mut last_kind = BlockKind::Rock; let mut last_kind = BlockKind::Rock;
for z in cavern_bottom - 1..cavern_top { for z in cavern_bottom - 1..cavern_top {
use SpriteKind::*; use SpriteKind::*;

View File

@ -2,7 +2,8 @@
#![allow( #![allow(
clippy::option_map_unit_fn, clippy::option_map_unit_fn,
clippy::blocks_in_if_conditions, clippy::blocks_in_if_conditions,
clippy::identity_op clippy::identity_op,
clippy::needless_pass_by_ref_mut //until we find a better way for specs
)] )]
#![allow(clippy::branches_sharing_code)] // TODO: evaluate #![allow(clippy::branches_sharing_code)] // TODO: evaluate
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]

View File

@ -31,7 +31,7 @@ impl<'a, R: Rng> NameGen<'a, R> {
]); ]);
let mut middle = cons.clone(); let mut middle = cons.clone();
middle.extend(vec!["tt"]); middle.extend(vec!["tt"]);
let vowel = vec!["o", "e", "a", "i", "u", "au", "ee", "ow", "ay", "ey", "oe"]; let vowel = ["o", "e", "a", "i", "u", "au", "ee", "ow", "ay", "ey", "oe"];
let end = vec![ let end = vec![
"et", "ige", "age", "ist", "en", "on", "og", "end", "ind", "ock", "een", "edge", "ist", "et", "ige", "age", "ist", "en", "on", "og", "end", "ind", "ock", "een", "edge", "ist",
"ed", "est", "eed", "ast", "olt", "ey", "ean", "ead", "onk", "ink", "eon", "er", "ow", "ed", "est", "eed", "ast", "olt", "ey", "ean", "ead", "onk", "ink", "eon", "er", "ow",

View File

@ -641,7 +641,7 @@ impl Archetype for House {
% 6 % 6
{ {
0 => SpriteKind::HangingSign, 0 => SpriteKind::HangingSign,
1 | 2 | 3 => SpriteKind::HangingBasket, 1..=3 => SpriteKind::HangingBasket,
4 => SpriteKind::WallSconce, 4 => SpriteKind::WallSconce,
5 => SpriteKind::WallLampSmall, 5 => SpriteKind::WallLampSmall,
_ => SpriteKind::DungeonWallDecor, _ => SpriteKind::DungeonWallDecor,

View File

@ -1414,7 +1414,7 @@ impl Land {
} }
} }
closed.into_iter().chain(open.into_iter()).collect() closed.into_iter().chain(open).collect()
} }
fn write_path( fn write_path(

View File

@ -298,7 +298,7 @@ impl GnarlingFortification {
wall_connections wall_connections
.iter() .iter()
.copied() .copied()
.zip(inner_tower_locs.into_iter()), .zip(inner_tower_locs),
) )
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -454,7 +454,6 @@ impl Structure for GnarlingFortification {
}) })
.for_each(|(point, next_point)| { .for_each(|(point, next_point)| {
// 2d world positions of each point in wall segment // 2d world positions of each point in wall segment
let point = point;
let start_wpos = point + self.origin; let start_wpos = point + self.origin;
let end_wpos = next_point + self.origin; let end_wpos = next_point + self.origin;
@ -1829,7 +1828,7 @@ impl Structure for GnarlingFortification {
} }
tunnels tunnels
.into_iter() .into_iter()
.chain(rooms.into_iter()) .chain(rooms)
.chain(core::iter::once(boss_room)) .chain(core::iter::once(boss_room))
.chain(core::iter::once(stump)) .chain(core::iter::once(stump))
.for_each(|prim| prim.fill(wood.clone())); .for_each(|prim| prim.fill(wood.clone()));
@ -1839,7 +1838,7 @@ impl Structure for GnarlingFortification {
let mut sprite_clear = Vec::new(); let mut sprite_clear = Vec::new();
tunnels_clear tunnels_clear
.into_iter() .into_iter()
.chain(rooms_clear.into_iter()) .chain(rooms_clear)
.chain(core::iter::once(boss_room_clear)) .chain(core::iter::once(boss_room_clear))
.for_each(|prim| { .for_each(|prim| {
sprite_clear.push(prim.translate(Vec3::new(0, 0, 1)).intersect(prim)); sprite_clear.push(prim.translate(Vec3::new(0, 0, 1)).intersect(prim));