1
- use super :: { FLOAT_ARITHMETIC , INTEGER_ARITHMETIC } ;
1
+ use super :: FLOAT_ARITHMETIC ;
2
2
use clippy_utils:: consts:: constant_simple;
3
3
use clippy_utils:: diagnostics:: span_lint;
4
- use clippy_utils:: is_from_proc_macro;
5
- use clippy_utils:: is_integer_literal;
6
4
use rustc_hir as hir;
7
5
use rustc_lint:: LateContext ;
8
6
use rustc_span:: source_map:: Span ;
@@ -45,31 +43,8 @@ impl Context {
45
43
_ => ( ) ,
46
44
}
47
45
48
- let ( l_ty, r_ty) = ( cx. typeck_results ( ) . expr_ty ( l) , cx. typeck_results ( ) . expr_ty ( r) ) ;
49
- if l_ty. peel_refs ( ) . is_integral ( ) && r_ty. peel_refs ( ) . is_integral ( ) {
50
- if is_from_proc_macro ( cx, expr) {
51
- return ;
52
- }
53
- match op {
54
- hir:: BinOpKind :: Div | hir:: BinOpKind :: Rem => match & r. kind {
55
- hir:: ExprKind :: Lit ( _lit) => ( ) ,
56
- hir:: ExprKind :: Unary ( hir:: UnOp :: Neg , expr) => {
57
- if is_integer_literal ( expr, 1 ) {
58
- span_lint ( cx, INTEGER_ARITHMETIC , expr. span , "integer arithmetic detected" ) ;
59
- self . expr_id = Some ( expr. hir_id ) ;
60
- }
61
- } ,
62
- _ => {
63
- span_lint ( cx, INTEGER_ARITHMETIC , expr. span , "integer arithmetic detected" ) ;
64
- self . expr_id = Some ( expr. hir_id ) ;
65
- } ,
66
- } ,
67
- _ => {
68
- span_lint ( cx, INTEGER_ARITHMETIC , expr. span , "integer arithmetic detected" ) ;
69
- self . expr_id = Some ( expr. hir_id ) ;
70
- } ,
71
- }
72
- } else if r_ty. peel_refs ( ) . is_floating_point ( ) && r_ty. peel_refs ( ) . is_floating_point ( ) {
46
+ let ( _, r_ty) = ( cx. typeck_results ( ) . expr_ty ( l) , cx. typeck_results ( ) . expr_ty ( r) ) ;
47
+ if r_ty. peel_refs ( ) . is_floating_point ( ) && r_ty. peel_refs ( ) . is_floating_point ( ) {
73
48
span_lint ( cx, FLOAT_ARITHMETIC , expr. span , "floating-point arithmetic detected" ) ;
74
49
self . expr_id = Some ( expr. hir_id ) ;
75
50
}
@@ -81,13 +56,7 @@ impl Context {
81
56
}
82
57
let ty = cx. typeck_results ( ) . expr_ty ( arg) ;
83
58
if constant_simple ( cx, cx. typeck_results ( ) , expr) . is_none ( ) {
84
- if ty. is_integral ( ) {
85
- if is_from_proc_macro ( cx, expr) {
86
- return ;
87
- }
88
- span_lint ( cx, INTEGER_ARITHMETIC , expr. span , "integer arithmetic detected" ) ;
89
- self . expr_id = Some ( expr. hir_id ) ;
90
- } else if ty. is_floating_point ( ) {
59
+ if ty. is_floating_point ( ) {
91
60
span_lint ( cx, FLOAT_ARITHMETIC , expr. span , "floating-point arithmetic detected" ) ;
92
61
self . expr_id = Some ( expr. hir_id ) ;
93
62
}
0 commit comments