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()
}
pub fn current<C: Component>(&self) -> Option<C>
pub fn current<C>(&self) -> Option<C>
where
C: Clone,
C: Component + Clone,
{
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())));
}
pub fn add_component_updates<'a, C: Component + Clone + Send + Sync>(
pub fn add_component_updates<'a, C>(
&mut self,
uids: &ReadStorage<'a, Uid>,
tracker: &UpdateTracker<C>,
@ -176,7 +176,7 @@ impl<P: CompPacket> CompSyncPackage<P> {
filter: impl Join + Copy,
) where
P: From<C>,
C: TryFrom<P>,
C: Component + Clone + Send + Sync + TryFrom<P>,
P::Phantom: From<PhantomData<C>>,
P::Phantom: TryInto<PhantomData<C>>,
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
/// 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,
tracker: &UpdateTracker<C>,
storage: &ReadStorage<'_, C>,
@ -194,7 +194,7 @@ impl<P: CompPacket> CompSyncPackage<P> {
entity: Entity,
) where
P: From<C>,
C: TryFrom<P>,
C: Component + Clone + Send + Sync + TryFrom<P>,
P::Phantom: From<PhantomData<C>>,
P::Phantom: TryInto<PhantomData<C>>,
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 {
fn to_string(&self) -> String {
match self {

View File

@ -139,12 +139,10 @@ impl Body {
))
.unwrap_or_default(),
),
Body::Armor(kind) => match kind {
ItemDropArmorKind::Neck | ItemDropArmorKind::Back | ItemDropArmorKind::Tabard => {
default.yawed_left(random).pitched_down(PI / 2.0)
},
_ => default.yawed_left(random),
},
Body::Armor(
ItemDropArmorKind::Neck | ItemDropArmorKind::Back | ItemDropArmorKind::Tabard,
) => default.yawed_left(random).pitched_down(PI / 2.0),
_ => 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
// over the network, the client will use deserialize_item_def to fetch the
// 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
S: Serializer,
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -123,7 +123,7 @@ impl Shared {
async fn connect_manager(&self, network: Network) {
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))
});

View File

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

View File

@ -263,7 +263,7 @@ impl CharacterUpdater {
}
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) {

View File

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

View File

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

View File

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

View File

@ -746,7 +746,7 @@ impl<'a> Trade<'a> {
.set(state.ids.amount_input, ui)
{
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() {
// trade amount can change with (shift||ctrl)-click
let amount = *trade.offers[key.who].get(&key.slot).unwrap_or(&0);

View File

@ -182,7 +182,7 @@ fn main() {
?selected_language,
"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)
});
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_quic = net_settings.use_quic;
let validate_tls = net_settings.validate_tls;
net_settings.username = username.clone();
net_settings.default_server = server_address.clone();
net_settings.username.clone_from(&username);
net_settings.default_server.clone_from(&server_address);
if !net_settings.servers.contains(&server_address) {
net_settings.servers.push(server_address.clone());
}

View File

@ -549,7 +549,7 @@ impl Controls {
},
Message::ServerChanged(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 => {
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
// /// point).
// 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,
(greedy, opaque_mesh, offs, scale, bone_idx): (
&'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>>
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]");
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
// /// point).
// 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,
(greedy, opaque_mesh, offs, scale, bone_idx): (
&'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>>
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]");
let max_size = greedy.max_size();
@ -218,7 +218,7 @@ where
(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,
(greedy, opaque_mesh, vertical_stripes): (
&'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>,
) -> MeshGen<SpriteVertex, SpriteVertex, TerrainVertex, ()>
where
V: BaseVol<Vox = Cell> + ReadVol + SizedVol,
V: BaseVol<Vox = Cell> + ReadVol + SizedVol + 'a,
{
let max_size = greedy.max_size();
// 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(), ())
}
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,
greedy: &'b mut GreedyMesh<'a, FigureSpriteAtlasData>,
) -> MeshGen<ParticleVertex, ParticleVertex, TerrainVertex, ()>
where
V: BaseVol<Vox = Cell> + ReadVol + SizedVol,
V: BaseVol<Vox = Cell> + ReadVol + SizedVol + 'a,
{
let max_size = greedy.max_size();
// 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 to = flat_get(pos);
let from_opaque = from.is_filled();
if from_opaque != !to.is_filled() {
if from_opaque == to.is_filled() {
None
} else {
// 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 to = flat_get(pos);
let from_opaque = from.is_filled();
if from_opaque != !to.is_filled() {
if from_opaque == to.is_filled() {
None
} else {
let faces_forward = from_opaque;

View File

@ -5665,14 +5665,11 @@ impl ItemDropCentralSpec {
(segment, match item_drop {
// 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::Armor(kind) => match kind {
item_drop::Body::Armor(
item_drop::ItemDropArmorKind::Neck
| item_drop::ItemDropArmorKind::Back
| item_drop::ItemDropArmorKind::Tabard => {
Vec3::new(offset.x, offset.y - 2.0, offset.z)
},
_ => offset * Vec3::new(1.0, 1.0, 0.0),
},
| item_drop::ItemDropArmorKind::Tabard,
) => Vec3::new(offset.x, offset.y - 2.0, offset.z),
_ => offset * Vec3::new(1.0, 1.0, 0.0),
})
} else {

View File

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

View File

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