needless_late_init refactoring

Remove duplication in creating suggestions by first mapping assignments
to spans and then suggestions.
This commit is contained in:
Michael Wright 2022-06-05 07:14:31 +02:00
parent 542d474d38
commit 94e321a6ff

View file

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