Skip to content

Commit

Permalink
clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kralverde committed Nov 28, 2024
1 parent f252f62 commit 30aca6b
Show file tree
Hide file tree
Showing 26 changed files with 42 additions and 43 deletions.
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/bytebuf/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<'a> Deserializer<'a> {
}
}

impl<'a, 'de> de::Deserializer<'de> for Deserializer<'a> {
impl<'de> de::Deserializer<'de> for Deserializer<'_> {
type Error = DeserializerError;

fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/bytebuf/packet_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{BitSet, ClientPacket, ServerPacket, VarInt, VarIntType, VarLong};

use super::{deserializer, serializer, ByteBuffer, DeserializerError};

impl<'a> Serialize for BitSet<'a> {
impl Serialize for BitSet<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
16 changes: 8 additions & 8 deletions pumpkin-protocol/src/bytebuf/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl ser::Error for SerializerError {
// Structs are ignored
// Iterables' values are written in order, but NO information (e.g. size) about the
// iterable itself is written (list sizes should be a seperate field)
impl<'a> ser::Serializer for &'a mut Serializer {
impl ser::Serializer for &mut Serializer {
type Ok = ();
type Error = SerializerError;

Expand Down Expand Up @@ -226,7 +226,7 @@ impl<'a> ser::Serializer for &'a mut Serializer {
}
}

impl<'a> ser::SerializeSeq for &'a mut Serializer {
impl ser::SerializeSeq for &mut Serializer {
// Must match the `Ok` type of the serializer.
type Ok = ();
// Must match the `Error` type of the serializer.
Expand All @@ -246,7 +246,7 @@ impl<'a> ser::SerializeSeq for &'a mut Serializer {
}
}

impl<'a> ser::SerializeTuple for &'a mut Serializer {
impl ser::SerializeTuple for &mut Serializer {
type Ok = ();
type Error = SerializerError;

Expand All @@ -263,7 +263,7 @@ impl<'a> ser::SerializeTuple for &'a mut Serializer {
}

// Same thing but for tuple structs.
impl<'a> ser::SerializeTupleStruct for &'a mut Serializer {
impl ser::SerializeTupleStruct for &mut Serializer {
type Ok = ();
type Error = SerializerError;

Expand All @@ -288,7 +288,7 @@ impl<'a> ser::SerializeTupleStruct for &'a mut Serializer {
//
// So the `end` method in this impl is responsible for closing both the `]` and
// the `}`.
impl<'a> ser::SerializeTupleVariant for &'a mut Serializer {
impl ser::SerializeTupleVariant for &mut Serializer {
type Ok = ();
type Error = SerializerError;

Expand All @@ -312,7 +312,7 @@ impl<'a> ser::SerializeTupleVariant for &'a mut Serializer {
// `serialize_entry` method allows serializers to optimize for the case where
// key and value are both available simultaneously. In JSON it doesn't make a
// difference so the default behavior for `serialize_entry` is fine.
impl<'a> ser::SerializeMap for &'a mut Serializer {
impl ser::SerializeMap for &mut Serializer {
type Ok = ();
type Error = SerializerError;

Expand Down Expand Up @@ -348,7 +348,7 @@ impl<'a> ser::SerializeMap for &'a mut Serializer {

// Structs are like maps in which the keys are constrained to be compile-time
// constant strings.
impl<'a> ser::SerializeStruct for &'a mut Serializer {
impl ser::SerializeStruct for &mut Serializer {
type Ok = ();
type Error = SerializerError;

Expand All @@ -371,7 +371,7 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer {

// Similar to `SerializeTupleVariant`, here the `end` method is responsible for
// closing both of the curly braces opened by `serialize_struct_variant`.
impl<'a> ser::SerializeStructVariant for &'a mut Serializer {
impl ser::SerializeStructVariant for &mut Serializer {
type Ok = ();
type Error = SerializerError;

Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/config/c_known_packs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl<'a> CKnownPacks<'a> {
}
}

impl<'a> ClientPacket for CKnownPacks<'a> {
impl ClientPacket for CKnownPacks<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_list::<KnownPack>(self.known_packs, |p, v| {
p.put_string(v.namespace);
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/config/c_registry_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct RegistryEntry<'a> {
pub data: BytesMut,
}

impl<'a> ClientPacket for CRegistryData<'a> {
impl ClientPacket for CRegistryData<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_string(self.registry_id);
bytebuf.put_list::<RegistryEntry>(self.entries, |p, v| {
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/config/c_server_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum Label<'a> {
TextComponent(TextComponent<'a>),
}

impl<'a> Serialize for Label<'a> {
impl Serialize for Label<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/login/c_login_success.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<'a> CLoginSuccess<'a> {
}
}

impl<'a> ClientPacket for CLoginSuccess<'a> {
impl ClientPacket for CLoginSuccess<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_uuid(self.uuid);
bytebuf.put_string(self.username);
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_boss_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<'a> CBossEvent<'a> {
}
}

impl<'a> ClientPacket for CBossEvent<'a> {
impl ClientPacket for CBossEvent<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_uuid(&self.uuid);
let action = &self.action;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_chunk_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pumpkin_world::{chunk::ChunkData, DIRECT_PALETTE_BITS};
#[client_packet("play:level_chunk_with_light")]
pub struct CChunkData<'a>(pub &'a ChunkData);

impl<'a> ClientPacket for CChunkData<'a> {
impl ClientPacket for CChunkData<'_> {
fn write(&self, buf: &mut crate::bytebuf::ByteBuffer) {
// Chunk X
buf.put_i32(self.0.position.x);
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_command_suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'a> CCommandSuggestions<'a> {
}
}

impl<'a> ClientPacket for CCommandSuggestions<'a> {
impl ClientPacket for CCommandSuggestions<'_> {
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) {
bytebuf.put_var_int(&self.id);
bytebuf.put_var_int(&self.start);
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a> CCommands<'a> {
}
}

impl<'a> ClientPacket for CCommands<'a> {
impl ClientPacket for CCommands<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_list(&self.nodes, |bytebuf, node: &ProtoNode| {
node.write_to(bytebuf)
Expand Down Expand Up @@ -46,7 +46,7 @@ pub enum ProtoNodeType<'a> {
},
}

impl<'a> ProtoNode<'a> {
impl ProtoNode<'_> {
const FLAG_IS_EXECUTABLE: u8 = 4;
const FLAG_HAS_REDIRECT: u8 = 8;
const FLAG_HAS_SUGGESTION_TYPE: u8 = 16;
Expand Down Expand Up @@ -181,7 +181,7 @@ pub enum ProtoCmdArgParser<'a> {
Uuid,
}

impl<'a> ProtoCmdArgParser<'a> {
impl ProtoCmdArgParser<'_> {
pub const ENTITY_FLAG_ONLY_SINGLE: u8 = 1;
pub const ENTITY_FLAG_PLAYERS_ONLY: u8 = 2;

Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_player_info_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<'a> CPlayerInfoUpdate<'a> {
}
}

impl<'a> ClientPacket for CPlayerInfoUpdate<'a> {
impl ClientPacket for CPlayerInfoUpdate<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_i8(self.actions);
bytebuf.put_list::<Player>(self.players, |p, v| {
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_server_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum Label<'a> {
TextComponent(TextComponent<'a>),
}

impl<'a> Serialize for Label<'a> {
impl Serialize for Label<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_sync_player_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a> CSyncPlayerPosition<'a> {
}
}

impl<'a> ClientPacket for CSyncPlayerPosition<'a> {
impl ClientPacket for CSyncPlayerPosition<'_> {
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) {
bytebuf.put_var_int(&self.teleport_id);
bytebuf.put_f64(self.x);
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_update_objectives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<'a> CUpdateObjectives<'a> {
}
}

impl<'a> ClientPacket for CUpdateObjectives<'a> {
impl ClientPacket for CUpdateObjectives<'_> {
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) {
bytebuf.put_string(self.objective_name);
bytebuf.put_u8(self.mode);
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-registry/src/recipe/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub mod ingredients {
}

struct IngredientTypeVisitor;
impl<'de> Visitor<'de> for IngredientTypeVisitor {
impl Visitor<'_> for IngredientTypeVisitor {
type Value = IngredientType;
fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
write!(formatter, "valid item type")
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-registry/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'de> Deserialize<'de> for TagType {
D: Deserializer<'de>,
{
struct TagVisitor;
impl<'de> Visitor<'de> for TagVisitor {
impl Visitor<'_> for TagVisitor {
type Value = TagType;
fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
write!(formatter, "valid tag")
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-world/src/chunk/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl ChunkReader for AnvilChunkReader {
let header = file_buf.drain(0..5).collect_vec();

let compression = Compression::from_byte(header[4])
.ok_or_else(|| ChunkReadingError::Compression(CompressionError::UnknownCompression))?;
.ok_or(ChunkReadingError::Compression(CompressionError::UnknownCompression))?;

let size = u32::from_be_bytes(header[..4].try_into().unwrap());

Expand Down
10 changes: 5 additions & 5 deletions pumpkin-world/src/world_gen/chunk_noise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<'a> ChunkNoiseWrappedFunctionConverter<'a> {
}
}

impl<'a> ConverterImpl<ChunkNoiseState> for ChunkNoiseWrappedFunctionConverter<'a> {
impl ConverterImpl<ChunkNoiseState> for ChunkNoiseWrappedFunctionConverter<'_> {
fn convert_noise(&mut self, _noise: &Arc<InternalNoise>) -> Option<Arc<InternalNoise>> {
None
}
Expand Down Expand Up @@ -711,7 +711,7 @@ impl<'a> ChunkNoiseInterpolationApplier<'a> {
}
}

impl<'a> EnvironmentApplierImpl for ChunkNoiseInterpolationApplier<'a> {
impl EnvironmentApplierImpl for ChunkNoiseInterpolationApplier<'_> {
type Env = ChunkNoiseState;

fn fill_mut(
Expand Down Expand Up @@ -742,7 +742,7 @@ impl<'a> EnvironmentApplierImpl for ChunkNoiseInterpolationApplier<'a> {
}
}

impl<'a> ApplierImpl for ChunkNoiseInterpolationApplier<'a> {
impl ApplierImpl for ChunkNoiseInterpolationApplier<'_> {
fn at(&mut self, index: usize) -> NoisePos {
self.shared.start_block_pos.y = (index as i32 + self.shared.minimum_cell_y as i32)
* self.shared.vertical_cell_block_count as i32;
Expand Down Expand Up @@ -778,7 +778,7 @@ impl<'a> ChunkNoiseApplier<'a> {
}
}

impl<'a> EnvironmentApplierImpl for ChunkNoiseApplier<'a> {
impl EnvironmentApplierImpl for ChunkNoiseApplier<'_> {
type Env = ChunkNoiseState;

fn fill_mut(
Expand Down Expand Up @@ -813,7 +813,7 @@ impl<'a> EnvironmentApplierImpl for ChunkNoiseApplier<'a> {
}
}

impl<'a> ApplierImpl for ChunkNoiseApplier<'a> {
impl ApplierImpl for ChunkNoiseApplier<'_> {
fn at(&mut self, index: usize) -> NoisePos {
let cell_block_z = index % self.shared.horizontal_cell_block_count as usize;
let xy_chunk = index / self.shared.horizontal_cell_block_count as usize;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/args/arg_bounded_num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ where
}
}

impl<'a, T: ToFromNumber> FindArg<'a> for BoundedNumArgumentConsumer<T> {
impl<T: ToFromNumber> FindArg<'_> for BoundedNumArgumentConsumer<T> {
type Data = Result<T, NotInBounds>;

fn find_arg(args: &super::ConsumedArgs, name: &str) -> Result<Self::Data, CommandError> {
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum CommandSender<'a> {
Player(Arc<Player>),
}

impl<'a> fmt::Display for CommandSender<'a> {
impl fmt::Display for CommandSender<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct TraverseAllPathsIter<'a> {
todo: VecDeque<(usize, usize)>,
}

impl<'a> Iterator for TraverseAllPathsIter<'a> {
impl Iterator for TraverseAllPathsIter<'_> {
type Item = Vec<usize>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
6 changes: 3 additions & 3 deletions pumpkin/src/command/tree_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait IsVisible {
fn is_visible(&self) -> bool;
}

impl<'a> IsVisible for Node<'a> {
impl IsVisible for Node<'_> {
fn is_visible(&self) -> bool {
matches!(
self.node_type,
Expand All @@ -16,7 +16,7 @@ impl<'a> IsVisible for Node<'a> {
}
}

impl<'a> Display for Node<'a> {
impl Display for Node<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self.node_type {
NodeType::Literal { string } => {
Expand Down Expand Up @@ -50,7 +50,7 @@ fn flatten_require_nodes(nodes: &[Node], children: &[usize]) -> Vec<usize> {
new_children
}

impl<'a> Display for CommandTree<'a> {
impl Display for CommandTree<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_char('/')?;
f.write_str(self.names[0])?;
Expand Down
1 change: 0 additions & 1 deletion pumpkin/src/proxy/velocity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::client::{authentication::GameProfile, Client};
/// Proxy implementation for Velocity <https://papermc.io/software/velocity> by `PaperMC`
/// Sadly `PaperMC` does not care about 3th Parties providing support for Velocity, There is no documentation.
/// I had to understand the Code logic by looking at `PaperMC`'s Velocity implementation: <https://github.com/PaperMC/Paper/blob/master/patches/server/0731-Add-Velocity-IP-Forwarding-Support.patch>
type HmacSha256 = Hmac<Sha256>;

const MAX_SUPPORTED_FORWARDING_VERSION: u8 = 4;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/server/key_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl KeyStore {
server_id: &'a str,
verification_token: &'a [u8; 4],
should_authenticate: bool,
) -> CEncryptionRequest<'_> {
) -> CEncryptionRequest<'a> {
CEncryptionRequest::new(
server_id,
&self.public_key_der,
Expand Down
6 changes: 3 additions & 3 deletions pumpkin/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Server {
}

/// Adds a new player to the server.
///
/// This function takes an `Arc<Client>` representing the connected client and performs the following actions:
///
/// 1. Generates a new entity ID for the player.
Expand All @@ -125,7 +125,7 @@ impl Server {
/// # Arguments
///
/// * `client`: An `Arc<Client>` representing the connected client.
///
/// # Returns
///
/// A tuple containing:
Expand Down Expand Up @@ -301,7 +301,7 @@ impl Server {
&'a self,
verification_token: &'a [u8; 4],
should_authenticate: bool,
) -> CEncryptionRequest<'_> {
) -> CEncryptionRequest<'a> {
self.key_store
.encryption_request("", verification_token, should_authenticate)
}
Expand Down

0 comments on commit 30aca6b

Please sign in to comment.