Skip to content

Commit

Permalink
cargo clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefanuk12 committed Dec 20, 2024
1 parent 9e9db7f commit 9acdb20
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/frontend/work_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct WorkCache<'a> {
input_to_output: HashMap<PathBuf, PathBuf>,
}

impl<'a> Clone for WorkCache<'a> {
impl Clone for WorkCache<'_> {
fn clone(&self) -> Self {
Self {
resources: self.resources,
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/generator/token_based.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 8 additions & 8 deletions src/process/expression_serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/process/processors/find_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/process/processors/find_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ 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 {
&self.identifier_tracker
}
}

impl<'a> ops::DerefMut for FindUsage<'a> {
impl ops::DerefMut for FindUsage<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.identifier_tracker
}
Expand All @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions src/rules/bundle/path_require_mode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: RequirePathLocatorMode> Deref
for RequirePathProcessor<'_, '_, '_, '_, T>
{
type Target = IdentifierTracker;

Expand All @@ -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<T: RequirePathLocatorMode> DerefMut
for RequirePathProcessor<'_, '_, '_, '_, T>
{
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.identifier_tracker
Expand Down Expand Up @@ -311,8 +311,8 @@ where
expression
}

impl<'a, 'b, 'resources, 'code, T: RequirePathLocatorMode> NodeProcessor
for RequirePathProcessor<'a, 'b, 'resources, 'code, T>
impl<T: RequirePathLocatorMode> NodeProcessor
for RequirePathProcessor<'_, '_, '_, '_, T>
{
fn process_expression(&mut self, expression: &mut Expression) {
if let Expression::Call(call) = expression {
Expand Down
6 changes: 3 additions & 3 deletions src/rules/convert_require/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ 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 {
&self.identifier_tracker
}
}

impl<'a> DerefMut for RequireConverter<'a> {
impl DerefMut for RequireConverter<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.identifier_tracker
}
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions src/rules/convert_require/roblox_require_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)?
Expand All @@ -312,16 +312,16 @@ fn parse_roblox_expression(
}

fn parse_roblox_field(
field: &Box<FieldExpression>,
field: &FieldExpression,
path_builder: &mut VecDeque<String>,
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<IndexExpression>,
index: &IndexExpression,
path_builder: &mut VecDeque<String>,
current_path: &mut PathBuf,
) -> DarkluaResult<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub struct Context<'a, 'resources, 'code> {
project_location: Option<PathBuf>,
}

impl<'a, 'resources, 'code> Context<'a, 'resources, 'code> {
impl Context<'_, '_, '_> {
pub fn block(&self, path: impl AsRef<Path>) -> Option<&Block> {
self.blocks.get(path.as_ref()).copied()
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/remove_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/replace_referenced_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
15 changes: 6 additions & 9 deletions src/rules/require/hybrid_require_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&current_path);
*current_path = temp_path;
Expand All @@ -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(
Expand All @@ -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)?
Expand All @@ -166,12 +163,12 @@ fn parse_roblox_expression(
}

fn parse_roblox_field(
field: &Box<FieldExpression>,
field: &FieldExpression,
path_builder: &mut VecDeque<String>,
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(
Expand Down
2 changes: 1 addition & 1 deletion src/rules/require/path_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/require/path_require_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl PathRequireMode {
) -> Result<Option<crate::nodes::Arguments>, crate::DarkluaError> {
let mut current_path = context.current_path().to_path_buf();
current_path.pop();
let diff = pathdiff::diff_paths(&path, &current_path).ok_or(
let diff = pathdiff::diff_paths(path, &current_path).ok_or(
DarkluaError::custom("invalid path difference").context("path require mode cannot"),
)?;

Expand Down

0 comments on commit 9acdb20

Please sign in to comment.