Skip to content

Commit 7853608

Browse files
committed
add comments
1 parent aab7aef commit 7853608

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler/rustc_lint/src/default_could_be_derived.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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
};

0 commit comments

Comments
 (0)