File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -263,14 +263,21 @@ impl<'tcx> LateLintPass<'tcx> for DefaultCouldBeDerived {
263
263
if idx > 0
264
264
&& let Some ( prev_field) = fields. get ( idx - 1 )
265
265
{
266
+ // Span covering the current field *and* the prior `,` for the prior field.
266
267
removals. push ( prev_field. span . shrink_to_hi ( ) . to ( field. span ) ) ;
267
268
} else if let Some ( next_field) = fields. get ( idx + 1 ) {
269
+ // Span for the current field *and* its trailing comma, all the way to the
270
+ // next field.
268
271
removals. push ( field. span . until ( next_field. span ) ) ;
269
272
} else if idx + 1 == fields. len ( )
270
273
&& let hir:: StructTailExpr :: DefaultFields ( span) = tail
271
274
{
275
+ // This is the last field *and* there's a `, ..`. This span covers this
276
+ // entire field and the `, ..`.
272
277
removals. push ( field. span . until ( span) ) ;
273
278
} else {
279
+ // The span for the current field, without any commas. This is a fallback
280
+ // that shouldn't really trigger.
274
281
removals. push ( field. span ) ;
275
282
}
276
283
} ;
You can’t perform that action at this time.
0 commit comments