diff --git a/src/frontend/work_cache.rs b/src/frontend/work_cache.rs index ecbb5027..6e8fbc1e 100644 --- a/src/frontend/work_cache.rs +++ b/src/frontend/work_cache.rs @@ -16,7 +16,7 @@ pub struct WorkCache<'a> { input_to_output: HashMap, } -impl<'a> Clone for WorkCache<'a> { +impl Clone for WorkCache<'_> { fn clone(&self) -> Self { Self { resources: self.resources, @@ -26,7 +26,7 @@ impl<'a> Clone for WorkCache<'a> { } } -impl<'a> fmt::Debug for WorkCache<'a> { +impl fmt::Debug for WorkCache<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("WorkCache") .field("resources", &self.resources) diff --git a/src/generator/token_based.rs b/src/generator/token_based.rs index 3d6b86d2..76d2fcf5 100644 --- a/src/generator/token_based.rs +++ b/src/generator/token_based.rs @@ -1688,7 +1688,7 @@ fn comma_token() -> Token { Token::from_content(",").with_trailing_trivia(TriviaKind::Whitespace.with_content(" ")) } -impl<'a> LuaGenerator for TokenBasedLuaGenerator<'a> { +impl LuaGenerator for TokenBasedLuaGenerator<'_> { fn into_string(self) -> String { self.output } diff --git a/src/process/expression_serializer.rs b/src/process/expression_serializer.rs index 571703ce..4bfd2483 100644 --- a/src/process/expression_serializer.rs +++ b/src/process/expression_serializer.rs @@ -181,7 +181,7 @@ impl Serializer { } } -impl<'a> ser::Serializer for &'a mut Serializer { +impl ser::Serializer for &mut Serializer { // The output type produced by this `Serializer` during successful // serialization. Most serializers that produce text or binary output should // set `Ok = ()` and serialize into an `io::Write` or buffer contained @@ -425,7 +425,7 @@ impl<'a> ser::Serializer for &'a mut Serializer { // // This impl is SerializeSeq so these methods are called after `serialize_seq` // is called on the 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. @@ -446,7 +446,7 @@ impl<'a> ser::SerializeSeq for &'a mut Serializer { } // Same thing but for tuples. -impl<'a> ser::SerializeTuple for &'a mut Serializer { +impl ser::SerializeTuple for &mut Serializer { type Ok = (); type Error = LuaSerializerError; @@ -463,7 +463,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 = LuaSerializerError; @@ -483,7 +483,7 @@ impl<'a> ser::SerializeTupleStruct for &'a mut Serializer { // `serialize_tuple_variant` method above. The `end` method // in this impl is responsible for closing both the outer and // inner tables. -impl<'a> ser::SerializeTupleVariant for &'a mut Serializer { +impl ser::SerializeTupleVariant for &mut Serializer { type Ok = (); type Error = LuaSerializerError; @@ -507,7 +507,7 @@ impl<'a> ser::SerializeTupleVariant for &'a mut Serializer { // There is a third optional method on the `SerializeMap` trait. The // `serialize_entry` method allows serializers to optimize for the case where // key and value are both available simultaneously. -impl<'a> ser::SerializeMap for &'a mut Serializer { +impl ser::SerializeMap for &mut Serializer { type Ok = (); type Error = LuaSerializerError; @@ -535,7 +535,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 = LuaSerializerError; @@ -556,7 +556,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 = LuaSerializerError; diff --git a/src/process/processors/find_identifier.rs b/src/process/processors/find_identifier.rs index 6b72e4c1..264074a2 100644 --- a/src/process/processors/find_identifier.rs +++ b/src/process/processors/find_identifier.rs @@ -60,7 +60,7 @@ impl<'a> FromIterator<&'a str> for FindVariables<'a> { } } -impl<'a> NodeProcessor for FindVariables<'a> { +impl NodeProcessor for FindVariables<'_> { fn process_variable_expression(&mut self, variable: &mut Identifier) { if !self.usage_found { let name = variable.get_name(); diff --git a/src/process/processors/find_usage.rs b/src/process/processors/find_usage.rs index fbf0cbce..810c0675 100644 --- a/src/process/processors/find_usage.rs +++ b/src/process/processors/find_usage.rs @@ -12,7 +12,7 @@ pub(crate) struct FindUsage<'a> { identifier_tracker: IdentifierTracker, } -impl<'a> ops::Deref for FindUsage<'a> { +impl ops::Deref for FindUsage<'_> { type Target = IdentifierTracker; fn deref(&self) -> &Self::Target { @@ -20,7 +20,7 @@ impl<'a> ops::Deref for FindUsage<'a> { } } -impl<'a> ops::DerefMut for FindUsage<'a> { +impl ops::DerefMut for FindUsage<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.identifier_tracker } @@ -47,7 +47,7 @@ impl<'a> FindUsage<'a> { } } -impl<'a> NodeProcessor for FindUsage<'a> { +impl NodeProcessor for FindUsage<'_> { fn process_variable_expression(&mut self, variable: &mut Identifier) { self.verify_identifier(variable); } diff --git a/src/rules/bundle/path_require_mode/mod.rs b/src/rules/bundle/path_require_mode/mod.rs index 0c3fdad7..a631e960 100644 --- a/src/rules/bundle/path_require_mode/mod.rs +++ b/src/rules/bundle/path_require_mode/mod.rs @@ -268,8 +268,8 @@ impl<'a, 'b, 'code, 'resources, T: RequirePathLocatorMode> } } -impl<'a, 'b, 'resources, 'code, T: RequirePathLocatorMode> Deref - for RequirePathProcessor<'a, 'b, 'resources, 'code, T> +impl Deref + for RequirePathProcessor<'_, '_, '_, '_, T> { type Target = IdentifierTracker; @@ -278,8 +278,8 @@ impl<'a, 'b, 'resources, 'code, T: RequirePathLocatorMode> Deref } } -impl<'a, 'b, 'resources, 'code, T: RequirePathLocatorMode> DerefMut - for RequirePathProcessor<'a, 'b, 'resources, 'code, T> +impl DerefMut + for RequirePathProcessor<'_, '_, '_, '_, T> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.identifier_tracker @@ -311,8 +311,8 @@ where expression } -impl<'a, 'b, 'resources, 'code, T: RequirePathLocatorMode> NodeProcessor - for RequirePathProcessor<'a, 'b, 'resources, 'code, T> +impl NodeProcessor + for RequirePathProcessor<'_, '_, '_, '_, T> { fn process_expression(&mut self, expression: &mut Expression) { if let Expression::Call(call) = expression { diff --git a/src/rules/convert_require/mod.rs b/src/rules/convert_require/mod.rs index 89d10858..bf30fe91 100644 --- a/src/rules/convert_require/mod.rs +++ b/src/rules/convert_require/mod.rs @@ -92,7 +92,7 @@ struct RequireConverter<'a> { context: &'a Context<'a, 'a, 'a>, } -impl<'a> Deref for RequireConverter<'a> { +impl Deref for RequireConverter<'_> { type Target = IdentifierTracker; fn deref(&self) -> &Self::Target { @@ -100,7 +100,7 @@ impl<'a> Deref for RequireConverter<'a> { } } -impl<'a> DerefMut for RequireConverter<'a> { +impl DerefMut for RequireConverter<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.identifier_tracker } @@ -131,7 +131,7 @@ impl<'a> RequireConverter<'a> { } } -impl<'a> NodeProcessor for RequireConverter<'a> { +impl NodeProcessor for RequireConverter<'_> { fn process_function_call(&mut self, call: &mut FunctionCall) { if is_require_call(call, self) { match self.try_require_conversion(call) { diff --git a/src/rules/convert_require/roblox_require_mode.rs b/src/rules/convert_require/roblox_require_mode.rs index d47e62be..25435f66 100644 --- a/src/rules/convert_require/roblox_require_mode.rs +++ b/src/rules/convert_require/roblox_require_mode.rs @@ -276,10 +276,10 @@ fn parse_roblox_prefix( current_path: &mut PathBuf, ) -> DarkluaResult<()> { match prefix { - Prefix::Field(x) => parse_roblox_field(&x, path_builder, current_path)?, - Prefix::Index(x) => parse_roblox_index(&x, path_builder, current_path)?, + Prefix::Field(x) => parse_roblox_field(x, path_builder, current_path)?, + Prefix::Index(x) => parse_roblox_index(x, path_builder, current_path)?, Prefix::Identifier(x) => { - handle_roblox_script_parent(&x.get_name(), path_builder, current_path)? + handle_roblox_script_parent(x.get_name(), path_builder, current_path)? } _ => Err( DarkluaError::custom("unexpected prefix, only constants accepted") @@ -298,7 +298,7 @@ fn parse_roblox_expression( Expression::Field(x) => parse_roblox_field(x, path_builder, current_path)?, Expression::Index(x) => parse_roblox_index(x, path_builder, current_path)?, Expression::Identifier(x) => { - handle_roblox_script_parent(&x.get_name(), path_builder, current_path)? + handle_roblox_script_parent(x.get_name(), path_builder, current_path)? } Expression::String(x) => { handle_roblox_script_parent(x.get_value(), path_builder, current_path)? @@ -312,16 +312,16 @@ fn parse_roblox_expression( } fn parse_roblox_field( - field: &Box, + field: &FieldExpression, path_builder: &mut VecDeque, current_path: &mut PathBuf, ) -> DarkluaResult<()> { - handle_roblox_script_parent(&field.get_field().get_name(), path_builder, current_path)?; + handle_roblox_script_parent(field.get_field().get_name(), path_builder, current_path)?; parse_roblox_prefix(field.get_prefix(), path_builder, current_path) } fn parse_roblox_index( - index: &Box, + index: &IndexExpression, path_builder: &mut VecDeque, current_path: &mut PathBuf, ) -> DarkluaResult<()> { diff --git a/src/rules/mod.rs b/src/rules/mod.rs index 5f38013b..7f0ac808 100644 --- a/src/rules/mod.rs +++ b/src/rules/mod.rs @@ -130,7 +130,7 @@ pub struct Context<'a, 'resources, 'code> { project_location: Option, } -impl<'a, 'resources, 'code> Context<'a, 'resources, 'code> { +impl Context<'_, '_, '_> { pub fn block(&self, path: impl AsRef) -> Option<&Block> { self.blocks.get(path.as_ref()).copied() } diff --git a/src/rules/remove_comments.rs b/src/rules/remove_comments.rs index eda1ceda..54dfa2de 100644 --- a/src/rules/remove_comments.rs +++ b/src/rules/remove_comments.rs @@ -250,7 +250,7 @@ impl<'a> FilterCommentProcessor<'a> { } } -impl<'a> NodeProcessor for FilterCommentProcessor<'a> { +impl NodeProcessor for FilterCommentProcessor<'_> { fn process_block(&mut self, block: &mut Block) { block.filter_comments(|trivia| self.ignore_trivia(trivia)); } diff --git a/src/rules/replace_referenced_tokens.rs b/src/rules/replace_referenced_tokens.rs index 30493c99..7cc316e4 100644 --- a/src/rules/replace_referenced_tokens.rs +++ b/src/rules/replace_referenced_tokens.rs @@ -17,7 +17,7 @@ impl<'a> Processor<'a> { } } -impl<'a> NodeProcessor for Processor<'a> { +impl NodeProcessor for Processor<'_> { fn process_block(&mut self, block: &mut Block) { block.replace_referenced_tokens(self.code); } diff --git a/src/rules/require/hybrid_require_mode.rs b/src/rules/require/hybrid_require_mode.rs index 54ad29d8..1793155d 100644 --- a/src/rules/require/hybrid_require_mode.rs +++ b/src/rules/require/hybrid_require_mode.rs @@ -113,10 +113,7 @@ fn parse_roblox_call(call: &FunctionCall, current_path: &mut PathBuf) -> Darklua .context("while parsing roblox-ts require"), )?; }; - args.iter_values().for_each(|arg| match arg { - Expression::String(x) => temp_path.push(x.get_value().to_string()), - _ => {} - }); + args.iter_values().for_each(|arg| if let Expression::String(x) = arg { temp_path.push(x.get_value()) }); let _ = temp_path.join(¤t_path); *current_path = temp_path; @@ -130,9 +127,9 @@ fn parse_roblox_prefix( current_path: &mut PathBuf, ) -> DarkluaResult<()> { match prefix { - Prefix::Field(x) => parse_roblox_field(&x, path_builder, current_path)?, + Prefix::Field(x) => parse_roblox_field(x, path_builder, current_path)?, Prefix::Identifier(x) => { - handle_roblox_script_parent(&x.get_name(), path_builder, current_path)? + handle_roblox_script_parent(x.get_name(), path_builder, current_path)? } Prefix::Call(x) => parse_roblox_call(x, current_path)?, _ => Err( @@ -151,7 +148,7 @@ fn parse_roblox_expression( match expression { Expression::Field(x) => parse_roblox_field(x, path_builder, current_path)?, Expression::Identifier(x) => { - handle_roblox_script_parent(&x.get_name(), path_builder, current_path)? + handle_roblox_script_parent(x.get_name(), path_builder, current_path)? } Expression::String(x) => { handle_roblox_script_parent(x.get_value(), path_builder, current_path)? @@ -166,12 +163,12 @@ fn parse_roblox_expression( } fn parse_roblox_field( - field: &Box, + field: &FieldExpression, path_builder: &mut VecDeque, current_path: &mut PathBuf, ) -> DarkluaResult<()> { parse_roblox_prefix(field.get_prefix(), path_builder, current_path)?; - handle_roblox_script_parent(&field.get_field().get_name(), path_builder, current_path) + handle_roblox_script_parent(field.get_field().get_name(), path_builder, current_path) } fn handle_roblox_script_parent( diff --git a/src/rules/require/path_iterator.rs b/src/rules/require/path_iterator.rs index 5837a120..e8a0d444 100644 --- a/src/rules/require/path_iterator.rs +++ b/src/rules/require/path_iterator.rs @@ -34,7 +34,7 @@ impl<'a, 'b> PathIterator<'a, 'b> { } } -impl<'a, 'b> Iterator for PathIterator<'a, 'b> { +impl Iterator for PathIterator<'_, '_> { type Item = PathBuf; fn next(&mut self) -> Option { diff --git a/src/rules/require/path_require_mode.rs b/src/rules/require/path_require_mode.rs index 06324762..9f74c92d 100644 --- a/src/rules/require/path_require_mode.rs +++ b/src/rules/require/path_require_mode.rs @@ -82,7 +82,7 @@ impl PathRequireMode { ) -> Result, crate::DarkluaError> { let mut current_path = context.current_path().to_path_buf(); current_path.pop(); - let diff = pathdiff::diff_paths(&path, ¤t_path).ok_or( + let diff = pathdiff::diff_paths(path, ¤t_path).ok_or( DarkluaError::custom("invalid path difference").context("path require mode cannot"), )?;