/// -1
/// };
/// ```
- #[clippy::version = "1.58.0"]
+ #[clippy::version = "1.59.0"]
pub NEEDLESS_LATE_INIT,
style,
"late initializations that can be replaced by a `let` statement with an initializer"
let suggestions = assignments
.iter()
- .map(|assignment| Some((assignment.span.until(assignment.rhs_span), String::new())))
- .chain(assignments.iter().map(|assignment| {
- Some((
+ .flat_map(|assignment| {
+ [
+ assignment.span.until(assignment.rhs_span),
assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()),
- String::new(),
- ))
- }))
- .collect::<Option<Vec<(Span, String)>>>()?;
+ ]
+ })
+ .map(|span| (span, String::new()))
+ .collect::<Vec<(Span, String)>>();
match suggestions.len() {
// All of `exprs` are never types
diag.tool_only_span_suggestion(
local_stmt.span,
"remove the local",
- String::new(),
+ "",
Applicability::MachineApplicable,
);
diag.span_suggestion(
usage.stmt.span.shrink_to_hi(),
"add a semicolon after the `if` expression",
- ";".to_string(),
+ ";",
applicability,
);
}
diag.span_suggestion(
usage.stmt.span.shrink_to_hi(),
"add a semicolon after the `match` expression",
- ";".to_string(),
+ ";",
applicability,
);
}