Use match ergonomics for bit_mask lint
This commit is contained in:
parent
931e2b0026
commit
fe151ebb9c
@ -121,7 +121,7 @@ fn get_lints(&self) -> LintArray {
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if let ExprKind::Binary(ref cmp, ref left, ref right) = e.node {
|
||||
if let ExprKind::Binary(cmp, left, right) = &e.node {
|
||||
if cmp.node.is_comparison() {
|
||||
if let Some(cmp_opt) = fetch_int_literal(cx, right) {
|
||||
check_compare(cx, left, cmp.node, cmp_opt, e.span)
|
||||
@ -131,13 +131,13 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
}
|
||||
}
|
||||
if_chain! {
|
||||
if let ExprKind::Binary(ref op, ref left, ref right) = e.node;
|
||||
if let ExprKind::Binary(op, left, right) = &e.node;
|
||||
if BinOpKind::Eq == op.node;
|
||||
if let ExprKind::Binary(ref op1, ref left1, ref right1) = left.node;
|
||||
if let ExprKind::Binary(op1, left1, right1) = &left.node;
|
||||
if BinOpKind::BitAnd == op1.node;
|
||||
if let ExprKind::Lit(ref lit) = right1.node;
|
||||
if let ExprKind::Lit(lit) = &right1.node;
|
||||
if let LitKind::Int(n, _) = lit.node;
|
||||
if let ExprKind::Lit(ref lit1) = right.node;
|
||||
if let ExprKind::Lit(lit1) = &right.node;
|
||||
if let LitKind::Int(0, _) = lit1.node;
|
||||
if n.leading_zeros() == n.count_zeros();
|
||||
if n > u128::from(self.verbose_bit_mask_threshold);
|
||||
@ -173,7 +173,7 @@ fn invert_cmp(cmp: BinOpKind) -> BinOpKind {
|
||||
}
|
||||
|
||||
fn check_compare(cx: &LateContext<'_, '_>, bit_op: &Expr, cmp_op: BinOpKind, cmp_value: u128, span: Span) {
|
||||
if let ExprKind::Binary(ref op, ref left, ref right) = bit_op.node {
|
||||
if let ExprKind::Binary(op, left, right) = &bit_op.node {
|
||||
if op.node != BinOpKind::BitAnd && op.node != BinOpKind::BitOr {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user