From 42377d3dad76f9748dd7a8e0fe737fec1fb4e3d0 Mon Sep 17 00:00:00 2001 From: k-nasa Date: Sun, 10 Oct 2021 10:10:52 +0900 Subject: [PATCH 1/5] Add code comment --- crates/syntax/src/syntax_node.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/syntax/src/syntax_node.rs b/crates/syntax/src/syntax_node.rs index bd7ea0240b..8647c1dc75 100644 --- a/crates/syntax/src/syntax_node.rs +++ b/crates/syntax/src/syntax_node.rs @@ -47,6 +47,8 @@ impl SyntaxTreeBuilder { pub fn finish(self) -> Parse { let (green, errors) = self.finish_raw(); + // NOTE Why you're disabling assertions. + // ref: https://github.com/rust-analyzer/rust-analyzer/pull/10357 if cfg!(debug_assertions) && false { let node = SyntaxNode::new_root(green.clone()); crate::validation::validate_block_structure(&node); From 820393f72d68c6bf1df125057296402ba83ca982 Mon Sep 17 00:00:00 2001 From: k-nasa Date: Sun, 10 Oct 2021 10:16:32 +0900 Subject: [PATCH 2/5] update comment --- crates/syntax/src/syntax_node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/syntax/src/syntax_node.rs b/crates/syntax/src/syntax_node.rs index 8647c1dc75..241c37a1e5 100644 --- a/crates/syntax/src/syntax_node.rs +++ b/crates/syntax/src/syntax_node.rs @@ -47,7 +47,7 @@ impl SyntaxTreeBuilder { pub fn finish(self) -> Parse { let (green, errors) = self.finish_raw(); - // NOTE Why you're disabling assertions. + // NOTE Why disabling assertions. // ref: https://github.com/rust-analyzer/rust-analyzer/pull/10357 if cfg!(debug_assertions) && false { let node = SyntaxNode::new_root(green.clone()); From b50cb5c2615768380b1d7b2f7923e2d944dc472f Mon Sep 17 00:00:00 2001 From: k-nasa Date: Sun, 10 Oct 2021 10:50:51 +0900 Subject: [PATCH 3/5] 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 From 3829cd981ae30a006eac2703eceabf6936d45e26 Mon Sep 17 00:00:00 2001 From: k-nasa Date: Sun, 10 Oct 2021 10:51:45 +0900 Subject: [PATCH 4/5] Revert "update comment" This reverts commit 820393f72d68c6bf1df125057296402ba83ca982. --- crates/syntax/src/syntax_node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/syntax/src/syntax_node.rs b/crates/syntax/src/syntax_node.rs index 241c37a1e5..8647c1dc75 100644 --- a/crates/syntax/src/syntax_node.rs +++ b/crates/syntax/src/syntax_node.rs @@ -47,7 +47,7 @@ impl SyntaxTreeBuilder { pub fn finish(self) -> Parse { let (green, errors) = self.finish_raw(); - // NOTE Why disabling assertions. + // NOTE Why you're disabling assertions. // ref: https://github.com/rust-analyzer/rust-analyzer/pull/10357 if cfg!(debug_assertions) && false { let node = SyntaxNode::new_root(green.clone()); From 9dd823a0e1f54bedd7dd5a12e5ae45f59f6755e3 Mon Sep 17 00:00:00 2001 From: k-nasa Date: Sun, 10 Oct 2021 13:16:34 +0900 Subject: [PATCH 5/5] remove comment --- crates/syntax/src/syntax_node.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/syntax/src/syntax_node.rs b/crates/syntax/src/syntax_node.rs index 8647c1dc75..bd7ea0240b 100644 --- a/crates/syntax/src/syntax_node.rs +++ b/crates/syntax/src/syntax_node.rs @@ -47,8 +47,6 @@ impl SyntaxTreeBuilder { pub fn finish(self) -> Parse { let (green, errors) = self.finish_raw(); - // NOTE Why you're disabling assertions. - // ref: https://github.com/rust-analyzer/rust-analyzer/pull/10357 if cfg!(debug_assertions) && false { let node = SyntaxNode::new_root(green.clone()); crate::validation::validate_block_structure(&node);