Skip to content

Commit 2a1a80d

Browse files
author
Michael Wright
committed
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.
1 parent 94e321a commit 2a1a80d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clippy_lints/src/needless_late_init.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ fn assignment_suggestions<'tcx>(
185185

186186
let suggestions = assignments
187187
.iter()
188-
.map(|assignment| assignment.span.until(assignment.rhs_span))
189-
.chain(
190-
assignments
191-
.iter()
192-
.map(|assignment| assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi())),
193-
)
188+
.flat_map(|assignment| {
189+
[
190+
assignment.span.until(assignment.rhs_span),
191+
assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()),
192+
]
193+
})
194194
.map(|span| Some((span, String::new())))
195195
.collect::<Option<Vec<(Span, String)>>>()?;
196196

0 commit comments

Comments
 (0)