@@ -771,6 +771,7 @@ declare_clippy_lint! {
771
771
pub struct Operators {
772
772
arithmetic_context : numeric_arithmetic:: Context ,
773
773
verbose_bit_mask_threshold : u64 ,
774
+ modulo_arithmetic_allow_comparison_to_zero : bool ,
774
775
}
775
776
impl_lint_pass ! ( Operators => [
776
777
ABSURD_EXTREME_COMPARISONS ,
@@ -801,10 +802,11 @@ impl_lint_pass!(Operators => [
801
802
SELF_ASSIGNMENT ,
802
803
] ) ;
803
804
impl Operators {
804
- pub fn new ( verbose_bit_mask_threshold : u64 ) -> Self {
805
+ pub fn new ( verbose_bit_mask_threshold : u64 , modulo_arithmetic_allow_comparison_to_zero : bool ) -> Self {
805
806
Self {
806
807
arithmetic_context : numeric_arithmetic:: Context :: default ( ) ,
807
808
verbose_bit_mask_threshold,
809
+ modulo_arithmetic_allow_comparison_to_zero,
808
810
}
809
811
}
810
812
}
@@ -835,12 +837,19 @@ impl<'tcx> LateLintPass<'tcx> for Operators {
835
837
cmp_owned:: check ( cx, op. node , lhs, rhs) ;
836
838
float_cmp:: check ( cx, e, op. node , lhs, rhs) ;
837
839
modulo_one:: check ( cx, e, op. node , rhs) ;
838
- modulo_arithmetic:: check ( cx, e, op. node , lhs, rhs) ;
840
+ modulo_arithmetic:: check (
841
+ cx,
842
+ e,
843
+ op. node ,
844
+ lhs,
845
+ rhs,
846
+ self . modulo_arithmetic_allow_comparison_to_zero ,
847
+ ) ;
839
848
} ,
840
849
ExprKind :: AssignOp ( op, lhs, rhs) => {
841
850
self . arithmetic_context . check_binary ( cx, e, op. node , lhs, rhs) ;
842
851
misrefactored_assign_op:: check ( cx, e, op. node , lhs, rhs) ;
843
- modulo_arithmetic:: check ( cx, e, op. node , lhs, rhs) ;
852
+ modulo_arithmetic:: check ( cx, e, op. node , lhs, rhs, false ) ;
844
853
} ,
845
854
ExprKind :: Assign ( lhs, rhs, _) => {
846
855
assign_op_pattern:: check ( cx, e, lhs, rhs) ;
0 commit comments