Skip to content

Commit f15ee8a

Browse files
committed
unnecessary_filter_map
1 parent de6f956 commit f15ee8a

File tree

3 files changed

+13
-25
lines changed

3 files changed

+13
-25
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ non_canonical_partial_ord_impl = "allow"
181181
self_named_constructors = "allow"
182182
too_many_arguments = "allow"
183183
type_complexity = "allow"
184-
unnecessary_filter_map = "allow"
185184
unnecessary_lazy_evaluations = "allow"
186185
unnecessary_mut_passed = "allow"
187186
useless_conversion = "allow"

crates/ide-completion/src/tests.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -210,23 +210,14 @@ pub(crate) fn check_edit_with_config(
210210

211211
let mut combined_edit = completion.text_edit.clone();
212212

213-
resolve_completion_edits(
214-
&db,
215-
&config,
216-
position,
217-
completion
218-
.import_to_add
219-
.iter()
220-
.cloned()
221-
.filter_map(|(import_path, import_name)| Some((import_path, import_name))),
222-
)
223-
.into_iter()
224-
.flatten()
225-
.for_each(|text_edit| {
226-
combined_edit.union(text_edit).expect(
227-
"Failed to apply completion resolve changes: change ranges overlap, but should not",
228-
)
229-
});
213+
resolve_completion_edits(&db, &config, position, completion.import_to_add.iter().cloned())
214+
.into_iter()
215+
.flatten()
216+
.for_each(|text_edit| {
217+
combined_edit.union(text_edit).expect(
218+
"Failed to apply completion resolve changes: change ranges overlap, but should not",
219+
)
220+
});
230221

231222
combined_edit.apply(&mut actual);
232223
assert_eq_text!(&ra_fixture_after, &actual)

crates/rust-analyzer/src/lsp/to_proto.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,14 @@ fn completion_item(
312312
set_score(&mut lsp_item, max_relevance, item.relevance);
313313

314314
if config.completion().enable_imports_on_the_fly && !item.import_to_add.is_empty() {
315-
let imports: Vec<_> = item
315+
let imports = item
316316
.import_to_add
317317
.into_iter()
318-
.filter_map(|(import_path, import_name)| {
319-
Some(lsp_ext::CompletionImport {
320-
full_import_path: import_path,
321-
imported_name: import_name,
322-
})
318+
.map(|(import_path, import_name)| lsp_ext::CompletionImport {
319+
full_import_path: import_path,
320+
imported_name: import_name,
323321
})
324-
.collect();
322+
.collect::<Vec<_>>();
325323
if !imports.is_empty() {
326324
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
327325
lsp_item.data = Some(to_value(data).unwrap());

0 commit comments

Comments
 (0)