Skip to content

Commit 0555ca1

Browse files
committed
Remove negative integer literal checks.
1 parent e648adf commit 0555ca1

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

clippy_lints/src/arithmetic.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
9292
}
9393
},
9494
hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
95-
let ty = cx.tables.expr_ty(arg);
96-
if ty.is_integral() {
97-
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
98-
self.expr_span = Some(expr.span);
99-
} else if ty.is_floating_point() {
95+
if cx.tables.expr_ty(arg).is_floating_point() {
10096
span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected");
10197
self.expr_span = Some(expr.span);
10298
}

tests/ui/arithmetic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn main() {
1515
1 %
1616
i / 2; // no error, this is part of the expression in the preceding line
1717
i - 2 + 2 - i;
18-
-i;
18+
-i; // no error, overflows are checked by `overflowing_literals`
1919

2020
i & 1; // no wrapping
2121
i | 1;

tests/ui/arithmetic.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ error: integer arithmetic detected
2525
LL | i - 2 + 2 - i;
2626
| ^^^^^^^^^^^^^
2727

28-
error: integer arithmetic detected
29-
--> $DIR/arithmetic.rs:18:5
30-
|
31-
LL | -i;
32-
| ^^
33-
3428
error: floating-point arithmetic detected
3529
--> $DIR/arithmetic.rs:28:5
3630
|
@@ -69,5 +63,5 @@ error: floating-point arithmetic detected
6963
LL | -f;
7064
| ^^
7165

72-
error: aborting due to 11 previous errors
66+
error: aborting due to 10 previous errors
7367

0 commit comments

Comments
 (0)