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
.iter()
.map(|assignment| assignment.span.until(assignment.rhs_span))
.chain(
assignments
.iter()
.map(|assignment| assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi())),
)
.flat_map(|assignment| {
[
assignment.span.until(assignment.rhs_span),
assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()),
]
})
.map(|span| Some((span, String::new())))
.collect::<Option<Vec<(Span, String)>>>()?;