@@ -61,40 +61,38 @@ impl<'tcx> LateLintPass<'tcx> for ManualDivCeil {
6161 let mut applicability = Applicability :: MachineApplicable ;
6262
6363 if let ExprKind :: Binary ( div_op, div_lhs, div_rhs) = expr. kind
64+ && div_op. node == BinOpKind :: Div
6465 && check_int_ty_and_feature ( cx, div_lhs)
6566 && check_int_ty_and_feature ( cx, div_rhs)
66- && div_op . node == BinOpKind :: Div
67+ && let ExprKind :: Binary ( inner_op , inner_lhs , inner_rhs ) = div_lhs . kind
6768 {
6869 // (x + (y - 1)) / y
69- if let ExprKind :: Binary ( add_op, add_lhs, add_rhs) = div_lhs. kind
70- && add_op. node == BinOpKind :: Add
71- && let ExprKind :: Binary ( sub_op, sub_lhs, sub_rhs) = add_rhs. kind
70+ if let ExprKind :: Binary ( sub_op, sub_lhs, sub_rhs) = inner_rhs. kind
71+ && inner_op. node == BinOpKind :: Add
7272 && sub_op. node == BinOpKind :: Sub
7373 && check_literal ( sub_rhs)
7474 && check_eq_expr ( cx, sub_lhs, div_rhs)
7575 {
76- build_suggestion ( cx, expr, add_lhs , div_rhs, & mut applicability) ;
76+ build_suggestion ( cx, expr, inner_lhs , div_rhs, & mut applicability) ;
7777 return ;
7878 }
7979
8080 // ((y - 1) + x) / y
81- if let ExprKind :: Binary ( add_op, add_lhs, add_rhs) = div_lhs. kind
82- && add_op. node == BinOpKind :: Add
83- && let ExprKind :: Binary ( sub_op, sub_lhs, sub_rhs) = add_lhs. kind
81+ if let ExprKind :: Binary ( sub_op, sub_lhs, sub_rhs) = inner_lhs. kind
82+ && inner_op. node == BinOpKind :: Add
8483 && sub_op. node == BinOpKind :: Sub
8584 && check_literal ( sub_rhs)
8685 && check_eq_expr ( cx, sub_lhs, div_rhs)
8786 {
88- build_suggestion ( cx, expr, add_rhs , div_rhs, & mut applicability) ;
87+ build_suggestion ( cx, expr, inner_rhs , div_rhs, & mut applicability) ;
8988 return ;
9089 }
9190
9291 // (x + y - 1) / y
93- if let ExprKind :: Binary ( sub_op, sub_lhs, sub_rhs) = div_lhs. kind
94- && sub_op. node == BinOpKind :: Sub
95- && let ExprKind :: Binary ( add_op, add_lhs, add_rhs) = sub_lhs. kind
92+ if let ExprKind :: Binary ( add_op, add_lhs, add_rhs) = inner_lhs. kind
93+ && inner_op. node == BinOpKind :: Sub
9694 && add_op. node == BinOpKind :: Add
97- && check_literal ( sub_rhs )
95+ && check_literal ( inner_rhs )
9896 && check_eq_expr ( cx, add_rhs, div_rhs)
9997 {
10098 build_suggestion ( cx, expr, add_lhs, div_rhs, & mut applicability) ;
0 commit comments