Unnamed repository; edit this file 'description' to name the repository.
fix clippy::map_flatten
Matthias Krüger 2022-03-12
parent 62ed658 · commit d64d711
-rw-r--r--crates/hir/src/lib.rs4
-rw-r--r--crates/hir_expand/src/quote.rs2
-rw-r--r--crates/ide/src/annotations.rs3
-rw-r--r--crates/ide_db/src/symbol_index.rs3
-rw-r--r--crates/rust-analyzer/src/handlers.rs2
5 files changed, 6 insertions, 8 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index d83fb16d10..0417196843 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -231,7 +231,7 @@ impl Crate {
return None;
}
- let doc_url = doc_attr_q.tt_values().map(|tt| {
+ let doc_url = doc_attr_q.tt_values().filter_map(|tt| {
let name = tt.token_trees.iter()
.skip_while(|tt| !matches!(tt, TokenTree::Leaf(Leaf::Ident(Ident { text, ..} )) if text == "html_root_url"))
.nth(2);
@@ -240,7 +240,7 @@ impl Crate {
Some(TokenTree::Leaf(Leaf::Literal(Literal{ref text, ..}))) => Some(text),
_ => None
}
- }).flatten().next();
+ }).next();
doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/")
}
diff --git a/crates/hir_expand/src/quote.rs b/crates/hir_expand/src/quote.rs
index 230a599641..82f410ecda 100644
--- a/crates/hir_expand/src/quote.rs
+++ b/crates/hir_expand/src/quote.rs
@@ -261,7 +261,7 @@ mod tests {
// }
let struct_name = mk_ident("Foo");
let fields = [mk_ident("name"), mk_ident("id")];
- let fields = fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees).flatten();
+ let fields = fields.iter().flat_map(|it| quote!(#it: self.#it.clone(), ).token_trees);
let list = tt::Subtree {
delimiter: Some(tt::Delimiter {
diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs
index 986db75c61..8bfcf3beb8 100644
--- a/crates/ide/src/annotations.rs
+++ b/crates/ide/src/annotations.rs
@@ -170,10 +170,9 @@ pub(crate) fn resolve_annotation(db: &RootDatabase, mut annotation: Annotation)
result
.into_iter()
.flat_map(|res| res.references)
- .map(|(file_id, access)| {
+ .flat_map(|(file_id, access)| {
access.into_iter().map(move |(range, _)| FileRange { file_id, range })
})
- .flatten()
.collect()
});
}
diff --git a/crates/ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs
index b5979e6b83..a812c838ac 100644
--- a/crates/ide_db/src/symbol_index.rs
+++ b/crates/ide_db/src/symbol_index.rs
@@ -120,8 +120,7 @@ fn library_symbols(db: &dyn SymbolsDatabase, source_root_id: SourceRootId) -> Ar
// we specifically avoid calling SymbolsDatabase::module_symbols here, even they do the same thing,
// as the index for a library is not going to really ever change, and we do not want to store each
// module's index in salsa.
- .map(|module| SymbolCollector::collect(db.upcast(), module))
- .flatten()
+ .flat_map(|module| SymbolCollector::collect(db.upcast(), module))
.collect();
Arc::new(SymbolIndex::new(symbols))
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index b5e9776000..e63b6f490b 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -532,7 +532,7 @@ pub(crate) fn handle_will_rename_files(
let mut source_change = source_changes.next().unwrap_or_default();
source_change.file_system_edits.clear();
// no collect here because we want to merge text edits on same file ids
- source_change.extend(source_changes.map(|it| it.source_file_edits).flatten());
+ source_change.extend(source_changes.flat_map(|it| it.source_file_edits));
if source_change.source_file_edits.is_empty() {
Ok(None)
} else {