|
1 |
| -use crate::utils::{snippet, span_lint_and_note, match_path_ast, paths}; |
| 1 | +use crate::utils::{match_path_ast, paths, snippet, span_lint_and_note}; |
2 | 2 | use if_chain::if_chain;
|
3 | 3 | use rustc_ast::ast::{Block, ExprKind, PatKind, StmtKind};
|
4 | 4 | use rustc_lint::{EarlyContext, EarlyLintPass};
|
@@ -93,7 +93,7 @@ impl EarlyLintPass for FieldReassignWithDefault {
|
93 | 93 | // statement kinds other than `StmtKind::Local` are valid, because they cannot
|
94 | 94 | // shadow a binding
|
95 | 95 | else {
|
96 |
| - if_chain!{ |
| 96 | + if_chain! { |
97 | 97 | // only take assignments
|
98 | 98 | if let StmtKind::Semi(ref later_expr) = post_defassign_stmt.kind;
|
99 | 99 | if let ExprKind::Assign(ref assign_lhs, ref assign_rhs, _) = later_expr.kind;
|
@@ -127,7 +127,11 @@ impl EarlyLintPass for FieldReassignWithDefault {
|
127 | 127 | if let Some(ty) = &preceding_local.ty {
|
128 | 128 | let ty_snippet = snippet(cx, ty.span, "_");
|
129 | 129 |
|
130 |
| - let field_list = assigned_fields.into_iter().map(|(field, value)| format!("{}: {}", field, value)).collect::<Vec<String>>().join(", "); |
| 130 | + let field_list = assigned_fields |
| 131 | + .into_iter() |
| 132 | + .map(|(field, value)| format!("{}: {}", field, value)) |
| 133 | + .collect::<Vec<String>>() |
| 134 | + .join(", "); |
131 | 135 |
|
132 | 136 | let sugg = format!("{} {{ {}, ..Default::default() }}", ty_snippet, field_list);
|
133 | 137 |
|
|
0 commit comments