Skip to content

Commit 64ca0f6

Browse files
bors[bot]k-nasa
andauthored
Merge #10504
10504: Remove needless clone r=lnicola a=k-nasa ## Why Delete clones for efficiency ## What - I erased unnecessary clones Co-authored-by: k-nasa <[email protected]>
2 parents ce86534 + 9dd823a commit 64ca0f6

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

crates/hir_def/src/generics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl HasChildSource<LocalTypeParamId> for GenericDefId {
392392

393393
// For traits the first type index is `Self`, we need to add it before the other params.
394394
if let GenericDefId::TraitId(id) = *self {
395-
let trait_ref = id.lookup(db).source(db).value.clone();
395+
let trait_ref = id.lookup(db).source(db).value;
396396
let idx = idx_iter.next().unwrap();
397397
params.insert(idx, Either::Right(trait_ref))
398398
}

crates/ide/src/doc_links.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl DocCommentToken {
254254
let original_start = doc_token.text_range().start();
255255
let relative_comment_offset = offset - original_start - prefix_len;
256256

257-
sema.descend_into_macros_many(doc_token.clone()).into_iter().find_map(|t| {
257+
sema.descend_into_macros_many(doc_token).into_iter().find_map(|t| {
258258
let (node, descended_prefix_len) = match_ast! {
259259
match t {
260260
ast::Comment(comment) => (t.parent()?, TextSize::try_from(comment.prefix().len()).ok()?),

crates/ide/src/goto_definition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub(crate) fn goto_definition(
4747
.into_iter()
4848
.filter_map(|token| {
4949
let parent = token.parent()?;
50-
if let Some(tt) = ast::TokenTree::cast(parent.clone()) {
50+
if let Some(tt) = ast::TokenTree::cast(parent) {
5151
if let x @ Some(_) =
5252
try_lookup_include_path(&sema, tt, token.clone(), position.file_id)
5353
{
@@ -77,7 +77,7 @@ fn try_lookup_include_path(
7777
token: SyntaxToken,
7878
file_id: FileId,
7979
) -> Option<Vec<NavigationTarget>> {
80-
let token = ast::String::cast(token.clone())?;
80+
let token = ast::String::cast(token)?;
8181
let path = token.value()?.into_owned();
8282
let macro_call = tt.syntax().parent().and_then(ast::MacroCall::cast)?;
8383
let name = macro_call.path()?.segment()?.name_ref()?;

crates/ide_assists/src/handlers/extract_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn extraction_target(node: &SyntaxNode, selection_range: TextRange) -> Option<Fu
169169
let expr = ast::Expr::cast(node.clone())?;
170170
// A node got selected fully
171171
if node.text_range() == selection_range {
172-
return FunctionBody::from_expr(expr.clone());
172+
return FunctionBody::from_expr(expr);
173173
}
174174

175175
node.ancestors().find_map(ast::Expr::cast).and_then(FunctionBody::from_expr)

crates/ide_completion/src/render/enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'a> EnumRender<'a> {
5353
}
5454
None => (
5555
hir::ModPath::from_segments(hir::PathKind::Plain, iter::once(name.clone())),
56-
hir::ModPath::from_segments(hir::PathKind::Plain, iter::once(name.clone())),
56+
hir::ModPath::from_segments(hir::PathKind::Plain, iter::once(name)),
5757
),
5858
};
5959

crates/ide_diagnostics/src/handlers/missing_fields.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
5858
let mut locals = FxHashMap::default();
5959
ctx.sema.scope(field_list_parent.syntax()).process_all_names(&mut |name, def| {
6060
if let hir::ScopeDef::Local(local) = def {
61-
locals.insert(name.clone(), local);
61+
locals.insert(name, local);
6262
}
6363
});
6464
let missing_fields = ctx.sema.record_literal_missing_fields(&field_list_parent);

crates/rust-analyzer/src/cli/lsif.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl LsifManager<'_> {
100100
let doc_id = self.get_file_id(file_id);
101101
let line_index = self.db.line_index(file_id);
102102
let line_index = LineIndex {
103-
index: line_index.clone(),
103+
index: line_index,
104104
encoding: OffsetEncoding::Utf16,
105105
endings: LineEndings::Unix,
106106
};
@@ -191,7 +191,7 @@ impl LsifManager<'_> {
191191
let text = self.analysis.file_text(file_id).unwrap();
192192
let line_index = self.db.line_index(file_id);
193193
let line_index = LineIndex {
194-
index: line_index.clone(),
194+
index: line_index,
195195
encoding: OffsetEncoding::Utf16,
196196
endings: LineEndings::Unix,
197197
};

crates/syntax/src/ast/expr_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl AstNode for CallableExpr {
336336
{
337337
if let Some(it) = ast::CallExpr::cast(syntax.clone()) {
338338
Some(Self::Call(it))
339-
} else if let Some(it) = ast::MethodCallExpr::cast(syntax.clone()) {
339+
} else if let Some(it) = ast::MethodCallExpr::cast(syntax) {
340340
Some(Self::MethodCall(it))
341341
} else {
342342
None

0 commit comments

Comments
 (0)