additional cargo clippy for toolchain switch

This commit is contained in:
Marcel Märtens 2024-05-18 21:33:30 +02:00
parent dd43f3b281
commit e48fc4c2b2
25 changed files with 58 additions and 73 deletions

View File

@ -1987,9 +1987,9 @@ impl Client {
self.state.terrain().get_key_arc(chunk_pos).cloned() self.state.terrain().get_key_arc(chunk_pos).cloned()
} }
pub fn current<C: Component>(&self) -> Option<C> pub fn current<C>(&self) -> Option<C>
where where
C: Clone, C: Component + Clone,
{ {
self.state.read_storage::<C>().get(self.entity()).cloned() self.state.read_storage::<C>().get(self.entity()).cloned()
} }

View File

@ -168,7 +168,7 @@ impl<P: CompPacket> CompSyncPackage<P> {
.push((uid.into(), CompUpdateKind::Removed(PhantomData::<C>.into()))); .push((uid.into(), CompUpdateKind::Removed(PhantomData::<C>.into())));
} }
pub fn add_component_updates<'a, C: Component + Clone + Send + Sync>( pub fn add_component_updates<'a, C>(
&mut self, &mut self,
uids: &ReadStorage<'a, Uid>, uids: &ReadStorage<'a, Uid>,
tracker: &UpdateTracker<C>, tracker: &UpdateTracker<C>,
@ -176,7 +176,7 @@ impl<P: CompPacket> CompSyncPackage<P> {
filter: impl Join + Copy, filter: impl Join + Copy,
) where ) where
P: From<C>, P: From<C>,
C: TryFrom<P>, C: Component + Clone + Send + Sync + TryFrom<P>,
P::Phantom: From<PhantomData<C>>, P::Phantom: From<PhantomData<C>>,
P::Phantom: TryInto<PhantomData<C>>, P::Phantom: TryInto<PhantomData<C>>,
C::Storage: specs::storage::Tracked, C::Storage: specs::storage::Tracked,
@ -186,7 +186,7 @@ impl<P: CompPacket> CompSyncPackage<P> {
/// If there was an update to the component `C` on the provided entity this /// If there was an update to the component `C` on the provided entity this
/// will add the update to this package. /// will add the update to this package.
pub fn add_component_update<C: Component + Clone + Send + Sync>( pub fn add_component_update<C>(
&mut self, &mut self,
tracker: &UpdateTracker<C>, tracker: &UpdateTracker<C>,
storage: &ReadStorage<'_, C>, storage: &ReadStorage<'_, C>,
@ -194,7 +194,7 @@ impl<P: CompPacket> CompSyncPackage<P> {
entity: Entity, entity: Entity,
) where ) where
P: From<C>, P: From<C>,
C: TryFrom<P>, C: Component + Clone + Send + Sync + TryFrom<P>,
P::Phantom: From<PhantomData<C>>, P::Phantom: From<PhantomData<C>>,
P::Phantom: TryInto<PhantomData<C>>, P::Phantom: TryInto<PhantomData<C>>,
C::Storage: specs::storage::Tracked, C::Storage: specs::storage::Tracked,

View File

@ -24,6 +24,7 @@ impl core::str::FromStr for AdminRole {
} }
} }
#[allow(clippy::to_string_trait_impl)]
impl ToString for AdminRole { impl ToString for AdminRole {
fn to_string(&self) -> String { fn to_string(&self) -> String {
match self { match self {

View File

@ -139,12 +139,10 @@ impl Body {
)) ))
.unwrap_or_default(), .unwrap_or_default(),
), ),
Body::Armor(kind) => match kind {
ItemDropArmorKind::Neck | ItemDropArmorKind::Back | ItemDropArmorKind::Tabard => { Body::Armor(
default.yawed_left(random).pitched_down(PI / 2.0) ItemDropArmorKind::Neck | ItemDropArmorKind::Back | ItemDropArmorKind::Tabard,
}, ) => default.yawed_left(random).pitched_down(PI / 2.0),
_ => default.yawed_left(random),
},
_ => default.yawed_left(random), _ => default.yawed_left(random),
} }
} }

View File

@ -578,7 +578,7 @@ impl Serialize for ItemBase {
// Custom serialization for ItemDef, we only want to send the item_definition_id // Custom serialization for ItemDef, we only want to send the item_definition_id
// over the network, the client will use deserialize_item_def to fetch the // over the network, the client will use deserialize_item_def to fetch the
// ItemDef from assets. // ItemDef from assets.
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
S: Serializer, S: Serializer,
{ {

View File

@ -87,6 +87,7 @@ pub enum AliasError {
TooLong, TooLong,
} }
#[allow(clippy::to_string_trait_impl)]
impl ToString for AliasError { impl ToString for AliasError {
fn to_string(&self) -> String { fn to_string(&self) -> String {
match *self { match *self {

View File

@ -482,14 +482,14 @@ impl SkillSet {
/// ///
/// NOTE: Please don't use pathological or clever implementations of to_mut /// NOTE: Please don't use pathological or clever implementations of to_mut
/// here. /// here.
pub fn unlock_skill_cow<'a, B, C: 'a>( pub fn unlock_skill_cow<'a, B, C>(
this_: &'a mut B, this_: &'a mut B,
skill: Skill, skill: Skill,
to_mut: impl FnOnce(&'a mut B) -> &'a mut C, to_mut: impl FnOnce(&'a mut B) -> &'a mut C,
) -> Result<(), SkillUnlockError> ) -> Result<(), SkillUnlockError>
where where
B: Borrow<SkillSet>, B: Borrow<SkillSet>,
C: BorrowMut<SkillSet>, C: BorrowMut<SkillSet> + 'a,
{ {
if let Some(skill_group_kind) = skill.skill_group_kind() { if let Some(skill_group_kind) = skill.skill_group_kind() {
let this = (*this_).borrow(); let this = (*this_).borrow();

View File

@ -101,20 +101,14 @@ impl CharacterBehavior for Data {
timer: tick_attack_or_default(data, self.timer, None), timer: tick_attack_or_default(data, self.timer, None),
..*self ..*self
}); });
if let Body::Object(object) = data.body { if matches!(data.body, Body::Object(Flamethrower | Lavathrower)) {
match object { // Send local event used for frontend shenanigans
&Flamethrower | &Lavathrower => { output_events.emit_local(LocalEvent::CreateOutcome(
// Send local event used for frontend shenanigans Outcome::FlamethrowerCharge {
output_events.emit_local(LocalEvent::CreateOutcome( pos: data.pos.0 + *data.ori.look_dir() * (data.body.max_radius()),
Outcome::FlamethrowerCharge {
pos: data.pos.0
+ *data.ori.look_dir() * (data.body.max_radius()),
},
));
}, },
_ => {}, ));
} }
};
} else { } else {
let attack = { let attack = {
let energy = AttackEffect::new( let energy = AttackEffect::new(

View File

@ -32,7 +32,6 @@ pub struct StaticData {
pub vertical_leap_strength: f32, pub vertical_leap_strength: f32,
/// What key is used to press ability /// What key is used to press ability
pub ability_info: AbilityInfo, pub ability_info: AbilityInfo,
///
pub damage_effect: Option<CombatEffect>, pub damage_effect: Option<CombatEffect>,
} }

View File

@ -3,7 +3,7 @@ use core::hash::Hash;
use hashbrown::HashMap; use hashbrown::HashMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, Entity, FlaggedStorage, VecStorage}; use specs::{Component, Entity, FlaggedStorage, VecStorage};
use std::{fmt, u64}; use std::fmt;
use tracing::error; use tracing::error;
// TODO: could we switch this to `NonZeroU64`? // TODO: could we switch this to `NonZeroU64`?

View File

@ -1,4 +1,4 @@
#![feature(async_closure, exclusive_range_pattern)] #![feature(async_closure)]
//!run with //!run with
//! (cd network/examples/fileshare && RUST_BACKTRACE=1 cargo run //! (cd network/examples/fileshare && RUST_BACKTRACE=1 cargo run
//! --profile=release -Z unstable-options -- --trace=info --port 15006) //! --profile=release -Z unstable-options -- --trace=info --port 15006)

View File

@ -123,7 +123,7 @@ impl Shared {
async fn connect_manager(&self, network: Network) { async fn connect_manager(&self, network: Network) {
trace!("Start connect_manager"); trace!("Start connect_manager");
let iter = futures_util::stream::unfold(network, async move |mut network| { let iter = futures_util::stream::unfold(network, async move |mut network: Network| {
network.connected().await.ok().map(|v| (v, network)) network.connected().await.ok().map(|v| (v, network))
}); });

View File

@ -115,7 +115,6 @@ use specs::{
shred::SendDispatcher, Builder, Entity as EcsEntity, Entity, Join, LendJoin, WorldExt, shred::SendDispatcher, Builder, Entity as EcsEntity, Entity, Join, LendJoin, WorldExt,
}; };
use std::{ use std::{
i32,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
sync::{Arc, Mutex}, sync::{Arc, Mutex},
time::{Duration, Instant}, time::{Duration, Instant},

View File

@ -263,7 +263,7 @@ impl CharacterUpdater {
} }
pub fn has_pending_database_action(&self, character_id: CharacterId) -> bool { pub fn has_pending_database_action(&self, character_id: CharacterId) -> bool {
self.pending_database_actions.get(&character_id).is_some() self.pending_database_actions.contains_key(&character_id)
} }
pub fn process_batch_completion(&mut self, completed_batch_id: u64) { pub fn process_batch_completion(&mut self, completed_batch_id: u64) {

View File

@ -146,6 +146,7 @@ impl core::str::FromStr for SqlLogMode {
} }
} }
#[allow(clippy::to_string_trait_impl)]
impl ToString for SqlLogMode { impl ToString for SqlLogMode {
fn to_string(&self) -> String { fn to_string(&self) -> String {
match self { match self {

View File

@ -92,14 +92,13 @@ impl<'a> System<'a> for Sys {
fn base_ori_interp(body: &Body) -> f32 { fn base_ori_interp(body: &Body) -> f32 {
match body { match body {
Body::Object(object) => match object { Body::Object(
object::Body::Crossbow object::Body::Crossbow
| object::Body::Flamethrower | object::Body::Flamethrower
| object::Body::Lavathrower | object::Body::Lavathrower
| object::Body::HaniwaSentry | object::Body::HaniwaSentry
| object::Body::TerracottaStatue => 100.0, | object::Body::TerracottaStatue,
_ => 10.0, ) => 100.0,
},
_ => 10.0, _ => 10.0,
} }
} }

View File

@ -318,7 +318,7 @@ impl<'a> Widget for Chat<'a> {
} }
if let Some(comps) = &self.force_completions { if let Some(comps) = &self.force_completions {
state.update(|s| s.completions = comps.clone()); state.update(|s| s.completions.clone_from(comps));
} }
let mut force_cursor = self.force_cursor; let mut force_cursor = self.force_cursor;
@ -394,8 +394,8 @@ impl<'a> Widget for Chat<'a> {
} else if s.history_pos > 0 { } else if s.history_pos > 0 {
s.history_pos -= 1; s.history_pos -= 1;
} }
if s.history_pos > 0 { if let Some(before) = s.history.iter().nth_back(s.history.len() - s.history_pos) {
s.input.message = s.history.get(s.history_pos - 1).unwrap().to_owned(); s.input.message.clone_from(before);
force_cursor = cursor_offset_to_index( force_cursor = cursor_offset_to_index(
s.input.message.len(), s.input.message.len(),
&s.input.message, &s.input.message,

View File

@ -746,7 +746,7 @@ impl<'a> Trade<'a> {
.set(state.ids.amount_input, ui) .set(state.ids.amount_input, ui)
{ {
if new_input != key.input { if new_input != key.input {
key.input = new_input.trim().to_owned(); new_input.trim().clone_into(&mut key.input);
if !key.input.is_empty() { if !key.input.is_empty() {
// trade amount can change with (shift||ctrl)-click // trade amount can change with (shift||ctrl)-click
let amount = *trade.offers[key.who].get(&key.slot).unwrap_or(&0); let amount = *trade.offers[key.who].get(&key.slot).unwrap_or(&0);

View File

@ -182,7 +182,7 @@ fn main() {
?selected_language, ?selected_language,
"Impossible to load language: change to the default language (English) instead.", "Impossible to load language: change to the default language (English) instead.",
); );
settings.language.selected_language = i18n::REFERENCE_LANG.to_owned(); i18n::REFERENCE_LANG.clone_into(&mut settings.language.selected_language);
LocalizationHandle::load_expect(&settings.language.selected_language) LocalizationHandle::load_expect(&settings.language.selected_language)
}); });
i18n.set_english_fallback(settings.language.use_english_fallback); i18n.set_english_fallback(settings.language.use_english_fallback);

View File

@ -376,8 +376,8 @@ impl PlayState for MainMenuState {
let use_srv = net_settings.use_srv; let use_srv = net_settings.use_srv;
let use_quic = net_settings.use_quic; let use_quic = net_settings.use_quic;
let validate_tls = net_settings.validate_tls; let validate_tls = net_settings.validate_tls;
net_settings.username = username.clone(); net_settings.username.clone_from(&username);
net_settings.default_server = server_address.clone(); net_settings.default_server.clone_from(&server_address);
if !net_settings.servers.contains(&server_address) { if !net_settings.servers.contains(&server_address) {
net_settings.servers.push(server_address.clone()); net_settings.servers.push(server_address.clone());
} }

View File

@ -549,7 +549,7 @@ impl Controls {
}, },
Message::ServerChanged(new_value) => { Message::ServerChanged(new_value) => {
self.selected_server_index = Some(new_value); self.selected_server_index = Some(new_value);
self.login_info.server = servers[new_value].clone(); self.login_info.server.clone_from(&servers[new_value]);
}, },
Message::FocusPassword => { Message::FocusPassword => {
if let Screen::Login { screen, .. } = &mut self.screen { if let Screen::Login { screen, .. } = &mut self.screen {

View File

@ -18,7 +18,7 @@ use vek::*;
// /// NOTE: bone_idx must be in [0, 15] (may be bumped to [0, 31] at some // /// NOTE: bone_idx must be in [0, 15] (may be bumped to [0, 31] at some
// /// point). // /// point).
// TODO: this function name... // TODO: this function name...
pub fn generate_mesh_base_vol_figure<'a: 'b, 'b, V: 'a>( pub fn generate_mesh_base_vol_figure<'a: 'b, 'b, V>(
vol: V, vol: V,
(greedy, opaque_mesh, offs, scale, bone_idx): ( (greedy, opaque_mesh, offs, scale, bone_idx): (
&'b mut GreedyMesh<'a, FigureSpriteAtlasData>, &'b mut GreedyMesh<'a, FigureSpriteAtlasData>,
@ -29,7 +29,7 @@ pub fn generate_mesh_base_vol_figure<'a: 'b, 'b, V: 'a>(
), ),
) -> MeshGen<TerrainVertex, TerrainVertex, TerrainVertex, math::Aabb<f32>> ) -> MeshGen<TerrainVertex, TerrainVertex, TerrainVertex, math::Aabb<f32>>
where where
V: BaseVol<Vox = Cell> + ReadVol + SizedVol, V: BaseVol<Vox = Cell> + ReadVol + SizedVol + 'a,
{ {
assert!(bone_idx <= 15, "Bone index for figures must be in [0, 15]"); assert!(bone_idx <= 15, "Bone index for figures must be in [0, 15]");
let max_size = greedy.max_size(); let max_size = greedy.max_size();
@ -115,7 +115,7 @@ where
// /// NOTE: bone_idx must be in [0, 15] (may be bumped to [0, 31] at some // /// NOTE: bone_idx must be in [0, 15] (may be bumped to [0, 31] at some
// /// point). // /// point).
// TODO: this function name... // TODO: this function name...
pub fn generate_mesh_base_vol_terrain<'a: 'b, 'b, V: 'a>( pub fn generate_mesh_base_vol_terrain<'a: 'b, 'b, V>(
vol: V, vol: V,
(greedy, opaque_mesh, offs, scale, bone_idx): ( (greedy, opaque_mesh, offs, scale, bone_idx): (
&'b mut GreedyMesh<'a, FigureSpriteAtlasData>, &'b mut GreedyMesh<'a, FigureSpriteAtlasData>,
@ -126,7 +126,7 @@ pub fn generate_mesh_base_vol_terrain<'a: 'b, 'b, V: 'a>(
), ),
) -> MeshGen<TerrainVertex, TerrainVertex, TerrainVertex, math::Aabb<f32>> ) -> MeshGen<TerrainVertex, TerrainVertex, TerrainVertex, math::Aabb<f32>>
where where
V: BaseVol<Vox = Block> + ReadVol + SizedVol, V: BaseVol<Vox = Block> + ReadVol + SizedVol + 'a,
{ {
assert!(bone_idx <= 15, "Bone index for figures must be in [0, 15]"); assert!(bone_idx <= 15, "Bone index for figures must be in [0, 15]");
let max_size = greedy.max_size(); let max_size = greedy.max_size();
@ -218,7 +218,7 @@ where
(Mesh::new(), Mesh::new(), Mesh::new(), bounds) (Mesh::new(), Mesh::new(), Mesh::new(), bounds)
} }
pub fn generate_mesh_base_vol_sprite<'a: 'b, 'b, V: 'a>( pub fn generate_mesh_base_vol_sprite<'a: 'b, 'b, V>(
vol: V, vol: V,
(greedy, opaque_mesh, vertical_stripes): ( (greedy, opaque_mesh, vertical_stripes): (
&'b mut GreedyMesh<'a, FigureSpriteAtlasData, greedy::SpriteAtlasAllocator>, &'b mut GreedyMesh<'a, FigureSpriteAtlasData, greedy::SpriteAtlasAllocator>,
@ -228,7 +228,7 @@ pub fn generate_mesh_base_vol_sprite<'a: 'b, 'b, V: 'a>(
offset: Vec3<f32>, offset: Vec3<f32>,
) -> MeshGen<SpriteVertex, SpriteVertex, TerrainVertex, ()> ) -> MeshGen<SpriteVertex, SpriteVertex, TerrainVertex, ()>
where where
V: BaseVol<Vox = Cell> + ReadVol + SizedVol, V: BaseVol<Vox = Cell> + ReadVol + SizedVol + 'a,
{ {
let max_size = greedy.max_size(); let max_size = greedy.max_size();
// NOTE: Required because we steal two bits from the normal in the shadow uint // NOTE: Required because we steal two bits from the normal in the shadow uint
@ -345,12 +345,12 @@ where
(Mesh::new(), Mesh::new(), Mesh::new(), ()) (Mesh::new(), Mesh::new(), Mesh::new(), ())
} }
pub fn generate_mesh_base_vol_particle<'a: 'b, 'b, V: 'a>( pub fn generate_mesh_base_vol_particle<'a: 'b, 'b, V>(
vol: V, vol: V,
greedy: &'b mut GreedyMesh<'a, FigureSpriteAtlasData>, greedy: &'b mut GreedyMesh<'a, FigureSpriteAtlasData>,
) -> MeshGen<ParticleVertex, ParticleVertex, TerrainVertex, ()> ) -> MeshGen<ParticleVertex, ParticleVertex, TerrainVertex, ()>
where where
V: BaseVol<Vox = Cell> + ReadVol + SizedVol, V: BaseVol<Vox = Cell> + ReadVol + SizedVol + 'a,
{ {
let max_size = greedy.max_size(); let max_size = greedy.max_size();
// NOTE: Required because we steal two bits from the normal in the shadow uint // NOTE: Required because we steal two bits from the normal in the shadow uint
@ -437,7 +437,7 @@ fn should_draw_greedy(
let from = flat_get(pos - delta); let from = flat_get(pos - delta);
let to = flat_get(pos); let to = flat_get(pos);
let from_opaque = from.is_filled(); let from_opaque = from.is_filled();
if from_opaque != !to.is_filled() { if from_opaque == to.is_filled() {
None None
} else { } else {
// If going from transparent to opaque, backward facing; otherwise, forward // If going from transparent to opaque, backward facing; otherwise, forward
@ -456,7 +456,7 @@ fn should_draw_greedy_ao(
let from = flat_get(pos - delta); let from = flat_get(pos - delta);
let to = flat_get(pos); let to = flat_get(pos);
let from_opaque = from.is_filled(); let from_opaque = from.is_filled();
if from_opaque != !to.is_filled() { if from_opaque == to.is_filled() {
None None
} else { } else {
let faces_forward = from_opaque; let faces_forward = from_opaque;

View File

@ -5665,14 +5665,11 @@ impl ItemDropCentralSpec {
(segment, match item_drop { (segment, match item_drop {
// TODO: apply non-random rotations to items here // TODO: apply non-random rotations to items here
item_drop::Body::Tool(_) => Vec3::new(offset.x - 2.0, offset.y, offset.z), item_drop::Body::Tool(_) => Vec3::new(offset.x - 2.0, offset.y, offset.z),
item_drop::Body::Armor(kind) => match kind { item_drop::Body::Armor(
item_drop::ItemDropArmorKind::Neck item_drop::ItemDropArmorKind::Neck
| item_drop::ItemDropArmorKind::Back | item_drop::ItemDropArmorKind::Back
| item_drop::ItemDropArmorKind::Tabard => { | item_drop::ItemDropArmorKind::Tabard,
Vec3::new(offset.x, offset.y - 2.0, offset.z) ) => Vec3::new(offset.x, offset.y - 2.0, offset.z),
},
_ => offset * Vec3::new(1.0, 1.0, 0.0),
},
_ => offset * Vec3::new(1.0, 1.0, 0.0), _ => offset * Vec3::new(1.0, 1.0, 0.0),
}) })
} else { } else {

View File

@ -241,14 +241,10 @@ impl FigureMgrStates {
} }
} }
fn get_mut<'a, Q: ?Sized>( fn get_mut<'a, Q>(&'a mut self, body: &Body, entity: &Q) -> Option<&'a mut FigureStateMeta>
&'a mut self,
body: &Body,
entity: &Q,
) -> Option<&'a mut FigureStateMeta>
where where
EcsEntity: Borrow<Q>, EcsEntity: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq + ?Sized,
{ {
match body { match body {
Body::Humanoid(_) => self Body::Humanoid(_) => self
@ -320,10 +316,10 @@ impl FigureMgrStates {
} }
} }
fn remove<Q: ?Sized>(&mut self, body: &Body, entity: &Q) -> Option<FigureStateMeta> fn remove<Q>(&mut self, body: &Body, entity: &Q) -> Option<FigureStateMeta>
where where
EcsEntity: Borrow<Q>, EcsEntity: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq + ?Sized,
{ {
match body { match body {
Body::Humanoid(_) => self.character_states.remove(entity).map(|e| e.meta), Body::Humanoid(_) => self.character_states.remove(entity).map(|e| e.meta),
@ -494,14 +490,14 @@ impl FigureMgrStates {
.count() .count()
} }
fn get_terrain_locals<'a, Q: ?Sized>( fn get_terrain_locals<'a, Q>(
&'a self, &'a self,
body: &Body, body: &Body,
entity: &Q, entity: &Q,
) -> Option<&'a BoundTerrainLocals> ) -> Option<&'a BoundTerrainLocals>
where where
EcsEntity: Borrow<Q>, EcsEntity: Borrow<Q>,
Q: Hash + Eq, Q: Hash + Eq + ?Sized,
{ {
match body { match body {
Body::Ship(body) => { Body::Ship(body) => {

View File

@ -214,7 +214,7 @@ impl SingleplayerWorlds {
'fail: loop { 'fail: loop {
for world in self.worlds.iter() { for world in self.worlds.iter() {
if world.path.ends_with(&test_name) { if world.path.ends_with(&test_name) {
test_name = name.clone(); test_name.clone_from(&name);
test_name.push('_'); test_name.push('_');
test_name.push_str(&i.to_string()); test_name.push_str(&i.to_string());
i += 1; i += 1;