2024-05-25 22:50:30 -05:00
|
|
|
if let StmtKind::Let(local) = stmt.kind
|
2022-10-05 12:17:57 -05:00
|
|
|
&& let Some(init) = local.init
|
|
|
|
&& let ExprKind::If(cond, then, Some(else_expr)) = init.kind
|
|
|
|
&& let ExprKind::DropTemps(expr) = cond.kind
|
|
|
|
&& let ExprKind::Lit(ref lit) = expr.kind
|
|
|
|
&& let LitKind::Bool(true) = lit.node
|
|
|
|
&& let ExprKind::Block(block, None) = then.kind
|
|
|
|
&& block.stmts.len() == 1
|
|
|
|
&& let StmtKind::Semi(e) = block.stmts[0].kind
|
|
|
|
&& let ExprKind::Binary(op, left, right) = e.kind
|
|
|
|
&& BinOpKind::Eq == op.node
|
|
|
|
&& let ExprKind::Lit(ref lit1) = left.kind
|
|
|
|
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node
|
|
|
|
&& let ExprKind::Lit(ref lit2) = right.kind
|
|
|
|
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit2.node
|
|
|
|
&& block.expr.is_none()
|
|
|
|
&& let ExprKind::Block(block1, None) = else_expr.kind
|
|
|
|
&& block1.stmts.len() == 1
|
|
|
|
&& let StmtKind::Semi(e1) = block1.stmts[0].kind
|
|
|
|
&& let ExprKind::Binary(op1, left1, right1) = e1.kind
|
|
|
|
&& BinOpKind::Eq == op1.node
|
|
|
|
&& let ExprKind::Lit(ref lit3) = left1.kind
|
|
|
|
&& let LitKind::Int(2, LitIntType::Unsuffixed) = lit3.node
|
|
|
|
&& let ExprKind::Lit(ref lit4) = right1.kind
|
|
|
|
&& let LitKind::Int(2, LitIntType::Unsuffixed) = lit4.node
|
|
|
|
&& block1.expr.is_none()
|
|
|
|
&& let PatKind::Wild = local.pat.kind
|
|
|
|
{
|
|
|
|
// report your lint here
|
2019-05-11 01:36:49 -05:00
|
|
|
}
|
2022-10-05 12:17:57 -05:00
|
|
|
if let ExprKind::If(cond, then, Some(else_expr)) = expr.kind
|
|
|
|
&& let ExprKind::Let(let_expr) = cond.kind
|
|
|
|
&& let PatKind::Lit(lit_expr) = let_expr.pat.kind
|
|
|
|
&& let ExprKind::Lit(ref lit) = lit_expr.kind
|
|
|
|
&& let LitKind::Bool(true) = lit.node
|
|
|
|
&& let ExprKind::Path(ref qpath) = let_expr.init.kind
|
|
|
|
&& match_qpath(qpath, &["a"])
|
|
|
|
&& let ExprKind::Block(block, None) = then.kind
|
|
|
|
&& block.stmts.is_empty()
|
|
|
|
&& block.expr.is_none()
|
|
|
|
&& let ExprKind::Block(block1, None) = else_expr.kind
|
|
|
|
&& block1.stmts.is_empty()
|
|
|
|
&& block1.expr.is_none()
|
|
|
|
{
|
|
|
|
// report your lint here
|
2021-12-06 05:33:31 -06:00
|
|
|
}
|