Skip to content

Commit 028e1c2

Browse files
committed
use let-chains
1 parent f04eb59 commit 028e1c2

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

clippy_lints/src/operators/modulo_arithmetic.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,10 @@ pub(super) fn check<'tcx>(
3434
}
3535

3636
fn used_in_comparison_with_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
37-
let Node::Expr(parent_expr) = cx.tcx.parent_hir_node(expr.hir_id) else {
38-
return false;
39-
};
40-
let ExprKind::Binary(op, lhs, rhs) = parent_expr.kind else {
41-
return false;
42-
};
43-
44-
if let BinOpKind::Eq | BinOpKind::Ne = op.node {
37+
if let Node::Expr(parent_expr) = cx.tcx.parent_hir_node(expr.hir_id)
38+
&& let ExprKind::Binary(op, lhs, rhs) = parent_expr.kind
39+
&& let BinOpKind::Eq | BinOpKind::Ne = op.node
40+
{
4541
let ecx = ConstEvalCtxt::new(cx);
4642
matches!(ecx.eval(lhs), Some(Constant::Int(0))) || matches!(ecx.eval(rhs), Some(Constant::Int(0)))
4743
} else {

0 commit comments

Comments
 (0)