File tree Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Expand file tree Collapse file tree 2 files changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -165,12 +165,6 @@ impl LateLintPass<'_> for Default {
165
165
let stmt = & block. stmts [ stmt_idx] ;
166
166
167
167
if let StmtKind :: Local ( preceding_local) = & stmt. kind {
168
- // filter out fields like `= Default::default()`, because the FRU already covers them
169
- let assigned_fields = assigned_fields
170
- . into_iter ( )
171
- . filter ( |( _, rhs) | !is_expr_default ( rhs, cx) )
172
- . collect :: < Vec < ( Symbol , & Expr < ' _ > ) > > ( ) ;
173
-
174
168
// if all fields of the struct are not assigned, add `.. Default::default()` to the suggestion.
175
169
let ext_with_default = !fields_of_type ( binding_type)
176
170
. iter ( )
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ error: field assignment outside of initializer for an instance created with Defa
53
53
LL | a.i = Default::default();
54
54
| ^^^^^^^^^^^^^^^^^^^^^^^^^
55
55
|
56
- note: consider initializing the variable with `A:: default()` and removing relevant reassignments
56
+ note: consider initializing the variable with `A { i: Default:: default(), ..Default::default() } ` and removing relevant reassignments
57
57
--> $DIR/field_reassign_with_default.rs:90:5
58
58
|
59
59
LL | let mut a: A = Default::default();
@@ -65,7 +65,7 @@ error: field assignment outside of initializer for an instance created with Defa
65
65
LL | a.i = Default::default();
66
66
| ^^^^^^^^^^^^^^^^^^^^^^^^^
67
67
|
68
- note: consider initializing the variable with `A { j: 45, .. Default::default() }` and removing relevant reassignments
68
+ note: consider initializing the variable with `A { i: Default::default(), j: 45 }` and removing relevant reassignments
69
69
--> $DIR/field_reassign_with_default.rs:94:5
70
70
|
71
71
LL | let mut a: A = Default::default();
You can’t perform that action at this time.
0 commit comments