Skip to content

Commit 5e4f092

Browse files
committed
use let chains in bit_mask.rs
1 parent 4667198 commit 5e4f092

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

clippy_lints/src/bit_mask.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use clippy_utils::consts::{constant, Constant};
22
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
33
use clippy_utils::sugg::Sugg;
4-
use if_chain::if_chain;
54
use rustc_ast::ast::LitKind;
65
use rustc_errors::Applicability;
76
use rustc_hir::{BinOpKind, Expr, ExprKind};
@@ -130,32 +129,33 @@ impl<'tcx> LateLintPass<'tcx> for BitMask {
130129
}
131130
}
132131
}
133-
if_chain! {
134-
if let ExprKind::Binary(op, left, right) = &e.kind;
135-
if BinOpKind::Eq == op.node;
136-
if let ExprKind::Binary(op1, left1, right1) = &left.kind;
137-
if BinOpKind::BitAnd == op1.node;
138-
if let ExprKind::Lit(lit) = &right1.kind;
139-
if let LitKind::Int(n, _) = lit.node;
140-
if let ExprKind::Lit(lit1) = &right.kind;
141-
if let LitKind::Int(0, _) = lit1.node;
142-
if n.leading_zeros() == n.count_zeros();
143-
if n > u128::from(self.verbose_bit_mask_threshold);
144-
then {
145-
span_lint_and_then(cx,
146-
VERBOSE_BIT_MASK,
147-
e.span,
148-
"bit mask could be simplified with a call to `trailing_zeros`",
149-
|diag| {
132+
133+
if let ExprKind::Binary(op, left, right) = &e.kind
134+
&& BinOpKind::Eq == op.node
135+
&& let ExprKind::Binary(op1, left1, right1) = &left.kind
136+
&& BinOpKind::BitAnd == op1.node
137+
&& let ExprKind::Lit(lit) = &right1.kind
138+
&& let LitKind::Int(n, _) = lit.node
139+
&& let ExprKind::Lit(lit1) = &right.kind
140+
&& let LitKind::Int(0, _) = lit1.node
141+
&& n.leading_zeros() == n.count_zeros()
142+
&& n > u128::from(self.verbose_bit_mask_threshold)
143+
{
144+
span_lint_and_then(
145+
cx,
146+
VERBOSE_BIT_MASK,
147+
e.span,
148+
"bit mask could be simplified with a call to `trailing_zeros`",
149+
|diag| {
150150
let sugg = Sugg::hir(cx, left1, "...").maybe_par();
151151
diag.span_suggestion(
152152
e.span,
153153
"try",
154154
format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()),
155155
Applicability::MaybeIncorrect,
156156
);
157-
});
158-
}
157+
},
158+
);
159159
}
160160
}
161161
}

0 commit comments

Comments
 (0)