diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-19 20:19:41 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-19 20:19:41 +0100 |
commit | 90f837829d4f2c1054751de2de695ba1c0b8ae5c (patch) | |
tree | 87de3a5aeb55aabd3bd14ba7132d69751db0bb24 /crates | |
parent | 24af351018f2aeb11a2fb8cabb551798a5ab695e (diff) | |
parent | d7f3d858add197f91969c69b1d4a14dbcb801f03 (diff) |
Merge #4047
4047: Some clippy fixes r=matklad a=kjeremy
Mostly removes redundant `clone` and `into`
Co-authored-by: Jeremy Kolb <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/handlers/add_from_impl_for_enum.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/introduce_variable.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/merge_imports.rs | 2 | ||||
-rw-r--r-- | crates/ra_db/src/fixture.rs | 2 | ||||
-rw-r--r-- | crates/ra_db/src/input.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/ast_id_map.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_expand/src/builtin_macro.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide/src/extend_selection.rs | 2 | ||||
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 3 | ||||
-rw-r--r-- | crates/rust-analyzer/src/world.rs | 2 |
11 files changed, 16 insertions, 19 deletions
diff --git a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs index 864373aa5..0621487e8 100644 --- a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs +++ b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs | |||
@@ -98,7 +98,7 @@ fn already_has_from_impl( | |||
98 | }; | 98 | }; |
99 | let var_ty = hir_enum_var.fields(sema.db)[0].signature_ty(sema.db); | 99 | let var_ty = hir_enum_var.fields(sema.db)[0].signature_ty(sema.db); |
100 | 100 | ||
101 | e_ty.impls_trait(sema.db, from_trait, &[var_ty.clone()]) | 101 | e_ty.impls_trait(sema.db, from_trait, &[var_ty]) |
102 | } | 102 | } |
103 | 103 | ||
104 | #[cfg(test)] | 104 | #[cfg(test)] |
diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs index 8d0f7e922..8c09e6bcd 100644 --- a/crates/ra_assists/src/handlers/introduce_variable.rs +++ b/crates/ra_assists/src/handlers/introduce_variable.rs | |||
@@ -124,7 +124,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> { | |||
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | if ast::Stmt::cast(node.clone().into()).is_some() { | 127 | if ast::Stmt::cast(node.clone()).is_some() { |
128 | return Some((node, false)); | 128 | return Some((node, false)); |
129 | } | 129 | } |
130 | 130 | ||
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index ef0ce0586..4be1238f1 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs | |||
@@ -30,7 +30,7 @@ pub(crate) fn merge_imports(ctx: AssistCtx) -> Option<Assist> { | |||
30 | .filter_map(|dir| neighbor(&use_item, dir)) | 30 | .filter_map(|dir| neighbor(&use_item, dir)) |
31 | .filter_map(|it| Some((it.clone(), it.use_tree()?))) | 31 | .filter_map(|it| Some((it.clone(), it.use_tree()?))) |
32 | .find_map(|(use_item, use_tree)| { | 32 | .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)) |
34 | })?; | 34 | })?; |
35 | 35 | ||
36 | rewriter.replace_ast(&tree, &merged); | 36 | rewriter.replace_ast(&tree, &merged); |
diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs index 7777ce81e..8248684ee 100644 --- a/crates/ra_db/src/fixture.rs +++ b/crates/ra_db/src/fixture.rs | |||
@@ -235,7 +235,7 @@ fn parse_meta(meta: &str) -> ParsedMeta { | |||
235 | "env" => { | 235 | "env" => { |
236 | for key in value.split(',') { | 236 | for key in value.split(',') { |
237 | if let Some((k, v)) = split1(key, '=') { | 237 | if let Some((k, v)) = split1(key, '=') { |
238 | env.set(k.into(), v.into()); | 238 | env.set(k, v.into()); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | } | 241 | } |
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 5ddce98c6..ab14e2d5e 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -327,7 +327,7 @@ impl ExternSource { | |||
327 | self.extern_paths.iter().find_map(|(root_path, id)| { | 327 | self.extern_paths.iter().find_map(|(root_path, id)| { |
328 | if let Ok(rel_path) = path.strip_prefix(root_path) { | 328 | if let Ok(rel_path) = path.strip_prefix(root_path) { |
329 | let rel_path = RelativePathBuf::from_path(rel_path).ok()?; | 329 | let rel_path = RelativePathBuf::from_path(rel_path).ok()?; |
330 | Some((id.clone(), rel_path)) | 330 | Some((*id, rel_path)) |
331 | } else { | 331 | } else { |
332 | None | 332 | None |
333 | } | 333 | } |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 82a52804d..0caedd8d8 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -473,16 +473,14 @@ impl ExprCollector<'_> { | |||
473 | self.collect_block_items(&block); | 473 | self.collect_block_items(&block); |
474 | let statements = block | 474 | let statements = block |
475 | .statements() | 475 | .statements() |
476 | .filter_map(|s| match s { | 476 | .map(|s| match s { |
477 | ast::Stmt::LetStmt(stmt) => { | 477 | ast::Stmt::LetStmt(stmt) => { |
478 | let pat = self.collect_pat_opt(stmt.pat()); | 478 | let pat = self.collect_pat_opt(stmt.pat()); |
479 | let type_ref = stmt.ascribed_type().map(TypeRef::from_ast); | 479 | let type_ref = stmt.ascribed_type().map(TypeRef::from_ast); |
480 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); | 480 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); |
481 | Some(Statement::Let { pat, type_ref, initializer }) | 481 | Statement::Let { pat, type_ref, initializer } |
482 | } | ||
483 | ast::Stmt::ExprStmt(stmt) => { | ||
484 | Some(Statement::Expr(self.collect_expr_opt(stmt.expr()))) | ||
485 | } | 482 | } |
483 | ast::Stmt::ExprStmt(stmt) => Statement::Expr(self.collect_expr_opt(stmt.expr())), | ||
486 | }) | 484 | }) |
487 | .collect(); | 485 | .collect(); |
488 | let tail = block.expr().map(|e| self.collect_expr(e)); | 486 | let tail = block.expr().map(|e| self.collect_expr(e)); |
diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs index a3ca302c2..d19569245 100644 --- a/crates/ra_hir_expand/src/ast_id_map.rs +++ b/crates/ra_hir_expand/src/ast_id_map.rs | |||
@@ -66,7 +66,7 @@ impl AstIdMap { | |||
66 | // change parent's id. This means that, say, adding a new function to a | 66 | // change parent's id. This means that, say, adding a new function to a |
67 | // trait does not change ids of top-level items, which helps caching. | 67 | // trait does not change ids of top-level items, which helps caching. |
68 | bfs(node, |it| { | 68 | bfs(node, |it| { |
69 | if let Some(module_item) = ast::ModuleItem::cast(it.clone()) { | 69 | if let Some(module_item) = ast::ModuleItem::cast(it) { |
70 | res.alloc(module_item.syntax()); | 70 | res.alloc(module_item.syntax()); |
71 | } | 71 | } |
72 | }); | 72 | }); |
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index f9d3787f6..3da137f2e 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -301,7 +301,7 @@ fn relative_file(db: &dyn AstDatabase, call_id: MacroCallId, path: &str) -> Opti | |||
301 | } | 301 | } |
302 | 302 | ||
303 | // Extern paths ? | 303 | // Extern paths ? |
304 | let krate = db.relevant_crates(call_site).get(0)?.clone(); | 304 | let krate = *db.relevant_crates(call_site).get(0)?; |
305 | let (extern_source_id, relative_file) = | 305 | let (extern_source_id, relative_file) = |
306 | db.crate_graph()[krate].extern_source.extern_path(path)?; | 306 | db.crate_graph()[krate].extern_source.extern_path(path)?; |
307 | 307 | ||
@@ -329,7 +329,7 @@ fn include_expand( | |||
329 | 329 | ||
330 | // FIXME: | 330 | // FIXME: |
331 | // Handle include as expression | 331 | // 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)) |
333 | .ok_or_else(|| mbe::ExpandError::ConversionError)? | 333 | .ok_or_else(|| mbe::ExpandError::ConversionError)? |
334 | .0; | 334 | .0; |
335 | 335 | ||
@@ -340,7 +340,7 @@ fn get_env_inner(db: &dyn AstDatabase, arg_id: EagerMacroId, key: &str) -> Optio | |||
340 | let call_id: MacroCallId = arg_id.into(); | 340 | let call_id: MacroCallId = arg_id.into(); |
341 | let original_file = call_id.as_file().original_file(db); | 341 | let original_file = call_id.as_file().original_file(db); |
342 | 342 | ||
343 | let krate = db.relevant_crates(original_file).get(0)?.clone(); | 343 | let krate = *db.relevant_crates(original_file).get(0)?; |
344 | db.crate_graph()[krate].env.get(key) | 344 | db.crate_graph()[krate].env.get(key) |
345 | } | 345 | } |
346 | 346 | ||
@@ -447,7 +447,7 @@ mod tests { | |||
447 | file_id: file_id.into(), | 447 | file_id: file_id.into(), |
448 | }; | 448 | }; |
449 | 449 | ||
450 | let id: MacroCallId = db.intern_eager_expansion(eager.into()).into(); | 450 | let id: MacroCallId = db.intern_eager_expansion(eager).into(); |
451 | id.as_file() | 451 | id.as_file() |
452 | } | 452 | } |
453 | }; | 453 | }; |
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index f5a063351..753d2ef6a 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs | |||
@@ -96,7 +96,7 @@ fn try_extend_selection( | |||
96 | return Some(node.text_range()); | 96 | return Some(node.text_range()); |
97 | } | 97 | } |
98 | 98 | ||
99 | let node = shallowest_node(&node.into()); | 99 | let node = shallowest_node(&node); |
100 | 100 | ||
101 | if node.parent().map(|n| list_kinds.contains(&n.kind())) == Some(true) { | 101 | if node.parent().map(|n| list_kinds.contains(&n.kind())) == Some(true) { |
102 | if let Some(range) = extend_list_item(&node) { | 102 | if let Some(range) = extend_list_item(&node) { |
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index b50cda06f..84008b2e3 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -303,8 +303,7 @@ pub fn load_extern_resources( | |||
303 | if message.target.kind.contains(&"proc-macro".to_string()) { | 303 | if message.target.kind.contains(&"proc-macro".to_string()) { |
304 | let package_id = message.package_id; | 304 | let package_id = message.package_id; |
305 | // Skip rmeta file | 305 | // Skip rmeta file |
306 | if let Some(filename) = | 306 | if let Some(filename) = message.filenames.iter().find(|name| is_dylib(name)) |
307 | message.filenames.iter().filter(|name| is_dylib(name)).next() | ||
308 | { | 307 | { |
309 | res.proc_dylib_paths.insert(package_id, filename.clone()); | 308 | res.proc_dylib_paths.insert(package_id, filename.clone()); |
310 | } | 309 | } |
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index f2ad453fa..369578fb6 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs | |||
@@ -184,7 +184,7 @@ impl WorldState { | |||
184 | let mut analysis_host = AnalysisHost::new(lru_capacity); | 184 | let mut analysis_host = AnalysisHost::new(lru_capacity); |
185 | analysis_host.apply_change(change); | 185 | analysis_host.apply_change(change); |
186 | WorldState { | 186 | WorldState { |
187 | config: config, | 187 | config, |
188 | roots: folder_roots, | 188 | roots: folder_roots, |
189 | workspaces: Arc::new(workspaces), | 189 | workspaces: Arc::new(workspaces), |
190 | analysis_host, | 190 | analysis_host, |