Skip to content

Commit a3ab512

Browse files
author
Michael Wright
committed
Fix collapsible_if error
1 parent 0c1ffc1 commit a3ab512

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

clippy_lints/src/formatting.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,19 @@ fn check_array(cx: &EarlyContext<'_>, expr: &ast::Expr) {
186186
if let ast::ExprKind::Array(ref array) = expr.node {
187187
for element in array {
188188
if let ast::ExprKind::Binary(ref op, ref lhs, _) = element.node {
189-
if has_unary_equivalent(op.node) {
190-
if !differing_macro_contexts(lhs.span, op.span) {
191-
let space_span = lhs.span.between(op.span);
192-
if let Some(space_snippet) = snippet_opt(cx, space_span) {
193-
let lint_span = lhs.span.with_lo(lhs.span.hi());
194-
if space_snippet.contains('\n') {
195-
span_note_and_lint(
196-
cx,
197-
POSSIBLE_MISSING_COMMA,
198-
lint_span,
199-
"possibly missing a comma here",
200-
lint_span,
201-
"to remove this lint, add a comma or write the expr in a single line",
202-
);
203-
}
189+
if has_unary_equivalent(op.node) && !differing_macro_contexts(lhs.span, op.span) {
190+
let space_span = lhs.span.between(op.span);
191+
if let Some(space_snippet) = snippet_opt(cx, space_span) {
192+
let lint_span = lhs.span.with_lo(lhs.span.hi());
193+
if space_snippet.contains('\n') {
194+
span_note_and_lint(
195+
cx,
196+
POSSIBLE_MISSING_COMMA,
197+
lint_span,
198+
"possibly missing a comma here",
199+
lint_span,
200+
"to remove this lint, add a comma or write the expr in a single line",
201+
);
204202
}
205203
}
206204
}

0 commit comments

Comments
 (0)