]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_lints/src/operators/self_assignment.rs
Merge branch 'master' of http://localhost:8000/rust-lang/rust.git:at_commit=75dd959a3...
[rust.git] / src / tools / clippy / clippy_lints / src / operators / self_assignment.rs
1 use clippy_utils::diagnostics::span_lint;
2 use clippy_utils::eq_expr_value;
3 use clippy_utils::source::snippet;
4 use rustc_hir::Expr;
5 use rustc_lint::LateContext;
6
7 use super::SELF_ASSIGNMENT;
8
9 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, lhs: &'tcx Expr<'_>, rhs: &'tcx Expr<'_>) {
10     if eq_expr_value(cx, lhs, rhs) {
11         let lhs = snippet(cx, lhs.span, "<lhs>");
12         let rhs = snippet(cx, rhs.span, "<rhs>");
13         span_lint(
14             cx,
15             SELF_ASSIGNMENT,
16             e.span,
17             &format!("self-assignment of `{rhs}` to `{lhs}`"),
18         );
19     }
20 }