]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_lints/src/misc_early/double_neg.rs
Rollup merge of #104420 - TethysSvensson:master, r=JohnTitor
[rust.git] / src / tools / clippy / clippy_lints / src / misc_early / double_neg.rs
1 use clippy_utils::diagnostics::span_lint;
2 use rustc_ast::ast::{Expr, ExprKind, UnOp};
3 use rustc_lint::EarlyContext;
4
5 use super::DOUBLE_NEG;
6
7 pub(super) fn check(cx: &EarlyContext<'_>, expr: &Expr) {
8     if let ExprKind::Unary(UnOp::Neg, ref inner) = expr.kind {
9         if let ExprKind::Unary(UnOp::Neg, _) = inner.kind {
10             span_lint(
11                 cx,
12                 DOUBLE_NEG,
13                 expr.span,
14                 "`--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op",
15             );
16         }
17     }
18 }