2019-05-11 06:36:49 +00:00
|
|
|
if_chain! {
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Local(local) = stmt.kind;
|
|
|
|
if let Some(init) = local.init;
|
2021-11-05 22:05:04 +00:00
|
|
|
if let ExprKind::If(cond, then, Some(else_expr)) = init.kind;
|
|
|
|
if let ExprKind::DropTemps(expr) = cond.kind;
|
|
|
|
if let ExprKind::Lit(ref lit) = expr.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Bool(true) = lit.node;
|
2021-11-05 22:05:04 +00:00
|
|
|
if let ExprKind::Block(block, None) = then.kind;
|
2019-05-19 14:52:44 +00:00
|
|
|
if block.stmts.len() == 1;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Semi(e) = block.stmts[0].kind;
|
|
|
|
if let ExprKind::Binary(op, left, right) = e.kind;
|
2019-05-11 06:36:49 +00:00
|
|
|
if BinOpKind::Eq == op.node;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let ExprKind::Lit(ref lit1) = left.kind;
|
|
|
|
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit1.node;
|
|
|
|
if let ExprKind::Lit(ref lit2) = right.kind;
|
|
|
|
if let LitKind::Int(1, LitIntType::Unsuffixed) = lit2.node;
|
2021-07-29 10:16:06 +00:00
|
|
|
if block.expr.is_none();
|
2021-11-05 22:05:04 +00:00
|
|
|
if let ExprKind::Block(block1, None) = else_expr.kind;
|
2019-05-19 14:52:44 +00:00
|
|
|
if block1.stmts.len() == 1;
|
2021-11-10 21:59:49 +00:00
|
|
|
if let StmtKind::Semi(e1) = block1.stmts[0].kind;
|
|
|
|
if let ExprKind::Binary(op1, left1, right1) = e1.kind;
|
2019-05-11 06:36:49 +00:00
|
|
|
if BinOpKind::Eq == op1.node;
|
2019-09-27 15:16:06 +00:00
|
|
|
if let ExprKind::Lit(ref lit3) = left1.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Int(2, LitIntType::Unsuffixed) = lit3.node;
|
2019-09-27 15:16:06 +00:00
|
|
|
if let ExprKind::Lit(ref lit4) = right1.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let LitKind::Int(2, LitIntType::Unsuffixed) = lit4.node;
|
2021-07-29 10:16:06 +00:00
|
|
|
if block1.expr.is_none();
|
2019-09-27 15:16:06 +00:00
|
|
|
if let PatKind::Wild = local.pat.kind;
|
2019-05-11 06:36:49 +00:00
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|
2021-10-29 01:39:41 +00:00
|
|
|
if_chain! {
|
2021-11-05 22:05:04 +00:00
|
|
|
if let ExprKind::If(cond, then, Some(else_expr)) = expr.kind;
|
|
|
|
if let ExprKind::Let(pat, expr1, _) = cond.kind;
|
|
|
|
if let PatKind::Lit(lit_expr) = pat.kind;
|
2021-10-29 01:39:41 +00:00
|
|
|
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
|
|
|
if let LitKind::Bool(true) = lit.node;
|
2021-11-05 22:05:04 +00:00
|
|
|
if let ExprKind::Path(ref qpath) = expr1.kind;
|
2021-11-08 23:05:37 +00:00
|
|
|
if match_qpath(qpath, &["a"]);
|
2021-11-05 22:05:04 +00:00
|
|
|
if let ExprKind::Block(block, None) = then.kind;
|
|
|
|
if block.stmts.is_empty();
|
2021-10-29 01:39:41 +00:00
|
|
|
if block.expr.is_none();
|
2021-11-05 22:05:04 +00:00
|
|
|
if let ExprKind::Block(block1, None) = else_expr.kind;
|
|
|
|
if block1.stmts.is_empty();
|
2021-10-29 01:39:41 +00:00
|
|
|
if block1.expr.is_none();
|
|
|
|
then {
|
|
|
|
// report your lint here
|
|
|
|
}
|
|
|
|
}
|