mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
60 lines
3.1 KiB
Text
60 lines
3.1 KiB
Text
if_chain! {
|
|
if let Expr_::ExprBlock(ref block) = expr.node;
|
|
if let Stmt_::StmtDecl(ref decl, _) = block.node
|
|
if let Decl_::DeclLocal(ref local) = decl.node;
|
|
if let Some(ref init) = local.init
|
|
if let Expr_::ExprMatch(ref expr, ref arms, MatchSource::ForLoopDesugar) = init.node;
|
|
if let Expr_::ExprCall(ref func, ref args) = expr.node;
|
|
// unimplemented: `ExprCall` is not further destructured at the moment
|
|
if arms.len() == 1;
|
|
if let Expr_::ExprLoop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.node;
|
|
if let Stmt_::StmtDecl(ref decl1, _) = body.node
|
|
if let Decl_::DeclLocal(ref local1) = decl1.node;
|
|
if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local1.pat.node;
|
|
if name.node.as_str() == "__next";
|
|
if let Stmt_::StmtExpr(ref e, _) = local1.pat.node
|
|
if let Expr_::ExprMatch(ref expr1, ref arms1, MatchSource::ForLoopDesugar) = e.node;
|
|
if let Expr_::ExprCall(ref func, ref args) = expr1.node;
|
|
// unimplemented: `ExprCall` is not further destructured at the moment
|
|
if arms1.len() == 2;
|
|
if let Expr_::ExprAssign(ref target, ref value) = arms1[0].body.node;
|
|
if let Expr_::ExprPath(ref path) = target.node;
|
|
if match_qpath(path, &["__next"]);
|
|
if let Expr_::ExprPath(ref path1) = value.node;
|
|
if match_qpath(path1, &["val"]);
|
|
if arms1[0].pats.len() == 1;
|
|
if let PatKind::TupleStruct(ref path2, ref fields, None) = arms1[0].pats[0].node;
|
|
if match_qpath(path2, &["{{root}}", "std", "option", "Option", "Some"]);
|
|
if fields.len() == 1;
|
|
// unimplemented: field checks
|
|
if let Expr_::ExprBreak(ref destination, None) = arms1[1].body.node;
|
|
if arms1[1].pats.len() == 1;
|
|
if let PatKind::Path(ref path3) = arms1[1].pats[0].node;
|
|
if match_qpath(path3, &["{{root}}", "std", "option", "Option", "None"]);
|
|
if let Stmt_::StmtDecl(ref decl2, _) = path3.node
|
|
if let Decl_::DeclLocal(ref local2) = decl2.node;
|
|
if let Some(ref init1) = local2.init
|
|
if let Expr_::ExprPath(ref path4) = init1.node;
|
|
if match_qpath(path4, &["__next"]);
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local2.pat.node;
|
|
if name1.node.as_str() == "y";
|
|
if let Stmt_::StmtExpr(ref e1, _) = local2.pat.node
|
|
if let Expr_::ExprBlock(ref block1) = e1.node;
|
|
if let Stmt_::StmtDecl(ref decl3, _) = block1.node
|
|
if let Decl_::DeclLocal(ref local3) = decl3.node;
|
|
if let Some(ref init2) = local3.init
|
|
if let Expr_::ExprPath(ref path5) = init2.node;
|
|
if match_qpath(path5, &["y"]);
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local3.pat.node;
|
|
if name2.node.as_str() == "z";
|
|
if arms[0].pats.len() == 1;
|
|
if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pats[0].node;
|
|
if name3.node.as_str() == "iter";
|
|
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name4, None) = local.pat.node;
|
|
if name4.node.as_str() == "_result";
|
|
if let Expr_::ExprPath(ref path6) = local.pat.node;
|
|
if match_qpath(path6, &["_result"]);
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|