@@ -771,6 +771,7 @@ declare_clippy_lint! {
771771pub struct Operators {
772772 arithmetic_context : numeric_arithmetic:: Context ,
773773 verbose_bit_mask_threshold : u64 ,
774+ modulo_arithmetic_allow_comparison_to_zero : bool ,
774775}
775776impl_lint_pass ! ( Operators => [
776777 ABSURD_EXTREME_COMPARISONS ,
@@ -801,10 +802,11 @@ impl_lint_pass!(Operators => [
801802 SELF_ASSIGNMENT ,
802803] ) ;
803804impl 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 {
805806 Self {
806807 arithmetic_context : numeric_arithmetic:: Context :: default ( ) ,
807808 verbose_bit_mask_threshold,
809+ modulo_arithmetic_allow_comparison_to_zero,
808810 }
809811 }
810812}
@@ -835,12 +837,19 @@ impl<'tcx> LateLintPass<'tcx> for Operators {
835837 cmp_owned:: check ( cx, op. node , lhs, rhs) ;
836838 float_cmp:: check ( cx, e, op. node , lhs, rhs) ;
837839 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+ ) ;
839848 } ,
840849 ExprKind :: AssignOp ( op, lhs, rhs) => {
841850 self . arithmetic_context . check_binary ( cx, e, op. node , lhs, rhs) ;
842851 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 ) ;
844853 } ,
845854 ExprKind :: Assign ( lhs, rhs, _) => {
846855 assign_op_pattern:: check ( cx, e, lhs, rhs) ;
0 commit comments