mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
unnecessary_filter_map
This commit is contained in:
parent
de6f9561f2
commit
f15ee8a380
3 changed files with 13 additions and 25 deletions
|
@ -181,7 +181,6 @@ non_canonical_partial_ord_impl = "allow"
|
||||||
self_named_constructors = "allow"
|
self_named_constructors = "allow"
|
||||||
too_many_arguments = "allow"
|
too_many_arguments = "allow"
|
||||||
type_complexity = "allow"
|
type_complexity = "allow"
|
||||||
unnecessary_filter_map = "allow"
|
|
||||||
unnecessary_lazy_evaluations = "allow"
|
unnecessary_lazy_evaluations = "allow"
|
||||||
unnecessary_mut_passed = "allow"
|
unnecessary_mut_passed = "allow"
|
||||||
useless_conversion = "allow"
|
useless_conversion = "allow"
|
||||||
|
|
|
@ -210,23 +210,14 @@ pub(crate) fn check_edit_with_config(
|
||||||
|
|
||||||
let mut combined_edit = completion.text_edit.clone();
|
let mut combined_edit = completion.text_edit.clone();
|
||||||
|
|
||||||
resolve_completion_edits(
|
resolve_completion_edits(&db, &config, position, completion.import_to_add.iter().cloned())
|
||||||
&db,
|
.into_iter()
|
||||||
&config,
|
.flatten()
|
||||||
position,
|
.for_each(|text_edit| {
|
||||||
completion
|
combined_edit.union(text_edit).expect(
|
||||||
.import_to_add
|
"Failed to apply completion resolve changes: change ranges overlap, but should not",
|
||||||
.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",
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
combined_edit.apply(&mut actual);
|
combined_edit.apply(&mut actual);
|
||||||
assert_eq_text!(&ra_fixture_after, &actual)
|
assert_eq_text!(&ra_fixture_after, &actual)
|
||||||
|
|
|
@ -312,16 +312,14 @@ fn completion_item(
|
||||||
set_score(&mut lsp_item, max_relevance, item.relevance);
|
set_score(&mut lsp_item, max_relevance, item.relevance);
|
||||||
|
|
||||||
if config.completion().enable_imports_on_the_fly && !item.import_to_add.is_empty() {
|
if config.completion().enable_imports_on_the_fly && !item.import_to_add.is_empty() {
|
||||||
let imports: Vec<_> = item
|
let imports = item
|
||||||
.import_to_add
|
.import_to_add
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|(import_path, import_name)| {
|
.map(|(import_path, import_name)| lsp_ext::CompletionImport {
|
||||||
Some(lsp_ext::CompletionImport {
|
full_import_path: import_path,
|
||||||
full_import_path: import_path,
|
imported_name: import_name,
|
||||||
imported_name: import_name,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect::<Vec<_>>();
|
||||||
if !imports.is_empty() {
|
if !imports.is_empty() {
|
||||||
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
|
let data = lsp_ext::CompletionResolveData { position: tdpp.clone(), imports };
|
||||||
lsp_item.data = Some(to_value(data).unwrap());
|
lsp_item.data = Some(to_value(data).unwrap());
|
||||||
|
|
Loading…
Reference in a new issue