diff options
| author | Michael Wright <mikerite@lavabit.com> | 2018-11-04 10:48:24 +0200 |
|---|---|---|
| committer | Michael Wright <mikerite@lavabit.com> | 2018-11-04 10:48:24 +0200 |
| commit | a3ab512576c77e08646ba731e8906a02983da2c8 (patch) | |
| tree | 06ef7616d5cb3816bcd837422ead833b5c4fb22f | |
| parent | 0c1ffc1d1fdfd73bf326d1e7a886f59367374dc3 (diff) | |
| download | rust-a3ab512576c77e08646ba731e8906a02983da2c8.tar.gz rust-a3ab512576c77e08646ba731e8906a02983da2c8.zip | |
Fix `collapsible_if` error
| -rw-r--r-- | clippy_lints/src/formatting.rs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/clippy_lints/src/formatting.rs b/clippy_lints/src/formatting.rs index 8649834e267..69aabcb7949 100644 --- a/clippy_lints/src/formatting.rs +++ b/clippy_lints/src/formatting.rs @@ -186,21 +186,19 @@ fn check_array(cx: &EarlyContext<'_>, expr: &ast::Expr) { if let ast::ExprKind::Array(ref array) = expr.node { for element in array { if let ast::ExprKind::Binary(ref op, ref lhs, _) = element.node { - if has_unary_equivalent(op.node) { - if !differing_macro_contexts(lhs.span, op.span) { - let space_span = lhs.span.between(op.span); - if let Some(space_snippet) = snippet_opt(cx, space_span) { - let lint_span = lhs.span.with_lo(lhs.span.hi()); - if space_snippet.contains('\n') { - span_note_and_lint( - cx, - POSSIBLE_MISSING_COMMA, - lint_span, - "possibly missing a comma here", - lint_span, - "to remove this lint, add a comma or write the expr in a single line", - ); - } + if has_unary_equivalent(op.node) && !differing_macro_contexts(lhs.span, op.span) { + let space_span = lhs.span.between(op.span); + if let Some(space_snippet) = snippet_opt(cx, space_span) { + let lint_span = lhs.span.with_lo(lhs.span.hi()); + if space_snippet.contains('\n') { + span_note_and_lint( + cx, + POSSIBLE_MISSING_COMMA, + lint_span, + "possibly missing a comma here", + lint_span, + "to remove this lint, add a comma or write the expr in a single line", + ); } } } |
