From 8e406760a4ee4bf0b0db5d0a14b8e5dca292d2d9 Mon Sep 17 00:00:00 2001 From: Hidehito Yabuuchi Date: Mon, 5 Mar 2018 18:20:27 +0900 Subject: [PATCH] Move call of `is_range_expression()` outside of blocks --- clippy_lints/src/redundant_field_names.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index 1f67dd80baa0..6775129f9df4 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -36,17 +36,17 @@ impl LintPass for RedundantFieldNames { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantFieldNames { fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) { + // Do not care about range expressions. + // They could have redundant field name when desugared to structs. + // e.g. `start..end` is desugared to `Range { start: start, end: end }` + if is_range_expression(expr.span) { + return; + } + if let ExprStruct(_, ref fields, _) = expr.node { for field in fields { let name = field.name.node; - // Do not care about range expressions. - // They could have redundant field name when desugared to structs. - // e.g. `start..end` is desugared to `Range { start: start, end: end }` - if is_range_expression(expr.span) { - continue; - } - if match_var(&field.expr, name) && !field.is_shorthand { span_lint_and_sugg ( cx,