Remove negative float literal checks.

This commit is contained in:
daxpedda 2019-11-25 19:23:28 +01:00
parent cc35165f52
commit e46bedca3c
No known key found for this signature in database
GPG key ID: 43D62A3EA388E46F
2 changed files with 9 additions and 5 deletions

View file

@ -92,15 +92,15 @@ 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() {
if constant_simple(cx, cx.tables, expr).is_none() {
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() {
span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected");
self.expr_span = Some(expr.span);
}
}
},
_ => (),
}

View file

@ -55,6 +55,10 @@ fn main() {
f *= 2.0;
f /= 2.0;
// no error, overflows are checked by `overflowing_literals`
-1.;
-(-1.);
// No errors for the following items because they are constant expressions
enum Foo {
Bar = -2,