needless_late_init refactoring

Simplify the creation of suggestions by using `flat_map` instead of
`chain`. Note that the order of the suggestions is not important.
This commit is contained in:
Michael Wright 2022-06-05 07:22:45 +02:00
parent 94e321a6ff
commit 2a1a80d80c

View file

@ -185,12 +185,12 @@ fn assignment_suggestions<'tcx>(
let suggestions = assignments let suggestions = assignments
.iter() .iter()
.map(|assignment| assignment.span.until(assignment.rhs_span)) .flat_map(|assignment| {
.chain( [
assignments assignment.span.until(assignment.rhs_span),
.iter() assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()),
.map(|assignment| assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi())), ]
) })
.map(|span| Some((span, String::new()))) .map(|span| Some((span, String::new())))
.collect::<Option<Vec<(Span, String)>>>()?; .collect::<Option<Vec<(Span, String)>>>()?;