From 048dad8c2e86006e53b3a134279729efb28b9e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 17 Mar 2021 01:56:31 +0100 Subject: don't clone types that are copy (clippy::clone_on_copy) --- .../ide_assists/src/handlers/extract_struct_from_enum_variant.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'crates/ide_assists/src') diff --git a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs index 335e0ed95..596c536a7 100644 --- a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -145,11 +145,8 @@ fn insert_import( variant_hir_name: &Name, ) -> Option<()> { let db = ctx.db(); - let mod_path = module.find_use_path_prefixed( - db, - enum_module_def.clone(), - ctx.config.insert_use.prefix_kind, - ); + let mod_path = + module.find_use_path_prefixed(db, *enum_module_def, ctx.config.insert_use.prefix_kind); if let Some(mut mod_path) = mod_path { mod_path.pop_segment(); mod_path.push_segment(variant_hir_name.clone()); -- cgit v1.2.3 From ff5f90d8ae2da8e4856d5c78f55e5cd02b178325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 17 Mar 2021 02:34:46 +0100 Subject: use simpler .map(|x| y) instead of .and_then(|x| Some(y)) for Options. (clippy::bind_instead_of_map) --- crates/ide_assists/src/handlers/expand_glob_import.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ide_assists/src') diff --git a/crates/ide_assists/src/handlers/expand_glob_import.rs b/crates/ide_assists/src/handlers/expand_glob_import.rs index 5b540df5c..83aa11d52 100644 --- a/crates/ide_assists/src/handlers/expand_glob_import.rs +++ b/crates/ide_assists/src/handlers/expand_glob_import.rs @@ -73,8 +73,8 @@ fn find_parent_and_path( ) -> Option<(Either, ast::Path)> { return star.ancestors().find_map(|n| { find_use_tree_list(n.clone()) - .and_then(|(u, p)| Some((Either::Right(u), p))) - .or_else(|| find_use_tree(n).and_then(|(u, p)| Some((Either::Left(u), p)))) + .map(|(u, p)| (Either::Right(u), p)) + .or_else(|| find_use_tree(n).map(|(u, p)| (Either::Left(u), p))) }); fn find_use_tree_list(n: SyntaxNode) -> Option<(ast::UseTreeList, ast::Path)> { -- cgit v1.2.3