aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kolb <[email protected]>2020-12-12 17:27:09 +0000
committerJeremy Kolb <[email protected]>2020-12-12 17:27:09 +0000
commit26a1675764c9f96cc96d75d2129dd6c828b8df51 (patch)
treee53212d4569e73c7337bb205e937174f425fda5b
parent479d1f7eec22c3564867223e2093f14774092528 (diff)
Remove some redundant allocations
-rw-r--r--crates/assists/src/handlers/extract_struct_from_enum_variant.rs2
-rw-r--r--crates/assists/src/handlers/qualify_path.rs2
-rw-r--r--crates/cfg/src/dnf.rs2
-rw-r--r--crates/completion/src/completions/unqualified_path.rs2
-rw-r--r--crates/completion/src/render/function.rs2
-rw-r--r--crates/project_model/src/workspace.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop.rs1
-rw-r--r--crates/syntax/src/ast/node_ext.rs2
-rw-r--r--crates/syntax/src/ast/token_ext.rs2
-rw-r--r--xtask/src/codegen/gen_assists_docs.rs2
10 files changed, 9 insertions, 10 deletions
diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
index d85767b4e..2e56bd7ff 100644
--- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -212,7 +212,7 @@ fn update_reference(
212 find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset) 212 find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset)
213 { 213 {
214 // tuple variant 214 // tuple variant
215 (path_expr.path()?.segment()?, path_expr.syntax().parent()?.clone()) 215 (path_expr.path()?.segment()?, path_expr.syntax().parent()?)
216 } else if let Some(record_expr) = 216 } else if let Some(record_expr) =
217 find_node_at_offset::<ast::RecordExpr>(source_file.syntax(), offset) 217 find_node_at_offset::<ast::RecordExpr>(source_file.syntax(), offset)
218 { 218 {
diff --git a/crates/assists/src/handlers/qualify_path.rs b/crates/assists/src/handlers/qualify_path.rs
index 6f9810fe8..98cb09214 100644
--- a/crates/assists/src/handlers/qualify_path.rs
+++ b/crates/assists/src/handlers/qualify_path.rs
@@ -150,7 +150,7 @@ impl QualifyCandidate<'_> {
150 import, 150 import,
151 trait_method_name, 151 trait_method_name,
152 generics, 152 generics,
153 match arg_list.clone() { 153 match arg_list {
154 Some(args) => make::arg_list(iter::once(receiver).chain(args)), 154 Some(args) => make::arg_list(iter::once(receiver).chain(args)),
155 None => make::arg_list(iter::once(receiver)), 155 None => make::arg_list(iter::once(receiver)),
156 } 156 }
diff --git a/crates/cfg/src/dnf.rs b/crates/cfg/src/dnf.rs
index 580c9a9a2..30f4bcdf7 100644
--- a/crates/cfg/src/dnf.rs
+++ b/crates/cfg/src/dnf.rs
@@ -30,7 +30,7 @@ impl DnfExpr {
30 pub fn new(expr: CfgExpr) -> Self { 30 pub fn new(expr: CfgExpr) -> Self {
31 let builder = Builder { expr: DnfExpr { conjunctions: Vec::new() } }; 31 let builder = Builder { expr: DnfExpr { conjunctions: Vec::new() } };
32 32
33 builder.lower(expr.clone()) 33 builder.lower(expr)
34 } 34 }
35 35
36 /// Computes a list of present or absent atoms in `opts` that cause this expression to evaluate 36 /// Computes a list of present or absent atoms in `opts` that cause this expression to evaluate
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs
index 2b0924ae5..b9315f6c0 100644
--- a/crates/completion/src/completions/unqualified_path.rs
+++ b/crates/completion/src/completions/unqualified_path.rs
@@ -147,7 +147,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
147 .filter_map(|(import_path, definition)| { 147 .filter_map(|(import_path, definition)| {
148 render_resolution_with_import( 148 render_resolution_with_import(
149 RenderContext::new(ctx), 149 RenderContext::new(ctx),
150 ImportEdit { import_path: import_path.clone(), import_scope: import_scope.clone() }, 150 ImportEdit { import_path, import_scope: import_scope.clone() },
151 &definition, 151 &definition,
152 ) 152 )
153 }); 153 });
diff --git a/crates/completion/src/render/function.rs b/crates/completion/src/render/function.rs
index d16005249..316e05b52 100644
--- a/crates/completion/src/render/function.rs
+++ b/crates/completion/src/render/function.rs
@@ -91,7 +91,7 @@ impl<'a> FunctionRender<'a> {
91 .zip(params_ty) 91 .zip(params_ty)
92 .flat_map(|(pat, param_ty)| { 92 .flat_map(|(pat, param_ty)| {
93 let pat = pat?; 93 let pat = pat?;
94 let name = pat.to_string(); 94 let name = pat;
95 let arg = name.trim_start_matches("mut ").trim_start_matches('_'); 95 let arg = name.trim_start_matches("mut ").trim_start_matches('_');
96 Some(self.add_arg(arg, param_ty.ty())) 96 Some(self.add_arg(arg, param_ty.ty()))
97 }) 97 })
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs
index 7f4a7e56b..68a235ce3 100644
--- a/crates/project_model/src/workspace.rs
+++ b/crates/project_model/src/workspace.rs
@@ -475,7 +475,7 @@ fn add_target_crate_root(
475 Some(display_name), 475 Some(display_name),
476 cfg_options, 476 cfg_options,
477 env, 477 env,
478 proc_macro.clone(), 478 proc_macro,
479 ); 479 );
480 480
481 crate_id 481 crate_id
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index a5f7647b8..ec3d5e060 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -658,7 +658,6 @@ impl GlobalState {
658 log::trace!("updating notifications for {:?}", subscriptions); 658 log::trace!("updating notifications for {:?}", subscriptions);
659 if self.config.publish_diagnostics { 659 if self.config.publish_diagnostics {
660 let snapshot = self.snapshot(); 660 let snapshot = self.snapshot();
661 let subscriptions = subscriptions.clone();
662 self.task_pool.handle.spawn(move || { 661 self.task_pool.handle.spawn(move || {
663 let diagnostics = subscriptions 662 let diagnostics = subscriptions
664 .into_iter() 663 .into_iter()
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index aa3a4b606..820af2d20 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -55,7 +55,7 @@ impl ast::Attr {
55 let key = self.simple_name()?; 55 let key = self.simple_name()?;
56 let value_token = lit.syntax().first_token()?; 56 let value_token = lit.syntax().first_token()?;
57 57
58 let value: SmolStr = ast::String::cast(value_token.clone())?.value()?.into(); 58 let value: SmolStr = ast::String::cast(value_token)?.value()?.into();
59 59
60 Some((key, value)) 60 Some((key, value))
61 } 61 }
diff --git a/crates/syntax/src/ast/token_ext.rs b/crates/syntax/src/ast/token_ext.rs
index 52b7285dd..5e9620a40 100644
--- a/crates/syntax/src/ast/token_ext.rs
+++ b/crates/syntax/src/ast/token_ext.rs
@@ -599,7 +599,7 @@ impl ast::IntNumber {
599 text = &text[radix.prefix_len()..]; 599 text = &text[radix.prefix_len()..];
600 600
601 let buf; 601 let buf;
602 if text.contains("_") { 602 if text.contains('_') {
603 buf = text.replace('_', ""); 603 buf = text.replace('_', "");
604 text = buf.as_str(); 604 text = buf.as_str();
605 }; 605 };
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs
index d7c85ebe9..be218dea1 100644
--- a/xtask/src/codegen/gen_assists_docs.rs
+++ b/xtask/src/codegen/gen_assists_docs.rs
@@ -134,7 +134,7 @@ r#####"
134 134
135 buf.push_str(&test) 135 buf.push_str(&test)
136 } 136 }
137 let buf = reformat(&buf.to_string())?; 137 let buf = reformat(&buf)?;
138 codegen::update(&project_root().join("crates/assists/src/tests/generated.rs"), &buf, mode) 138 codegen::update(&project_root().join("crates/assists/src/tests/generated.rs"), &buf, mode)
139} 139}
140 140