rust/tests/ui/author/matches.stout
2019-09-27 17:21:20 +02:00

39 lines
1.7 KiB
Plaintext

if_chain! {
if let StmtKind::Decl(ref decl, _) = stmt.kind
if let DeclKind::Local(ref local) = decl.kind;
if let Some(ref init) = local.init;
if let ExprKind::Match(ref expr, ref arms, MatchSource::Normal) = init.kind;
if let ExprKind::Lit(ref lit) = expr.kind;
if let LitKind::Int(42, _) = lit.kind;
if arms.len() == 3;
if let ExprKind::Lit(ref lit1) = arms[0].body.kind;
if let LitKind::Int(5, _) = lit1.kind;
if arms[0].pats.len() == 1;
if let PatKind::Lit(ref lit_expr) = arms[0].pats[0].kind
if let ExprKind::Lit(ref lit2) = lit_expr.kind;
if let LitKind::Int(16, _) = lit2.kind;
if let ExprKind::Block(ref block) = arms[1].body.kind;
if let StmtKind::Decl(ref decl1, _) = block.kind
if let DeclKind::Local(ref local1) = decl1.kind;
if let Some(ref init1) = local1.init
if let ExprKind::Lit(ref lit3) = init1.kind;
if let LitKind::Int(3, _) = lit3.kind;
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local1.pat.kind;
if name.kind.as_str() == "x";
if let ExprKind::Path(ref path) = local1.pat.kind;
if match_qpath(path, &["x"]);
if arms[1].pats.len() == 1;
if let PatKind::Lit(ref lit_expr1) = arms[1].pats[0].kind
if let ExprKind::Lit(ref lit4) = lit_expr1.kind;
if let LitKind::Int(17, _) = lit4.kind;
if let ExprKind::Lit(ref lit5) = arms[2].body.kind;
if let LitKind::Int(1, _) = lit5.kind;
if arms[2].pats.len() == 1;
if let PatKind::Wild = arms[2].pats[0].kind;
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local.pat.kind;
if name1.kind.as_str() == "a";
then {
// report your lint here
}
}