From 7aade9d289417b4a4aad3a9b90c87ed2cf157302 Mon Sep 17 00:00:00 2001 From: Cesar <142530682+cr-fuel@users.noreply.github.com> Date: Wed, 6 Sep 2023 06:59:38 -0400 Subject: [PATCH] Fix clippy warnings (#5093) ## Description This is a minor PR to fix all the clippy warnings ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --- sway-lsp/src/capabilities/hover/mod.rs | 2 +- sway-lsp/src/core/token.rs | 2 +- sway-lsp/src/core/token_map.rs | 5 +++-- sway-lsp/src/traverse/typed_tree.rs | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sway-lsp/src/capabilities/hover/mod.rs b/sway-lsp/src/capabilities/hover/mod.rs index e70de60f59d..a7fa0e61f13 100644 --- a/sway-lsp/src/capabilities/hover/mod.rs +++ b/sway-lsp/src/capabilities/hover/mod.rs @@ -59,7 +59,7 @@ pub fn hover_data( } // The `TypeInfo` of the token does not contain an `Ident`. In this case, // we use the `Ident` of the token itself. - None => (ident.clone(), token), + None => (ident, token), }; let contents = hover_format(session.clone(), &engines, &decl_token, &decl_ident.name); diff --git a/sway-lsp/src/core/token.rs b/sway-lsp/src/core/token.rs index e337b125a97..ff4589aa15a 100644 --- a/sway-lsp/src/core/token.rs +++ b/sway-lsp/src/core/token.rs @@ -196,7 +196,7 @@ impl TokenIdent { .source_id() .map(|source_id| se.get_path(source_id)); Self { - name: ident.span().clone().str(), + name: ident.span().str(), range: get_range_from_span(&ident.span()), path, is_raw_ident: ident.is_raw_ident(), diff --git a/sway-lsp/src/core/token_map.rs b/sway-lsp/src/core/token_map.rs index fb075c132d3..78ebcf47f80 100644 --- a/sway-lsp/src/core/token_map.rs +++ b/sway-lsp/src/core/token_map.rs @@ -114,11 +114,12 @@ impl TokenMap { Some(TypedAstToken::TypedFunctionDeclaration(decl)) if functions_only == Some(true) => { - TokenIdent::new(&Ident::new(decl.span.clone()), source_engine) + TokenIdent::new(&Ident::new(decl.span), source_engine) } Some(TypedAstToken::TypedDeclaration(decl)) => { - TokenIdent::new(&Ident::new(decl.span().clone()), source_engine) + TokenIdent::new(&Ident::new(decl.span()), source_engine) } + #[allow(clippy::redundant_clone)] _ => ident.clone(), }; if position >= token_ident.range.start && position <= token_ident.range.end { diff --git a/sway-lsp/src/traverse/typed_tree.rs b/sway-lsp/src/traverse/typed_tree.rs index e4fe0d11746..799c72dd8b5 100644 --- a/sway-lsp/src/traverse/typed_tree.rs +++ b/sway-lsp/src/traverse/typed_tree.rs @@ -1210,7 +1210,7 @@ fn collect_type_id( let decl = ctx.engines.de().get_enum(decl_ref); if let Some(token) = ctx .tokens - .try_get_mut(&ctx.ident(&Ident::new(type_span.clone()))) + .try_get_mut(&ctx.ident(&Ident::new(type_span))) .try_unwrap() { assign_type_to_token(token, symbol_kind, typed_token.clone(), type_id); @@ -1231,7 +1231,7 @@ fn collect_type_id( let decl = ctx.engines.de().get_struct(decl_ref); if let Some(token) = ctx .tokens - .try_get_mut(&ctx.ident(&Ident::new(type_span.clone()))) + .try_get_mut(&ctx.ident(&Ident::new(type_span))) .try_unwrap() { assign_type_to_token(token, symbol_kind, typed_token.clone(), type_id); @@ -1254,7 +1254,7 @@ fn collect_type_id( } => { if let Some(token) = ctx .tokens - .try_get_mut(&ctx.ident(&Ident::new(name.span().clone()))) + .try_get_mut(&ctx.ident(&Ident::new(name.span()))) .try_unwrap() { assign_type_to_token(token, symbol_kind, typed_token.clone(), type_id); @@ -1273,7 +1273,7 @@ fn collect_type_id( _ => { if let Some(token) = ctx .tokens - .try_get_mut(&ctx.ident(&Ident::new(type_span.clone()))) + .try_get_mut(&ctx.ident(&Ident::new(type_span))) .try_unwrap() { assign_type_to_token(token, symbol_kind, typed_token.clone(), type_id);