1 use clippy_utils::diagnostics::span_lint;
2 use clippy_utils::{is_integer_const, unsext};
3 use rustc_hir::{BinOpKind, Expr};
4 use rustc_lint::LateContext;
9 pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, op: BinOpKind, right: &Expr<'_>) {
10 if op == BinOpKind::Rem {
11 if is_integer_const(cx, right, 1) {
12 span_lint(cx, MODULO_ONE, expr.span, "any number modulo 1 will be 0");
15 if let ty::Int(ity) = cx.typeck_results().expr_ty(right).kind() {
16 if is_integer_const(cx, right, unsext(cx.tcx, -1, *ity)) {
21 "any number modulo -1 will panic/overflow or result in 0",