about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohann Hemmann <johann.hemmann@code.berlin>2024-01-22 01:11:59 +0100
committerJohann Hemmann <johann.hemmann@code.berlin>2024-01-31 19:06:18 +0100
commitf15ee8a380c18cf7d9d53a91c2b4a6d6161e9877 (patch)
tree032a6973be9750ef4d6f736c6c44efb7e1519043
parentde6f9561f2822b87aede9f5edc6e14951da570ba (diff)
downloadrust-f15ee8a380c18cf7d9d53a91c2b4a6d6161e9877.tar.gz
rust-f15ee8a380c18cf7d9d53a91c2b4a6d6161e9877.zip
unnecessary_filter_map
-rw-r--r--Cargo.toml1
-rw-r--r--crates/ide-completion/src/tests.rs25
-rw-r--r--crates/rust-analyzer/src/lsp/to_proto.rs12
3 files changed, 13 insertions, 25 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8d861f2a18a..b8f273af471 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -181,7 +181,6 @@ non_canonical_partial_ord_impl = "allow"
 self_named_constructors = "allow"
 too_many_arguments = "allow"
 type_complexity = "allow"
-unnecessary_filter_map = "allow"
 unnecessary_lazy_evaluations = "allow"
 unnecessary_mut_passed = "allow"
 useless_conversion = "allow"
diff --git a/crates/ide-completion/src/tests.rs b/crates/ide-completion/src/tests.rs
index c421be51a0d..154b69875ae 100644
--- a/crates/ide-completion/src/tests.rs
+++ b/crates/ide-completion/src/tests.rs
@@ -210,23 +210,14 @@ pub(crate) fn check_edit_with_config(
 
     let mut combined_edit = completion.text_edit.clone();
 
-    resolve_completion_edits(
-        &db,
-        &config,
-        position,
-        completion
-            .import_to_add
-            .iter()
-            .cloned()
-            .filter_map(|(import_path, import_name)| Some((import_path, import_name))),
-    )
-    .into_iter()
-    .flatten()
-    .for_each(|text_edit| {
-        combined_edit.union(text_edit).expect(
-            "Failed to apply completion resolve changes: change ranges overlap, but should not",
-        )
-    });
+    resolve_completion_edits(&db, &config, position, completion.import_to_add.iter().cloned())
+        .into_iter()
+        .flatten()
+        .for_each(|text_edit| {
+            combined_edit.union(text_edit).expect(
+                "Failed to apply completion resolve changes: change ranges overlap, but should not",
+            )
+        });
 
     combined_edit.apply(&mut actual);
     assert_eq_text!(&ra_fixture_after, &actual)
diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs
index f221863aff0..d363ac69fdc 100644
--- a/crates/rust-analyzer/src/lsp/to_proto.rs
+++ b/crates/rust-analyzer/src/lsp/to_proto.rs
@@ -312,16 +312,14 @@ fn completion_item(
     set_score(&mut lsp_item, max_relevance, item.relevance);
 
     if config.completion().enable_imports_on_the_fly && !item.import_to_add.is_empty() {
-        let imports: Vec<_> = item
+        let imports = item
             .import_to_add
             .into_iter()
-            .filter_map(|(import_path, import_name)| {
-                Some(lsp_ext::CompletionImport {
-                    full_import_path: import_path,
-                    imported_name: import_name,
-                })
+            .map(|(import_path, import_name)| lsp_ext::CompletionImport {
+                full_import_path: import_path,
+                imported_name: import_name,
             })
-            .collect();
+            .collect::<Vec<_>>();
         if !imports.is_empty() {
             let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
             lsp_item.data = Some(to_value(data).unwrap());