use clippy_utils::source::snippet_opt;
use if_chain::if_chain;
use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
-use rustc_lint::{EarlyContext, EarlyLintPass};
+use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
/// ```rust,ignore
/// a =- 42; // confusing, should it be `a -= 42` or `a = -42`?
/// ```
+ #[clippy::version = "pre 1.29.0"]
pub SUSPICIOUS_ASSIGNMENT_FORMATTING,
suspicious,
"suspicious formatting of `*=`, `-=` or `!=`"
/// if foo &&! bar { // this should be `foo && !bar` but looks like a different operator
/// }
/// ```
+ #[clippy::version = "1.40.0"]
pub SUSPICIOUS_UNARY_OP_FORMATTING,
suspicious,
"suspicious formatting of unary `-` or `!` on the RHS of a BinOp"
/// if bar { // this is the `else` block of the previous `if`, but should it be?
/// }
/// ```
+ #[clippy::version = "pre 1.29.0"]
pub SUSPICIOUS_ELSE_FORMATTING,
suspicious,
"suspicious formatting of `else`"
/// -4, -5, -6
/// ];
/// ```
+ #[clippy::version = "pre 1.29.0"]
pub POSSIBLE_MISSING_COMMA,
correctness,
"possible missing comma in array"
if let ExprKind::If(_, then, Some(else_)) = &expr.kind;
if is_block(else_) || is_if(else_);
if !differing_macro_contexts(then.span, else_.span);
- if !then.span.from_expansion() && !in_external_macro(cx.sess, expr.span);
+ if !then.span.from_expansion() && !in_external_macro(cx.sess(), expr.span);
// workaround for rust-lang/rust#43081
if expr.span.lo().0 != 0 && expr.span.hi().0 != 0;
}
fn indentation(cx: &EarlyContext<'_>, span: Span) -> usize {
- cx.sess.source_map().lookup_char_pos(span.lo()).col.0
+ cx.sess().source_map().lookup_char_pos(span.lo()).col.0
}
/// Implementation of the `POSSIBLE_MISSING_COMMA` lint for array