Skip to content

Commit fa0a78b

Browse files
committed
removed lint for division/modulo for literal 0
1 parent e97602e commit fa0a78b

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

clippy_lints/src/arithmetic.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
9090
if l_ty.peel_refs().is_integral() && r_ty.peel_refs().is_integral() {
9191
match op.node {
9292
hir::BinOpKind::Div | hir::BinOpKind::Rem => match &r.kind {
93-
hir::ExprKind::Lit(lit) => {
94-
if let rustc_ast::ast::LitKind::Int(0, _) = lit.node {
95-
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
96-
self.expr_span = Some(expr.span);
97-
}
98-
},
93+
hir::ExprKind::Lit(_lit) => (),
9994
hir::ExprKind::Unary(hir::UnOp::UnNeg, expr) => {
10095
if let hir::ExprKind::Lit(lit) = &expr.kind {
10196
if let rustc_ast::ast::LitKind::Int(1, _) = lit.node {

tests/ui/integer_arithmetic.stderr

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ error: integer arithmetic detected
7575
LL | i *= 2;
7676
| ^^^^^^
7777

78-
error: integer arithmetic detected
79-
--> $DIR/integer_arithmetic.rs:37:5
80-
|
81-
LL | i /= 0;
82-
| ^^^^^^
83-
8478
error: integer arithmetic detected
8579
--> $DIR/integer_arithmetic.rs:38:11
8680
|
@@ -99,12 +93,6 @@ error: integer arithmetic detected
9993
LL | i /= var2;
10094
| ^^^^^^^^^
10195

102-
error: integer arithmetic detected
103-
--> $DIR/integer_arithmetic.rs:42:5
104-
|
105-
LL | i %= 0;
106-
| ^^^^^^
107-
10896
error: integer arithmetic detected
10997
--> $DIR/integer_arithmetic.rs:43:11
11098
|
@@ -177,5 +165,5 @@ error: integer arithmetic detected
177165
LL | (&x + &y)
178166
| ^^^^^^^^^
179167

180-
error: aborting due to 29 previous errors
168+
error: aborting due to 27 previous errors
181169

0 commit comments

Comments
 (0)