Skip to content

Commit 94e321a

Browse files
author
Michael Wright
committed
needless_late_init refactoring
Remove duplication in creating suggestions by first mapping assignments to spans and then suggestions.
1 parent 542d474 commit 94e321a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

clippy_lints/src/needless_late_init.rs

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

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

197197
match suggestions.len() {

0 commit comments

Comments
 (0)