- span_note_and_lint(cx,
- SUSPICIOUS_ELSE_FORMATTING,
- else_span,
- "this is an `else if` but the formatting might hide it",
- else_span,
- "to remove this lint, remove the `else` or remove the new line between `else` \
- and `if`");
+ span_note_and_lint(
+ cx,
+ SUSPICIOUS_ELSE_FORMATTING,
+ else_span,
+ "this is an `else if` but the formatting might hide it",
+ else_span,
+ "to remove this lint, remove the `else` or remove the new line between `else` \
+ and `if`",
+ );
+ }
+ }
+ }
+ }
+}
+
+/// Implementation of the `POSSIBLE_MISSING_COMMA` lint for array
+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 !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",
+ );
+ }
+ }