Skip to content

Commit 90f8378

Browse files
bors[bot]kjeremy
andauthored
Merge #4047
4047: Some clippy fixes r=matklad a=kjeremy Mostly removes redundant `clone` and `into` Co-authored-by: Jeremy Kolb <[email protected]>
2 parents 24af351 + d7f3d85 commit 90f8378

File tree

11 files changed

+16
-19
lines changed

11 files changed

+16
-19
lines changed

crates/ra_assists/src/handlers/add_from_impl_for_enum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn already_has_from_impl(
9898
};
9999
let var_ty = hir_enum_var.fields(sema.db)[0].signature_ty(sema.db);
100100

101-
e_ty.impls_trait(sema.db, from_trait, &[var_ty.clone()])
101+
e_ty.impls_trait(sema.db, from_trait, &[var_ty])
102102
}
103103

104104
#[cfg(test)]

crates/ra_assists/src/handlers/introduce_variable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> {
124124
}
125125
}
126126

127-
if ast::Stmt::cast(node.clone().into()).is_some() {
127+
if ast::Stmt::cast(node.clone()).is_some() {
128128
return Some((node, false));
129129
}
130130

crates/ra_assists/src/handlers/merge_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) fn merge_imports(ctx: AssistCtx) -> Option<Assist> {
3030
.filter_map(|dir| neighbor(&use_item, dir))
3131
.filter_map(|it| Some((it.clone(), it.use_tree()?)))
3232
.find_map(|(use_item, use_tree)| {
33-
Some((try_merge_trees(&tree, &use_tree)?, use_item.clone()))
33+
Some((try_merge_trees(&tree, &use_tree)?, use_item))
3434
})?;
3535

3636
rewriter.replace_ast(&tree, &merged);

crates/ra_db/src/fixture.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ fn parse_meta(meta: &str) -> ParsedMeta {
235235
"env" => {
236236
for key in value.split(',') {
237237
if let Some((k, v)) = split1(key, '=') {
238-
env.set(k.into(), v.into());
238+
env.set(k, v.into());
239239
}
240240
}
241241
}

crates/ra_db/src/input.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl ExternSource {
327327
self.extern_paths.iter().find_map(|(root_path, id)| {
328328
if let Ok(rel_path) = path.strip_prefix(root_path) {
329329
let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
330-
Some((id.clone(), rel_path))
330+
Some((*id, rel_path))
331331
} else {
332332
None
333333
}

crates/ra_hir_def/src/body/lower.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -473,16 +473,14 @@ impl ExprCollector<'_> {
473473
self.collect_block_items(&block);
474474
let statements = block
475475
.statements()
476-
.filter_map(|s| match s {
476+
.map(|s| match s {
477477
ast::Stmt::LetStmt(stmt) => {
478478
let pat = self.collect_pat_opt(stmt.pat());
479479
let type_ref = stmt.ascribed_type().map(TypeRef::from_ast);
480480
let initializer = stmt.initializer().map(|e| self.collect_expr(e));
481-
Some(Statement::Let { pat, type_ref, initializer })
482-
}
483-
ast::Stmt::ExprStmt(stmt) => {
484-
Some(Statement::Expr(self.collect_expr_opt(stmt.expr())))
481+
Statement::Let { pat, type_ref, initializer }
485482
}
483+
ast::Stmt::ExprStmt(stmt) => Statement::Expr(self.collect_expr_opt(stmt.expr())),
486484
})
487485
.collect();
488486
let tail = block.expr().map(|e| self.collect_expr(e));

crates/ra_hir_expand/src/ast_id_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl AstIdMap {
6666
// change parent's id. This means that, say, adding a new function to a
6767
// trait does not change ids of top-level items, which helps caching.
6868
bfs(node, |it| {
69-
if let Some(module_item) = ast::ModuleItem::cast(it.clone()) {
69+
if let Some(module_item) = ast::ModuleItem::cast(it) {
7070
res.alloc(module_item.syntax());
7171
}
7272
});

crates/ra_hir_expand/src/builtin_macro.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ fn relative_file(db: &dyn AstDatabase, call_id: MacroCallId, path: &str) -> Opti
301301
}
302302

303303
// Extern paths ?
304-
let krate = db.relevant_crates(call_site).get(0)?.clone();
304+
let krate = *db.relevant_crates(call_site).get(0)?;
305305
let (extern_source_id, relative_file) =
306306
db.crate_graph()[krate].extern_source.extern_path(path)?;
307307

@@ -329,7 +329,7 @@ fn include_expand(
329329

330330
// FIXME:
331331
// Handle include as expression
332-
let res = parse_to_token_tree(&db.file_text(file_id.into()))
332+
let res = parse_to_token_tree(&db.file_text(file_id))
333333
.ok_or_else(|| mbe::ExpandError::ConversionError)?
334334
.0;
335335

@@ -340,7 +340,7 @@ fn get_env_inner(db: &dyn AstDatabase, arg_id: EagerMacroId, key: &str) -> Optio
340340
let call_id: MacroCallId = arg_id.into();
341341
let original_file = call_id.as_file().original_file(db);
342342

343-
let krate = db.relevant_crates(original_file).get(0)?.clone();
343+
let krate = *db.relevant_crates(original_file).get(0)?;
344344
db.crate_graph()[krate].env.get(key)
345345
}
346346

@@ -447,7 +447,7 @@ mod tests {
447447
file_id: file_id.into(),
448448
};
449449

450-
let id: MacroCallId = db.intern_eager_expansion(eager.into()).into();
450+
let id: MacroCallId = db.intern_eager_expansion(eager).into();
451451
id.as_file()
452452
}
453453
};

crates/ra_ide/src/extend_selection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn try_extend_selection(
9696
return Some(node.text_range());
9797
}
9898

99-
let node = shallowest_node(&node.into());
99+
let node = shallowest_node(&node);
100100

101101
if node.parent().map(|n| list_kinds.contains(&n.kind())) == Some(true) {
102102
if let Some(range) = extend_list_item(&node) {

crates/ra_project_model/src/cargo_workspace.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ pub fn load_extern_resources(
303303
if message.target.kind.contains(&"proc-macro".to_string()) {
304304
let package_id = message.package_id;
305305
// Skip rmeta file
306-
if let Some(filename) =
307-
message.filenames.iter().filter(|name| is_dylib(name)).next()
306+
if let Some(filename) = message.filenames.iter().find(|name| is_dylib(name))
308307
{
309308
res.proc_dylib_paths.insert(package_id, filename.clone());
310309
}

crates/rust-analyzer/src/world.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl WorldState {
184184
let mut analysis_host = AnalysisHost::new(lru_capacity);
185185
analysis_host.apply_change(change);
186186
WorldState {
187-
config: config,
187+
config,
188188
roots: folder_roots,
189189
workspaces: Arc::new(workspaces),
190190
analysis_host,

0 commit comments

Comments
 (0)