mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
fix clippy::map_flatten
This commit is contained in:
parent
62ed658311
commit
d64d711db2
5 changed files with 6 additions and 8 deletions
|
@ -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() + "/")
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue