From 79d103d5b42c5b207c28b6eb8a6ab42f0c685ec5 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Fri, 5 Feb 2021 16:57:26 +0100 Subject: Remove redundant clones --- crates/assists/src/assist_context.rs | 4 ++-- crates/hir_def/src/body/lower.rs | 2 +- crates/hir_def/src/data.rs | 2 +- crates/hir_def/src/test_db.rs | 2 +- crates/hir_ty/src/diagnostics.rs | 2 +- crates/proc_macro_api/src/rpc.rs | 2 +- crates/test_utils/src/fixture.rs | 11 +---------- 7 files changed, 8 insertions(+), 17 deletions(-) (limited to 'crates') diff --git a/crates/assists/src/assist_context.rs b/crates/assists/src/assist_context.rs index 8d93edba2..bba6c08e0 100644 --- a/crates/assists/src/assist_context.rs +++ b/crates/assists/src/assist_context.rs @@ -162,7 +162,7 @@ impl Assists { } else { None }; - assist.source_change = source_change.clone(); + assist.source_change = source_change; self.buf.push(assist); Some(()) @@ -242,7 +242,7 @@ impl AssistBuilder { } pub(crate) fn create_file(&mut self, dst: AnchoredPathBuf, content: impl Into) { let file_system_edit = - FileSystemEdit::CreateFile { dst: dst.clone(), initial_contents: content.into() }; + FileSystemEdit::CreateFile { dst: dst, initial_contents: content.into() }; self.source_change.push_file_system_edit(file_system_edit); } diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index 28b11cdde..c18001e15 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs @@ -712,7 +712,7 @@ impl ExprCollector<'_> { let statements = block.statements().filter_map(|s| self.collect_stmt(s)).flatten().collect(); let tail = block.tail_expr().map(|e| self.collect_expr(e)); - let syntax_node_ptr = AstPtr::new(&block.clone().into()); + let syntax_node_ptr = AstPtr::new(&block.into()); let expr_id = self.alloc_expr( Expr::Block { id: block_id, statements, tail, label: None }, syntax_node_ptr, diff --git a/crates/hir_def/src/data.rs b/crates/hir_def/src/data.rs index 42fcca386..d3380e0f4 100644 --- a/crates/hir_def/src/data.rs +++ b/crates/hir_def/src/data.rs @@ -43,7 +43,7 @@ impl FunctionData { name: func.name.clone(), params: func.params.iter().map(|id| item_tree[*id].clone()).collect(), ret_type: item_tree[func.ret_type].clone(), - attrs: item_tree.attrs(db, krate, ModItem::from(loc.id.value).into()).clone(), + attrs: item_tree.attrs(db, krate, ModItem::from(loc.id.value).into()), has_self_param: func.has_self_param, has_body: func.has_body, is_unsafe: func.is_unsafe, diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs index c4e36eda5..6665d902d 100644 --- a/crates/hir_def/src/test_db.rs +++ b/crates/hir_def/src/test_db.rs @@ -161,7 +161,7 @@ impl TestDB { let node = src.map(|ptr| ptr.to_node(&root)); let frange = node.as_ref().original_file_range(db); - let message = d.message().to_owned(); + let message = d.message(); actual.entry(frange.file_id).or_default().push((frange.range, message)); }); diff --git a/crates/hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs index 323c5f963..1b628d247 100644 --- a/crates/hir_ty/src/diagnostics.rs +++ b/crates/hir_ty/src/diagnostics.rs @@ -480,7 +480,7 @@ mod tests { // FIXME: macros... let file_id = src.file_id.original_file(&db); let range = src.value.to_node(&root).text_range(); - let message = d.message().to_owned(); + let message = d.message(); actual.entry(file_id).or_default().push((range, message)); }); diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs index cf830b59f..64cfdafc5 100644 --- a/crates/proc_macro_api/src/rpc.rs +++ b/crates/proc_macro_api/src/rpc.rs @@ -262,7 +262,7 @@ mod tests { assert_eq!(task.macro_body, back.macro_body); - let result = ExpansionResult { expansion: tt.clone() }; + let result = ExpansionResult { expansion: tt }; let json = serde_json::to_string(&result).unwrap(); let back: ExpansionResult = serde_json::from_str(&json).unwrap(); diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs index e40b61a94..e3f57f3b2 100644 --- a/crates/test_utils/src/fixture.rs +++ b/crates/test_utils/src/fixture.rs @@ -95,16 +95,7 @@ impl Fixture { } } - Fixture { - path, - text: String::new(), - krate: krate, - deps, - cfg_atoms, - cfg_key_values, - edition, - env, - } + Fixture { path, text: String::new(), krate, deps, cfg_atoms, cfg_key_values, edition, env } } } -- cgit v1.2.3