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 {
263263 if idx > 0
264264 && let Some ( prev_field) = fields. get ( idx - 1 )
265265 {
266+ // Span covering the current field *and* the prior `,` for the prior field.
266267 removals. push ( prev_field. span . shrink_to_hi ( ) . to ( field. span ) ) ;
267268 } 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.
268271 removals. push ( field. span . until ( next_field. span ) ) ;
269272 } else if idx + 1 == fields. len ( )
270273 && let hir:: StructTailExpr :: DefaultFields ( span) = tail
271274 {
275+ // This is the last field *and* there's a `, ..`. This span covers this
276+ // entire field and the `, ..`.
272277 removals. push ( field. span . until ( span) ) ;
273278 } else {
279+ // The span for the current field, without any commas. This is a fallback
280+ // that shouldn't really trigger.
274281 removals. push ( field. span ) ;
275282 }
276283 } ;
You can’t perform that action at this time.
0 commit comments