diff options
| author | Ada Alakbarova <ada.alakbarova@proton.me> | 2025-05-26 00:23:51 +0200 |
|---|---|---|
| committer | Ada Alakbarova <ada.alakbarova@proton.me> | 2025-05-26 00:32:45 +0200 |
| commit | 028e1c28c90e6ac5294306a5ec97f698b5311107 (patch) | |
| tree | 606edc18ac374bc9a83030b9df062f2d4aeca8c8 /clippy_lints | |
| parent | f04eb5984e779b9c5df79a26b8f94ab590409a9f (diff) | |
| download | rust-028e1c28c90e6ac5294306a5ec97f698b5311107.tar.gz rust-028e1c28c90e6ac5294306a5ec97f698b5311107.zip | |
use let-chains
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/operators/modulo_arithmetic.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/clippy_lints/src/operators/modulo_arithmetic.rs b/clippy_lints/src/operators/modulo_arithmetic.rs index 44ac2a17e7e..b79461663d7 100644 --- a/clippy_lints/src/operators/modulo_arithmetic.rs +++ b/clippy_lints/src/operators/modulo_arithmetic.rs @@ -34,14 +34,10 @@ pub(super) fn check<'tcx>( } fn used_in_comparison_with_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - let Node::Expr(parent_expr) = cx.tcx.parent_hir_node(expr.hir_id) else { - return false; - }; - let ExprKind::Binary(op, lhs, rhs) = parent_expr.kind else { - return false; - }; - - if let BinOpKind::Eq | BinOpKind::Ne = op.node { + if let Node::Expr(parent_expr) = cx.tcx.parent_hir_node(expr.hir_id) + && let ExprKind::Binary(op, lhs, rhs) = parent_expr.kind + && let BinOpKind::Eq | BinOpKind::Ne = op.node + { let ecx = ConstEvalCtxt::new(cx); matches!(ecx.eval(lhs), Some(Constant::Int(0))) || matches!(ecx.eval(rhs), Some(Constant::Int(0))) } else { |
