fix clippy::map_flatten

This commit is contained in:
Matthias Krüger 2022-03-12 14:26:16 +01:00
parent 62ed658311
commit d64d711db2
5 changed files with 6 additions and 8 deletions

View File

@ -231,7 +231,7 @@ pub fn get_html_root_url(self: &Crate, db: &dyn HirDatabase) -> Option<String> {
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 @@ pub fn get_html_root_url(self: &Crate, db: &dyn HirDatabase) -> Option<String> {
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() + "/")
}

View File

@ -261,7 +261,7 @@ fn test_quote_derive_copy_hack() {
// }
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 {

View File

@ -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()
});
}

View File

@ -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))

View File

@ -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 {