1
Fork 0

compiler: clippy::complexity fixes

useless_format
map_flatten
useless_conversion
needless_bool
filter_next
clone_on_copy
needless_option_as_deref
This commit is contained in:
Matthias Krüger 2022-02-03 23:12:25 +01:00
parent 4e8fb743cc
commit b80057d08d
22 changed files with 39 additions and 45 deletions

View file

@ -1362,8 +1362,7 @@ impl<'a> Resolver<'a> {
.filter(|(_, module)| {
current_module.is_ancestor_of(module) && !ptr::eq(current_module, *module)
})
.map(|(_, module)| module.kind.name())
.flatten(),
.flat_map(|(_, module)| module.kind.name()),
)
.filter(|c| !c.to_string().is_empty())
.collect::<Vec<_>>();
@ -1859,7 +1858,7 @@ crate fn show_candidates(
let instead = if instead { " instead" } else { "" };
let mut msg = format!("consider importing {} {}{}", determiner, kind, instead);
for note in accessible_path_strings.iter().map(|cand| cand.3.as_ref()).flatten() {
for note in accessible_path_strings.iter().flat_map(|cand| cand.3.as_ref()) {
err.note(note);
}
@ -1942,7 +1941,7 @@ crate fn show_candidates(
multi_span.push_span_label(span, format!("`{}`: not accessible", name));
}
for note in inaccessible_path_strings.iter().map(|cand| cand.3.as_ref()).flatten() {
for note in inaccessible_path_strings.iter().flat_map(|cand| cand.3.as_ref()) {
err.note(note);
}

View file

@ -1167,7 +1167,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
err.span_suggestion(
span,
&"use this syntax instead",
format!("{path_str}"),
path_str.to_string(),
Applicability::MaybeIncorrect,
);
}