Remove negative float literal checks.
This commit is contained in:
parent
cc35165f52
commit
e46bedca3c
2 changed files with 9 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue