mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-23 11:33:19 +00:00
48 lines
2.1 KiB
Text
48 lines
2.1 KiB
Text
if_chain! {
|
|
if let StmtKind::Local(ref local) = stmt.kind;
|
|
if let Some(ref init) = local.init;
|
|
if let Some(higher::If { cond: cond, then: then, r#else: else_expr}) = higher::If::hir(init)
|
|
if let ExprKind::Lit(ref lit) = cond.kind;
|
|
if let LitKind::Bool(true) = lit.node;
|
|
if let ExprKind::Block(ref block, ref label) = then.kind;
|
|
if block.stmts.len() == 1;
|
|
if let StmtKind::Semi(ref e, _) = block.stmts[0].kind
|
|
if let ExprKind::Binary(ref op, ref left, ref right) = e.kind;
|
|
if BinOpKind::Eq == op.node;
|
|
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;
|
|
if block.expr.is_none();
|
|
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
|
|
if block1.stmts.len() == 1;
|
|
if let StmtKind::Semi(ref e1, _) = block1.stmts[0].kind
|
|
if let ExprKind::Binary(ref op1, ref left1, ref right1) = e1.kind;
|
|
if BinOpKind::Eq == op1.node;
|
|
if let ExprKind::Lit(ref lit3) = left1.kind;
|
|
if let LitKind::Int(2, LitIntType::Unsuffixed) = lit3.node;
|
|
if let ExprKind::Lit(ref lit4) = right1.kind;
|
|
if let LitKind::Int(2, LitIntType::Unsuffixed) = lit4.node;
|
|
if block1.expr.is_none();
|
|
if let PatKind::Wild = local.pat.kind;
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|
|
if_chain! {
|
|
if let Some(higher::IfLet { let_pat: let_pat, let_expr: let_expr, if_then: if_then, if_else: else_expr}) = higher::IfLet::hir(expr)
|
|
if let PatKind::Lit(ref lit_expr) = let_pat.kind
|
|
if let ExprKind::Lit(ref lit) = lit_expr.kind;
|
|
if let LitKind::Bool(true) = lit.node;
|
|
if let ExprKind::Path(ref path) = let_expr.kind;
|
|
if match_qpath(path, &["a"]);
|
|
if let ExprKind::Block(ref block, ref label) = if_then.kind;
|
|
if block.stmts.len() == 0;
|
|
if block.expr.is_none();
|
|
if let ExprKind::Block(ref block1, ref label1) = else_expr.kind;
|
|
if block1.stmts.len() == 0;
|
|
if block1.expr.is_none();
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|