about summary refs log tree commit diff
diff options
context:
space:
mode:
authordaxpedda <daxpedda@users.noreply.github.com>2019-01-20 14:18:31 +0100
committerdaxpedda <daxpedda@users.noreply.github.com>2019-01-20 14:18:31 +0100
commit0555ca1c2d98e74d748922c5a60d42174dab9675 (patch)
treef103a79fbc0edfd2b2ff21c48eba19e6aa6c4833
parente648adf0866a1cea7db6ce2d33ea86e442f25377 (diff)
downloadrust-0555ca1c2d98e74d748922c5a60d42174dab9675.tar.gz
rust-0555ca1c2d98e74d748922c5a60d42174dab9675.zip
Remove negative integer literal checks.
-rw-r--r--clippy_lints/src/arithmetic.rs6
-rw-r--r--tests/ui/arithmetic.rs2
-rw-r--r--tests/ui/arithmetic.stderr8
3 files changed, 3 insertions, 13 deletions
diff --git a/clippy_lints/src/arithmetic.rs b/clippy_lints/src/arithmetic.rs
index d133a583f02..4ad2c43e083 100644
--- a/clippy_lints/src/arithmetic.rs
+++ b/clippy_lints/src/arithmetic.rs
@@ -92,11 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
                 }
             },
             hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
-                let ty = cx.tables.expr_ty(arg);
-                if ty.is_integral() {
-                    span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
-                    self.expr_span = Some(expr.span);
-                } else if ty.is_floating_point() {
+                if cx.tables.expr_ty(arg).is_floating_point() {
                     span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected");
                     self.expr_span = Some(expr.span);
                 }
diff --git a/tests/ui/arithmetic.rs b/tests/ui/arithmetic.rs
index 874604889b9..5e9f8d41a16 100644
--- a/tests/ui/arithmetic.rs
+++ b/tests/ui/arithmetic.rs
@@ -15,7 +15,7 @@ fn main() {
     1 %
     i / 2; // no error, this is part of the expression in the preceding line
     i - 2 + 2 - i;
-    -i;
+    -i; // no error, overflows are checked by `overflowing_literals`
 
     i & 1; // no wrapping
     i | 1;
diff --git a/tests/ui/arithmetic.stderr b/tests/ui/arithmetic.stderr
index c9bb68f857c..df441e4d3f8 100644
--- a/tests/ui/arithmetic.stderr
+++ b/tests/ui/arithmetic.stderr
@@ -25,12 +25,6 @@ error: integer arithmetic detected
 LL |     i - 2 + 2 - i;
    |     ^^^^^^^^^^^^^
 
-error: integer arithmetic detected
-  --> $DIR/arithmetic.rs:18:5
-   |
-LL |     -i;
-   |     ^^
-
 error: floating-point arithmetic detected
   --> $DIR/arithmetic.rs:28:5
    |
@@ -69,5 +63,5 @@ error: floating-point arithmetic detected
 LL |     -f;
    |     ^^
 
-error: aborting due to 11 previous errors
+error: aborting due to 10 previous errors