From b50cb5c2615768380b1d7b2f7923e2d944dc472f Mon Sep 17 00:00:00 2001 From: k-nasa Date: Sun, 10 Oct 2021 10:50:51 +0900 Subject: [PATCH] Remove neesless clone --- crates/hir_def/src/generics.rs | 2 +- crates/ide/src/doc_links.rs | 2 +- crates/ide/src/goto_definition.rs | 4 ++-- crates/ide_assists/src/handlers/extract_function.rs | 2 +- crates/ide_completion/src/render/enum_variant.rs | 2 +- crates/ide_diagnostics/src/handlers/missing_fields.rs | 2 +- crates/rust-analyzer/src/cli/lsif.rs | 4 ++-- crates/syntax/src/ast/expr_ext.rs | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs index 8622357cd4..98eafa9000 100644 --- a/crates/hir_def/src/generics.rs +++ b/crates/hir_def/src/generics.rs @@ -392,7 +392,7 @@ impl HasChildSource for GenericDefId { // For traits the first type index is `Self`, we need to add it before the other params. if let GenericDefId::TraitId(id) = *self { - let trait_ref = id.lookup(db).source(db).value.clone(); + let trait_ref = id.lookup(db).source(db).value; let idx = idx_iter.next().unwrap(); params.insert(idx, Either::Right(trait_ref)) } diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index adaaece719..9a879715e7 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs @@ -254,7 +254,7 @@ impl DocCommentToken { let original_start = doc_token.text_range().start(); let relative_comment_offset = offset - original_start - prefix_len; - sema.descend_into_macros_many(doc_token.clone()).into_iter().find_map(|t| { + sema.descend_into_macros_many(doc_token).into_iter().find_map(|t| { let (node, descended_prefix_len) = match_ast! { match t { ast::Comment(comment) => (t.parent()?, TextSize::try_from(comment.prefix().len()).ok()?), diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index 911998d69b..718c31f9bc 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs @@ -47,7 +47,7 @@ pub(crate) fn goto_definition( .into_iter() .filter_map(|token| { let parent = token.parent()?; - if let Some(tt) = ast::TokenTree::cast(parent.clone()) { + if let Some(tt) = ast::TokenTree::cast(parent) { if let x @ Some(_) = try_lookup_include_path(&sema, tt, token.clone(), position.file_id) { @@ -77,7 +77,7 @@ fn try_lookup_include_path( token: SyntaxToken, file_id: FileId, ) -> Option> { - let token = ast::String::cast(token.clone())?; + let token = ast::String::cast(token)?; let path = token.value()?.into_owned(); let macro_call = tt.syntax().parent().and_then(ast::MacroCall::cast)?; let name = macro_call.path()?.segment()?.name_ref()?; diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index a367d97afe..401fb78f98 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs @@ -169,7 +169,7 @@ fn extraction_target(node: &SyntaxNode, selection_range: TextRange) -> Option EnumRender<'a> { } None => ( hir::ModPath::from_segments(hir::PathKind::Plain, iter::once(name.clone())), - hir::ModPath::from_segments(hir::PathKind::Plain, iter::once(name.clone())), + hir::ModPath::from_segments(hir::PathKind::Plain, iter::once(name)), ), }; diff --git a/crates/ide_diagnostics/src/handlers/missing_fields.rs b/crates/ide_diagnostics/src/handlers/missing_fields.rs index 03656ad925..d5b8471515 100644 --- a/crates/ide_diagnostics/src/handlers/missing_fields.rs +++ b/crates/ide_diagnostics/src/handlers/missing_fields.rs @@ -58,7 +58,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option { let doc_id = self.get_file_id(file_id); let line_index = self.db.line_index(file_id); let line_index = LineIndex { - index: line_index.clone(), + index: line_index, encoding: OffsetEncoding::Utf16, endings: LineEndings::Unix, }; @@ -191,7 +191,7 @@ impl LsifManager<'_> { let text = self.analysis.file_text(file_id).unwrap(); let line_index = self.db.line_index(file_id); let line_index = LineIndex { - index: line_index.clone(), + index: line_index, encoding: OffsetEncoding::Utf16, endings: LineEndings::Unix, }; diff --git a/crates/syntax/src/ast/expr_ext.rs b/crates/syntax/src/ast/expr_ext.rs index f421f34b3d..28b4f5bc02 100644 --- a/crates/syntax/src/ast/expr_ext.rs +++ b/crates/syntax/src/ast/expr_ext.rs @@ -336,7 +336,7 @@ impl AstNode for CallableExpr { { if let Some(it) = ast::CallExpr::cast(syntax.clone()) { Some(Self::Call(it)) - } else if let Some(it) = ast::MethodCallExpr::cast(syntax.clone()) { + } else if let Some(it) = ast::MethodCallExpr::cast(syntax) { Some(Self::MethodCall(it)) } else { None