apply some clippy fixes that comes with the new toolchain version

This commit is contained in:
Marcel Märtens 2021-09-24 23:11:05 +02:00
parent 2a82405df2
commit e36eef99c8
17 changed files with 22 additions and 101 deletions

View File

@ -1,7 +1,4 @@
#![allow(incomplete_features)]
#![feature(
generic_const_exprs,
const_fn_floating_point_arithmetic,
)]
#![feature(generic_const_exprs, const_fn_floating_point_arithmetic)]
pub mod msg;
pub mod sync;

View File

@ -375,6 +375,7 @@ impl<T> AbilitySet<T> {
}
}
#[allow(clippy::derivable_impls)]
impl Default for AbilitySet<CharacterAbility> {
fn default() -> Self {
AbilitySet {

View File

@ -41,7 +41,7 @@ pub enum GameMode {
#[derive(Copy, Clone, Default, Debug)]
pub struct PlayerEntity(pub Option<Entity>);
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Default)]
pub struct PlayerPhysicsSetting {
/// true if the client wants server-authoratative physics (e.g. to use
/// airships properly)
@ -51,15 +51,6 @@ pub struct PlayerPhysicsSetting {
pub server_force: bool,
}
impl Default for PlayerPhysicsSetting {
fn default() -> PlayerPhysicsSetting {
PlayerPhysicsSetting {
client_optin: false,
server_force: false,
}
}
}
impl PlayerPhysicsSetting {
pub fn server_authoritative(&self) -> bool { self.client_optin || self.server_force }

View File

@ -54,12 +54,9 @@ fn skills_from_nodes(nodes: &[SkillNode]) -> Vec<(Skill, Option<u16>)> {
skills
}
#[derive(Default)]
pub struct SkillSetBuilder(SkillSet);
impl Default for SkillSetBuilder {
fn default() -> Self { Self(SkillSet::default()) }
}
impl SkillSetBuilder {
/// Creates `SkillSetBuilder` from `asset_specifier`
#[must_use]

View File

@ -151,7 +151,7 @@ impl CharacterBehavior for Data {
// and applying `pitch` to get needed orientation.
let look_dir = data.inputs.look_dir;
let xy_dir = Dir::from_unnormalized(Vec3::new(look_dir.x, look_dir.y, 0.0))
.unwrap_or_else(Dir::default);
.unwrap_or_default();
let pitch = xy_dir.rotation_between(look_dir);
Ori::from(Vec3::new(

View File

@ -1,7 +1,4 @@
#[derive(Default)]
pub struct Input {
// TODO: Use this type to manage server input.
}
impl Default for Input {
fn default() -> Self { Input {} }
}

View File

@ -1662,9 +1662,9 @@ impl<'a> AgentData<'a> {
Some((entity, *e_pos))
} else if let Some(villain_info) = guard_duty(e_health, e_alignment) {
Some(villain_info)
} else if rtsim_remember(e_stats, agent, event_emitter) {
Some((entity, *e_pos))
} else if npc_sees_cultist(e_stats, e_inventory, agent, event_emitter) {
} else if rtsim_remember(e_stats, agent, event_emitter)
|| npc_sees_cultist(e_stats, e_inventory, agent, event_emitter)
{
Some((entity, *e_pos))
} else {
None

View File

@ -87,7 +87,7 @@ impl Animation for SpinAnimation {
next.head.orientation = Quaternion::rotation_y(movement1 * 0.1 - movement2 * -0.1)
* Quaternion::rotation_z(1.07 + movement1 * 0.4 + movement2 * -1.5);
next.torso.orientation = Quaternion::rotation_z(movement2 * 6.28);
next.torso.orientation = Quaternion::rotation_z(movement2 * std::f32::consts::TAU);
}
if let Some(ToolKind::Axe | ToolKind::Hammer | ToolKind::Dagger) = active_tool_kind {

View File

@ -27,21 +27,12 @@ pub enum SlotContents {
Ability4,
}
#[derive(Clone, Debug)]
#[derive(Clone, Copy, Default)]
pub struct State {
pub slots: [Option<SlotContents>; 10],
inputs: [bool; 10],
}
impl Default for State {
fn default() -> Self {
Self {
slots: [None; 10],
inputs: [false; 10],
}
}
}
impl State {
pub fn new(slots: [Option<SlotContents>; 10]) -> Self {
Self {

View File

@ -378,6 +378,7 @@ impl Controls {
.position(|i| i.character.id == Some(id))
});
#[allow(clippy::if_same_then_else)]
if let Some(error) = error {
// TODO: use more user friendly errors with suggestions on potential solutions
// instead of directly showing error message here

View File

@ -209,6 +209,7 @@ pub enum ShadowMode {
Cheap,
}
#[allow(clippy::derivable_impls)]
impl Default for ShadowMode {
fn default() -> Self { ShadowMode::Map(Default::default()) }
}

View File

@ -310,7 +310,7 @@ impl Renderer {
| (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES),
limits,
},
trace_path.as_deref(),
trace_path,
))?;
// Set error handler for wgpu errors

View File

@ -136,11 +136,11 @@ pub mod con_settings {
pub scroll_y: Axis,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct GameAnalogButton {}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct MenuAnalogButton {}
@ -246,12 +246,4 @@ pub mod con_settings {
}
}
}
impl Default for GameAnalogButton {
fn default() -> Self { Self {} }
}
impl Default for MenuAnalogButton {
fn default() -> Self { Self {} }
}
}

View File

@ -19,7 +19,7 @@ impl Background {
}
}
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Default)]
pub struct Style {
background: Option<Background>,
check: Option<image::Handle>,
@ -82,12 +82,3 @@ impl Style {
self.background.as_ref().map(|b| b.default)
}
}
impl Default for Style {
fn default() -> Self {
Self {
background: None,
check: None,
}
}
}

View File

@ -875,12 +875,7 @@ impl Ui {
switch_to_plain_state!();
// Mesh should already be cached.
mesh.push_mesh(
text_cache
.get(&widget_id)
.as_deref()
.unwrap_or(&Mesh::new()),
);
mesh.push_mesh(text_cache.get(&widget_id).unwrap_or(&Mesh::new()));
},
PrimitiveKind::Rectangle { color } => {
let color = srgba_to_linear(color.to_fsa().into());

View File

@ -7,11 +7,7 @@
)]
#![allow(clippy::branches_sharing_code)] // TODO: evaluate
#![deny(clippy::clone_on_ref_ptr)]
#![feature(
bool_to_option,
const_panic,
label_break_value
)]
#![feature(bool_to_option, const_panic, label_break_value)]
mod all;
mod block;

View File

@ -274,24 +274,14 @@ impl<V: Copy + Default> LaborMap<V> {
}
}
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct AreaResources {
pub resource_sum: GoodMap<f32>,
pub resource_chunks: GoodMap<f32>,
pub chunks: u32,
}
impl Default for AreaResources {
fn default() -> Self {
Self {
resource_sum: GoodMap::default(),
resource_chunks: GoodMap::default(),
chunks: 0,
}
}
}
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct NaturalResources {
// resources per distance, we should increase labor cost for far resources
pub per_area: Vec<AreaResources>,
@ -301,16 +291,6 @@ pub struct NaturalResources {
pub average_yield_per_chunk: GoodMap<f32>,
}
impl Default for NaturalResources {
fn default() -> Self {
Self {
per_area: Vec::new(),
chunks_per_resource: GoodMap::default(),
average_yield_per_chunk: GoodMap::default(),
}
}
}
#[derive(Debug, Deserialize)]
pub struct RawProfessions(Vec<RawProfession>);
@ -383,21 +363,12 @@ pub struct TradeDelivery {
pub supply: GoodMap<f32>, // maximum amount available, at the time of interaction
}
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct TradeInformation {
pub orders: DHashMap<Id<Site>, Vec<TradeOrder>>, // per provider
pub deliveries: DHashMap<Id<Site>, Vec<TradeDelivery>>, // per receiver
}
impl Default for TradeInformation {
fn default() -> Self {
Self {
orders: Default::default(),
deliveries: Default::default(),
}
}
}
#[derive(Debug)]
pub struct NeighborInformation {
pub id: Id<Site>,