Skip to content

Commit 26a1675

Browse files
committed
Remove some redundant allocations
1 parent 479d1f7 commit 26a1675

File tree

10 files changed

+9
-10
lines changed

10 files changed

+9
-10
lines changed

crates/assists/src/handlers/extract_struct_from_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn update_reference(
212212
find_node_at_offset::<ast::PathExpr>(source_file.syntax(), offset)
213213
{
214214
// tuple variant
215-
(path_expr.path()?.segment()?, path_expr.syntax().parent()?.clone())
215+
(path_expr.path()?.segment()?, path_expr.syntax().parent()?)
216216
} else if let Some(record_expr) =
217217
find_node_at_offset::<ast::RecordExpr>(source_file.syntax(), offset)
218218
{

crates/assists/src/handlers/qualify_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl QualifyCandidate<'_> {
150150
import,
151151
trait_method_name,
152152
generics,
153-
match arg_list.clone() {
153+
match arg_list {
154154
Some(args) => make::arg_list(iter::once(receiver).chain(args)),
155155
None => make::arg_list(iter::once(receiver)),
156156
}

crates/cfg/src/dnf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl DnfExpr {
3030
pub fn new(expr: CfgExpr) -> Self {
3131
let builder = Builder { expr: DnfExpr { conjunctions: Vec::new() } };
3232

33-
builder.lower(expr.clone())
33+
builder.lower(expr)
3434
}
3535

3636
/// Computes a list of present or absent atoms in `opts` that cause this expression to evaluate

crates/completion/src/completions/unqualified_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
147147
.filter_map(|(import_path, definition)| {
148148
render_resolution_with_import(
149149
RenderContext::new(ctx),
150-
ImportEdit { import_path: import_path.clone(), import_scope: import_scope.clone() },
150+
ImportEdit { import_path, import_scope: import_scope.clone() },
151151
&definition,
152152
)
153153
});

crates/completion/src/render/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a> FunctionRender<'a> {
9191
.zip(params_ty)
9292
.flat_map(|(pat, param_ty)| {
9393
let pat = pat?;
94-
let name = pat.to_string();
94+
let name = pat;
9595
let arg = name.trim_start_matches("mut ").trim_start_matches('_');
9696
Some(self.add_arg(arg, param_ty.ty()))
9797
})

crates/project_model/src/workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ fn add_target_crate_root(
475475
Some(display_name),
476476
cfg_options,
477477
env,
478-
proc_macro.clone(),
478+
proc_macro,
479479
);
480480

481481
crate_id

crates/rust-analyzer/src/main_loop.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,6 @@ impl GlobalState {
658658
log::trace!("updating notifications for {:?}", subscriptions);
659659
if self.config.publish_diagnostics {
660660
let snapshot = self.snapshot();
661-
let subscriptions = subscriptions.clone();
662661
self.task_pool.handle.spawn(move || {
663662
let diagnostics = subscriptions
664663
.into_iter()

crates/syntax/src/ast/node_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl ast::Attr {
5555
let key = self.simple_name()?;
5656
let value_token = lit.syntax().first_token()?;
5757

58-
let value: SmolStr = ast::String::cast(value_token.clone())?.value()?.into();
58+
let value: SmolStr = ast::String::cast(value_token)?.value()?.into();
5959

6060
Some((key, value))
6161
}

crates/syntax/src/ast/token_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl ast::IntNumber {
599599
text = &text[radix.prefix_len()..];
600600

601601
let buf;
602-
if text.contains("_") {
602+
if text.contains('_') {
603603
buf = text.replace('_', "");
604604
text = buf.as_str();
605605
};

xtask/src/codegen/gen_assists_docs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ r#####"
134134

135135
buf.push_str(&test)
136136
}
137-
let buf = reformat(&buf.to_string())?;
137+
let buf = reformat(&buf)?;
138138
codegen::update(&project_root().join("crates/assists/src/tests/generated.rs"), &buf, mode)
139139
}
140140

0 commit comments

Comments
 (0)