Skip to content

Commit

Permalink
Move call of is_range_expression() outside of blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ordovicia committed Mar 5, 2018
1 parent e13dcd2 commit 8e40676
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions clippy_lints/src/redundant_field_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8e40676

Please sign in to comment.