Skip to content

Commit 7dbf315

Browse files
authored
Merge pull request #2509 from ordovicia/redundant_field_names_range
Remove unused variable and a minor refactoring
2 parents 05f92b8 + 8e40676 commit 7dbf315

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

clippy_lints/src/redundant_field_names.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ impl LintPass for RedundantFieldNames {
3636

3737
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames {
3838
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
39-
if let ExprStruct(ref path, ref fields, _) = expr.node {
39+
// Do not care about range expressions.
40+
// They could have redundant field name when desugared to structs.
41+
// e.g. `start..end` is desugared to `Range { start: start, end: end }`
42+
if is_range_expression(expr.span) {
43+
return;
44+
}
45+
46+
if let ExprStruct(_, ref fields, _) = expr.node {
4047
for field in fields {
4148
let name = field.name.node;
4249

43-
// Do not care about range expressions.
44-
// They could have redundant field name when desugared to structs.
45-
// e.g. `start..end` is desugared to `Range { start: start, end: end }`
46-
if is_range_expression(expr.span) {
47-
continue;
48-
}
49-
5050
if match_var(&field.expr, name) && !field.is_shorthand {
5151
span_lint_and_sugg (
5252
cx,

0 commit comments

Comments
 (0)