2021-05-04 03:20:22 -05:00
|
|
|
use clippy_utils::diagnostics::span_lint;
|
|
|
|
use rustc_ast::ast::{Expr, ExprKind, UnOp};
|
|
|
|
use rustc_lint::EarlyContext;
|
|
|
|
|
|
|
|
use super::DOUBLE_NEG;
|
|
|
|
|
|
|
|
pub(super) fn check(cx: &EarlyContext<'_>, expr: &Expr) {
|
2021-09-22 09:13:54 -05:00
|
|
|
if let ExprKind::Unary(UnOp::Neg, ref inner) = expr.kind {
|
|
|
|
if let ExprKind::Unary(UnOp::Neg, _) = inner.kind {
|
|
|
|
span_lint(
|
|
|
|
cx,
|
|
|
|
DOUBLE_NEG,
|
|
|
|
expr.span,
|
|
|
|
"`--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op",
|
|
|
|
);
|
|
|
|
}
|
2021-05-04 03:20:22 -05:00
|
|
|
}
|
|
|
|
}
|