Skip to content

Commit 8e40676

Browse files
committed
Move call of is_range_expression() outside of blocks
1 parent e13dcd2 commit 8e40676

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: clippy_lints/src/redundant_field_names.rs

+7-7
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+
// 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+
3946
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)