diff --git a/common/src/terrain/block.rs b/common/src/terrain/block.rs index 6f5eeb8996..cadf0a40bd 100644 --- a/common/src/terrain/block.rs +++ b/common/src/terrain/block.rs @@ -116,7 +116,7 @@ impl BlockKind { /// # Format /// -/// ``` +/// ```ignore /// BBBBBBBB CCCCCCCC AAAAAIII IIIIIIII /// ``` /// - `0..8` : BlockKind @@ -194,13 +194,6 @@ impl Block { #[inline] pub const fn air(sprite: SpriteKind) -> Self { Self::unfilled(BlockKind::Air, sprite) } - #[inline] - pub const fn lava(sprite: SpriteKind) -> Self { - // TODO: Is this valid? I don't think so, lava is filled. Debug panic will catch - // it if not though. - Self::unfilled(BlockKind::Lava, sprite) - } - #[inline] pub const fn empty() -> Self { Self::air(SpriteKind::Empty) } @@ -260,7 +253,7 @@ impl Block { pub fn get_attr(&self) -> Result> { match self.sprite_category() { Some(category) => category.read_attr(*self), - None => return Err(sprite::AttributeError::NotPresent), + None => Err(sprite::AttributeError::NotPresent), } } @@ -271,7 +264,7 @@ impl Block { } #[inline(always)] - pub(super) const fn to_be_u32(&self) -> u32 { + pub(super) const fn to_be_u32(self) -> u32 { u32::from_be_bytes([self.kind as u8, self.data[0], self.data[1], self.data[2]]) } @@ -666,7 +659,7 @@ impl Block { } #[inline] - pub fn to_u32(&self) -> u32 { + pub fn to_u32(self) -> u32 { u32::from_le_bytes([self.kind as u8, self.data[0], self.data[1], self.data[2]]) } } diff --git a/common/src/terrain/sprite.rs b/common/src/terrain/sprite.rs index 896a5b5998..f3c76cf341 100644 --- a/common/src/terrain/sprite.rs +++ b/common/src/terrain/sprite.rs @@ -52,7 +52,10 @@ use hashbrown::HashMap; use lazy_static::lazy_static; use num_derive::FromPrimitive; use serde::{Deserialize, Serialize}; -use std::{convert::TryFrom, fmt}; +use std::{ + convert::{Infallible, TryFrom}, + fmt, +}; use strum::EnumIter; use vek::*; @@ -323,8 +326,6 @@ sprites! { }, } -use core::convert::Infallible; - attributes! { Ori { bits: 4, err: Infallible, from: |bits| Ok(Self(bits as u8)), into: |Ori(x)| x as u16 }, Growth { bits: 4, err: Infallible, from: |bits| Ok(Self(bits as u8)), into: |Growth(x)| x as u16 }, diff --git a/common/src/terrain/sprite/magic.rs b/common/src/terrain/sprite/magic.rs index 5ebd2a2687..91729d97b5 100644 --- a/common/src/terrain/sprite/magic.rs +++ b/common/src/terrain/sprite/magic.rs @@ -128,7 +128,7 @@ macro_rules! sprites { #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize, EnumIter, FromPrimitive)] #[repr(u32)] pub enum SpriteKind { - $($($sprite_name = crate::terrain::sprite::gen_discriminant(crate::terrain::sprite::Category::$category_name, $sprite_id),)*)* + $($($sprite_name = $crate::terrain::sprite::gen_discriminant($crate::terrain::sprite::Category::$category_name, $sprite_id),)*)* } ); @@ -197,12 +197,15 @@ macro_rules! attributes { } } - $(impl Attribute for $name { - const INDEX: usize = Attributes::$name as usize; - const BITS: u8 = $bits; - type Error = $err; - #[inline(always)] fn from_bits(bits: u16) -> Result { $from_bits(bits) } - #[inline(always)] fn into_bits(self) -> u16 { $into_bits(self) } - })* + $( + #[allow(clippy::all)] + impl Attribute for $name { + const INDEX: usize = Attributes::$name as usize; + const BITS: u8 = $bits; + type Error = $err; + #[inline(always)] fn from_bits(bits: u16) -> Result { $from_bits(bits) } + #[inline(always)] fn into_bits(self) -> u16 { $into_bits(self) } + } + )* }; } diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index 1e4705e72a..af8fb1016b 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -212,7 +212,7 @@ impl TryFrom>>> for SpriteSpec { type Error = SpritesMissing; fn try_from( - mut map: HashMap>>, + map: HashMap>>, ) -> Result { Ok(Self(map))